spaCy/website/docs/api
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
..
annotation.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
cli.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
cython-classes.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
cython-structs.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
cython.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
dependencyparser.md Improve built-in component API docs 2019-02-24 13:11:49 +01:00
doc.md 💫 Allow setting of custom attributes during retokenization (closes #3314) (#3324) 2019-02-24 18:38:47 +01:00
entityrecognizer.md Improve built-in component API docs 2019-02-24 13:11:49 +01:00
entityruler.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
goldcorpus.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
goldparse.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
index.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
language.md Remove n_threads 2019-02-17 22:25:42 +01:00
lemmatizer.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
lexeme.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
matcher.md Remove n_threads 2019-02-17 22:25:42 +01:00
phrasematcher.md Remove n_threads 2019-02-17 22:25:42 +01:00
pipeline-functions.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
sentencesegmenter.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
span.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
stringstore.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
tagger.md Improve built-in component API docs 2019-02-24 13:11:49 +01:00
textcategorizer.md Update TextCategorizer docs 2019-02-24 13:11:57 +01:00
token.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
tokenizer.md Fix docs example (see #2728) 2019-02-21 14:22:06 +01:00
top-level.md Document regex utilities [ci skip] 2019-02-24 18:34:10 +01:00
vectors.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00
vocab.md 💫 Update website (#3285) 2019-02-17 19:31:19 +01:00