mirror of
https://github.com/explosion/spaCy.git
synced 2025-10-25 13:11:03 +03:00
<!--- 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.
|
||
|---|---|---|
| .. | ||
| __init__.py | ||
| _test_issue1622.py | ||
| _test_issue2800.py | ||
| test_issue1-1000.py | ||
| test_issue1001-1500.py | ||
| test_issue1501-2000.py | ||
| test_issue1971.py | ||
| test_issue2001-2500.py | ||
| test_issue2501-3000.py | ||
| test_issue2656.py | ||
| test_issue2728.py | ||
| test_issue2822.py | ||
| test_issue2833.py | ||
| test_issue2926.py | ||
| test_issue3002.py | ||
| test_issue3009.py | ||
| test_issue3012.py | ||
| test_issue3199.py | ||
| test_issue3209.py | ||
| test_issue3248.py | ||
| test_issue3277.py | ||
| test_issue3288.py | ||
| test_issue3289.py | ||