mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-13 02:36:32 +03:00
context manager with space (for consistency)
This commit is contained in:
parent
da48c6a2a2
commit
262552010d
|
@ -265,7 +265,7 @@ for doc in nlp.pipe(texts, disable=["tagger", "parser"]):
|
||||||
|
|
||||||
If you need to **execute more code** with components disabled – e.g. to reset
|
If you need to **execute more code** with components disabled – e.g. to reset
|
||||||
the weights or update only some components during training – you can use the
|
the weights or update only some components during training – you can use the
|
||||||
[`nlp.select_pipes`](/api/language#select_pipes) contextmanager. At the end of
|
[`nlp.select_pipes`](/api/language#select_pipes) context manager. At the end of
|
||||||
the `with` block, the disabled pipeline components will be restored
|
the `with` block, the disabled pipeline components will be restored
|
||||||
automatically. Alternatively, `select_pipes` returns an object that lets you
|
automatically. Alternatively, `select_pipes` returns an object that lets you
|
||||||
call its `restore()` method to restore the disabled components when needed. This
|
call its `restore()` method to restore the disabled components when needed. This
|
||||||
|
@ -274,7 +274,7 @@ blocks.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
### Disable for block
|
### Disable for block
|
||||||
# 1. Use as a contextmanager
|
# 1. Use as a context manager
|
||||||
with nlp.select_pipes(disable=["tagger", "parser"]):
|
with nlp.select_pipes(disable=["tagger", "parser"]):
|
||||||
doc = nlp("I won't be tagged and parsed")
|
doc = nlp("I won't be tagged and parsed")
|
||||||
doc = nlp("I will be tagged and parsed")
|
doc = nlp("I will be tagged and parsed")
|
||||||
|
|
|
@ -249,7 +249,7 @@ The following methods, attributes and commands are new in spaCy v3.0.
|
||||||
| ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
| ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| [`Token.lex`](/api/token#attributes) | Access a token's [`Lexeme`](/api/lexeme). |
|
| [`Token.lex`](/api/token#attributes) | Access a token's [`Lexeme`](/api/lexeme). |
|
||||||
| [`Token.morph`](/api/token#attributes) [`Token.morph_`](/api/token#attributes) | Access a token's morphological analysis. |
|
| [`Token.morph`](/api/token#attributes) [`Token.morph_`](/api/token#attributes) | Access a token's morphological analysis. |
|
||||||
| [`Language.select_pipes`](/api/language#select_pipes) | Contextmanager for enabling or disabling specific pipeline components for a block. |
|
| [`Language.select_pipes`](/api/language#select_pipes) | Context manager for enabling or disabling specific pipeline components for a block. |
|
||||||
| [`Language.analyze_pipes`](/api/language#analyze_pipes) | [Analyze](/usage/processing-pipelines#analysis) components and their interdependencies. |
|
| [`Language.analyze_pipes`](/api/language#analyze_pipes) | [Analyze](/usage/processing-pipelines#analysis) components and their interdependencies. |
|
||||||
| [`Language.resume_training`](/api/language#resume_training) | Experimental: continue training a pretrained model and initialize "rehearsal" for components that implement a `rehearse` method to prevent catastrophic forgetting. |
|
| [`Language.resume_training`](/api/language#resume_training) | Experimental: continue training a pretrained model and initialize "rehearsal" for components that implement a `rehearse` method to prevent catastrophic forgetting. |
|
||||||
| [`@Language.factory`](/api/language#factory) [`@Language.component`](/api/language#component) | Decorators for [registering](/usage/processing-pipelines#custom-components) pipeline component factories and simple stateless component functions. |
|
| [`@Language.factory`](/api/language#factory) [`@Language.component`](/api/language#component) | Decorators for [registering](/usage/processing-pipelines#custom-components) pipeline component factories and simple stateless component functions. |
|
||||||
|
@ -336,13 +336,13 @@ Note that spaCy v3.0 now requires **Python 3.6+**.
|
||||||
[training config](/usage/training#config).
|
[training config](/usage/training#config).
|
||||||
- [`Language.add_pipe`](/api/language#add_pipe) now takes the **string name** of
|
- [`Language.add_pipe`](/api/language#add_pipe) now takes the **string name** of
|
||||||
the component factory instead of the component function.
|
the component factory instead of the component function.
|
||||||
- **Custom pipeline components** now needs to be decorated with the
|
- **Custom pipeline components** now need to be decorated with the
|
||||||
[`@Language.component`](/api/language#component) or
|
[`@Language.component`](/api/language#component) or
|
||||||
[`@Language.factory`](/api/language#factory) decorator.
|
[`@Language.factory`](/api/language#factory) decorator.
|
||||||
- [`Language.update`](/api/language#update) now takes a batch of
|
- [`Language.update`](/api/language#update) now takes a batch of
|
||||||
[`Example`](/api/example) objects instead of raw texts and annotations, or
|
[`Example`](/api/example) objects instead of raw texts and annotations, or
|
||||||
`Doc` and `GoldParse` objects.
|
`Doc` and `GoldParse` objects.
|
||||||
- The `Language.disable_pipes` contextmanager has been replaced by
|
- The `Language.disable_pipes` context manager has been replaced by
|
||||||
[`Language.select_pipes`](/api/language#select_pipes), which can explicitly
|
[`Language.select_pipes`](/api/language#select_pipes), which can explicitly
|
||||||
disable or enable components.
|
disable or enable components.
|
||||||
- The [`Language.update`](/api/language#update),
|
- The [`Language.update`](/api/language#update),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user