spaCy/spacy/tests/parser/test_beam_parse.py

24 lines
611 B
Python
Raw Normal View History

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