mirror of
https://github.com/explosion/spaCy.git
synced 2025-06-05 13:43:24 +03:00
Document PhraseMatcher.remove [ci skip]
This commit is contained in:
parent
c23edf302b
commit
aad66d9bb9
|
@ -87,6 +87,8 @@ cdef class PhraseMatcher:
|
||||||
the key does not exist.
|
the key does not exist.
|
||||||
|
|
||||||
key (unicode): The match ID.
|
key (unicode): The match ID.
|
||||||
|
|
||||||
|
DOCS: https://spacy.io/api/phrasematcher#remove
|
||||||
"""
|
"""
|
||||||
if key not in self._docs:
|
if key not in self._docs:
|
||||||
raise KeyError(key)
|
raise KeyError(key)
|
||||||
|
|
|
@ -152,3 +152,22 @@ overwritten.
|
||||||
| `match_id` | unicode | An ID for the thing you're matching. |
|
| `match_id` | unicode | An ID for the thing you're matching. |
|
||||||
| `on_match` | callable or `None` | Callback function to act on matches. Takes the arguments `matcher`, `doc`, `i` and `matches`. |
|
| `on_match` | callable or `None` | Callback function to act on matches. Takes the arguments `matcher`, `doc`, `i` and `matches`. |
|
||||||
| `*docs` | list | `Doc` objects of the phrases to match. |
|
| `*docs` | list | `Doc` objects of the phrases to match. |
|
||||||
|
|
||||||
|
## PhraseMatcher.remove {#remove tag="method" new="2.2"}
|
||||||
|
|
||||||
|
Remove a rule from the matcher by match ID. A `KeyError` is raised if the key
|
||||||
|
does not exist.
|
||||||
|
|
||||||
|
> #### Example
|
||||||
|
>
|
||||||
|
> ```python
|
||||||
|
> matcher = PhraseMatcher(nlp.vocab)
|
||||||
|
> matcher.add("OBAMA", None, nlp("Barack Obama"))
|
||||||
|
> assert "OBAMA" in matcher
|
||||||
|
> matcher.remove("OBAMA")
|
||||||
|
> assert "OBAMA" not in matcher
|
||||||
|
> ```
|
||||||
|
|
||||||
|
| Name | Type | Description |
|
||||||
|
| ----- | ------- | ------------------------- |
|
||||||
|
| `key` | unicode | The ID of the match rule. |
|
||||||
|
|
Loading…
Reference in New Issue
Block a user