Skip to content

Commit

Permalink
bugfix in unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfgang Seeker committed Apr 8, 2016
1 parent 72e0de7 commit 80bea62
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions spacy/syntax/iterators.pxd
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

from spacy.tokens.doc cimport Doc

cdef dict CHUNKERS

cdef class DocIterator:
cdef Doc _doc

Expand Down
2 changes: 2 additions & 0 deletions spacy/syntax/iterators.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ from spacy.tokens.token cimport Token

from spacy.parts_of_speech cimport NOUN

CHUNKERS = {'en':EnglishNounChunks, 'de':GermanNounChunks}

# base class for document iterators
cdef class DocIterator:
def __init__(self, Doc doc):
Expand Down
3 changes: 1 addition & 2 deletions spacy/syntax/parser.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ from ._parse_features cimport fill_context
from .stateclass cimport StateClass
from ._state cimport StateC

from spacy.syntax.iterators cimport DocIterator, EnglishNounChunks, GermanNounChunks
CHUNKERS = {'en':EnglishNounChunks, 'de':GermanNounChunks}
from spacy.syntax.iterators cimport CHUNKERS, DocIterator, EnglishNounChunks, GermanNounChunks


DEBUG = False
Expand Down
6 changes: 4 additions & 2 deletions spacy/tests/tokens/test_noun_chunks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from spacy.attrs import HEAD, DEP
from spacy.symbols import nsubj, dobj, punct, amod, nmod, conj, cc, root
from spacy.en import English

from spacy.syntax.iterators import EnglishNounChunks


def test_not_nested():
nlp = English(parser=False)
nlp = English(parser=False, entity=False)
sent = u'''Peter has chronic command and control issues'''.strip()
tokens = nlp(sent)
tokens.from_array(
Expand All @@ -22,6 +22,7 @@ def test_not_nested():
[-2, conj],
[-5, dobj]
], dtype='int32'))
tokens.noun_chunks = EnglishNounChunks
for chunk in tokens.noun_chunks:
print(chunk.text)
word_occurred = {}
Expand All @@ -31,3 +32,4 @@ def test_not_nested():
word_occurred[word.text] += 1
for word, freq in word_occurred.items():
assert freq == 1, (word, [chunk.text for chunk in tokens.noun_chunks])

0 comments on commit 80bea62

Please sign in to comment.