spaCy/spacy/tests/parser/test_beam_parse.py

24 lines
564 B
Python
Raw Normal View History

2017-10-07 03:15:15 +03:00
# coding: utf8
from __future__ import unicode_literals
2017-07-22 02:48:35 +03:00
import pytest
2017-11-05 16:39:57 +03:00
from ...language import Language
from ...pipeline import DependencyParser
2017-07-22 02:48:35 +03:00
2017-10-07 03:15:15 +03:00
@pytest.mark.models('en')
2017-11-05 16:39:57 +03:00
def test_beam_parse_en(EN):
2017-10-07 03:15:15 +03:00
doc = EN(u'Australia is a country', disable=['ner'])
ents = EN.entity(doc, beam_width=2)
print(ents)
2017-11-05 16:39:57 +03:00
def test_beam_parse():
nlp = Language()
nlp.add_pipe(DependencyParser(nlp.vocab), name='parser')
nlp.parser.add_label('nsubj')
nlp.begin_training()
doc = nlp.make_doc(u'Australia is a country')
nlp.parser(doc, beam_width=2)