mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-27 18:36:36 +03:00
df19e2bff6
<!--- Provide a general summary of your changes in the title. --> ## Description This PR adds the abilility to override custom extension attributes during merging. This will only work for attributes that are writable, i.e. attributes registered with a default value like `default=False` or attribute that have both a getter *and* a setter implemented. ```python Token.set_extension('is_musician', default=False) doc = nlp("I like David Bowie.") with doc.retokenize() as retokenizer: attrs = {"LEMMA": "David Bowie", "_": {"is_musician": True}} retokenizer.merge(doc[2:4], attrs=attrs) assert doc[2].text == "David Bowie" assert doc[2].lemma_ == "David Bowie" assert doc[2]._.is_musician ``` ### Types of change enhancement ## Checklist <!--- Before you submit the PR, go over this checklist and make sure you can tick off all the boxes. [] -> [x] --> - [x] I have submitted the spaCy Contributor Agreement. - [x] I ran the tests, and all new and existing tests passed. - [x] My changes don't require a change to the documentation, or if they do, I've added all required information. |
||
---|---|---|
.. | ||
101 | ||
_benchmarks-choi.md | ||
adding-languages.md | ||
examples.md | ||
facts-figures.md | ||
index.md | ||
linguistic-features.md | ||
models.md | ||
processing-pipelines.md | ||
rule-based-matching.md | ||
saving-loading.md | ||
spacy-101.md | ||
training.md | ||
v2-1.md | ||
v2.md | ||
vectors-similarity.md | ||
visualizers.md |