spaCy - Util.filter_spans
This utility function was introduced in version 2.0. It will filter a sequence of span objects and also removes the duplicates. This function is very useful for creating the named entities.
Argument
The table below explains its argument −
| NAME | TYPE | DESCRIPTION |
|---|---|---|
| spans | iterable | It represents the spans to filter. |
Example
An example of util.filter_spans() function is as follows −
import spacy
text = nlp("This is Tutorialspoint.com.")
spans = [text[0:2], text[0:2], text[0:4]]
filtered_document = spacy.util.filter_spans(spans)
filtered_document
Output
You will receive the following output −
[This is Tutorialspoint.com.]
spacy_util_get_data_path.htm
Advertisements