mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
Add collapse_phrases option to displacy (closes #2266)
This commit is contained in:
parent
87cc6b3599
commit
6fb6371670
|
@ -86,6 +86,10 @@ def parse_deps(orig_doc, options={}):
|
||||||
doc = Doc(orig_doc.vocab).from_bytes(orig_doc.to_bytes())
|
doc = Doc(orig_doc.vocab).from_bytes(orig_doc.to_bytes())
|
||||||
if not doc.is_parsed:
|
if not doc.is_parsed:
|
||||||
user_warning(Warnings.W005)
|
user_warning(Warnings.W005)
|
||||||
|
if options.get('collapse_phrases', False):
|
||||||
|
for np in list(doc.noun_chunks):
|
||||||
|
np.merge(tag=np.root.tag_, lemma=np.root.lemma_,
|
||||||
|
ent_type=np.root.ent_type_)
|
||||||
if options.get('collapse_punct', True):
|
if options.get('collapse_punct', True):
|
||||||
spans = []
|
spans = []
|
||||||
for word in doc[:-1]:
|
for word in doc[:-1]:
|
||||||
|
|
|
@ -157,6 +157,12 @@ p
|
||||||
| as it prevents long arcs to attach punctuation.
|
| as it prevents long arcs to attach punctuation.
|
||||||
+cell #[code True]
|
+cell #[code True]
|
||||||
|
|
||||||
|
+row
|
||||||
|
+cell #[code collapse_phrases]
|
||||||
|
+cell bool
|
||||||
|
+cell Merge base noun phrases into one token.
|
||||||
|
+cell #[code False]
|
||||||
|
|
||||||
+row
|
+row
|
||||||
+cell #[code compact]
|
+cell #[code compact]
|
||||||
+cell bool
|
+cell bool
|
||||||
|
|
Loading…
Reference in New Issue
Block a user