spaCy/spacy/tests/doc
Ines Montani df19e2bff6
💫 Allow setting of custom attributes during retokenization (closes #3314) (#3324)
<!--- 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.
2019-02-24 18:38:47 +01:00
..
__init__.py Rename "tokens" tests to "doc" 2017-01-11 18:59:01 +01:00
test_add_entities.py Tidy up and format remaining files 2018-11-30 17:43:08 +01:00
test_array.py 💫 Tidy up and auto-format tests (#2967) 2018-11-27 01:09:36 +01:00
test_creation.py 💫 Tidy up and auto-format tests (#2967) 2018-11-27 01:09:36 +01:00
test_doc_api.py Tidy up retokenizer tests 2019-02-24 14:14:11 +01:00
test_pickle_doc.py Tidy up and format remaining files 2018-11-30 17:43:08 +01:00
test_retokenize_merge.py 💫 Allow setting of custom attributes during retokenization (closes #3314) (#3324) 2019-02-24 18:38:47 +01:00
test_retokenize_split.py 💫 Allow setting of custom attributes during retokenization (closes #3314) (#3324) 2019-02-24 18:38:47 +01:00
test_span.py Make warning tests more explicit 2019-02-10 14:02:19 +01:00
test_to_json.py 💫 Add token match pattern validation via JSON schemas (#3244) 2019-02-13 01:47:26 +11:00
test_token_api.py 💫 Tidy up and auto-format tests (#2967) 2018-11-27 01:09:36 +01:00
test_underscore.py Tidy up and format remaining files 2018-11-30 17:43:08 +01:00