spaCy/website/docs/usage
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
..
101 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
_benchmarks-choi.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
adding-languages.md Clean up of char classes, few tokenizer fixes and faster default French tokenizer (#3293) 2019-02-20 22:10:13 +01:00
examples.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
facts-figures.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
index.md Update Python versions [ci skip] 2019-02-24 11:49:45 +01:00
linguistic-features.md 💫 Allow setting of custom attributes during retokenization (closes #3314) (#3324) 2019-02-24 18:38:47 +01:00
models.md Fix links [ci skip] 2019-02-17 22:25:50 +01:00
processing-pipelines.md Fix links [ci skip] 2019-02-17 22:25:50 +01:00
rule-based-matching.md Improve matcher example (resolves #3287) 2019-02-18 13:26:37 +01:00
saving-loading.md Add docs on serializing the pipeline (see #3289) [ci skip] 2019-02-18 14:13:29 +01:00
spacy-101.md Fix links [ci skip] 2019-02-17 22:25:50 +01:00
training.md Fix links [ci skip] 2019-02-17 22:25:50 +01:00
v2-1.md Update v2-1.md 2019-02-24 11:49:27 +01:00
v2.md Fix links [ci skip] 2019-02-17 22:25:50 +01:00
vectors-similarity.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
visualizers.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00