2020-09-21 21:43:54 +03:00
|
|
|
from spacy.tokens import Doc
|
2017-05-29 23:14:31 +03:00
|
|
|
|
|
|
|
|
2020-09-21 21:43:54 +03:00
|
|
|
def test_de_parser_noun_chunks_standard_de(de_vocab):
|
|
|
|
words = ["Eine", "Tasse", "steht", "auf", "dem", "Tisch", "."]
|
|
|
|
heads = [1, 2, 2, 2, 5, 3, 2]
|
2020-07-15 15:13:58 +03:00
|
|
|
pos = ["DET", "NOUN", "VERB", "ADP", "DET", "NOUN", "PUNCT"]
|
2018-11-27 03:09:36 +03:00
|
|
|
deps = ["nk", "sb", "ROOT", "mo", "nk", "nk", "punct"]
|
2020-09-21 21:43:54 +03:00
|
|
|
doc = Doc(de_vocab, words=words, pos=pos, deps=deps, heads=heads)
|
2017-05-29 23:14:31 +03:00
|
|
|
chunks = list(doc.noun_chunks)
|
|
|
|
assert len(chunks) == 2
|
|
|
|
assert chunks[0].text_with_ws == "Eine Tasse "
|
|
|
|
assert chunks[1].text_with_ws == "dem Tisch "
|
|
|
|
|
|
|
|
|
2020-09-21 21:43:54 +03:00
|
|
|
def test_de_extended_chunk(de_vocab):
|
|
|
|
# fmt: off
|
|
|
|
words = ["Die", "Sängerin", "singt", "mit", "einer", "Tasse", "Kaffee", "Arien", "."]
|
|
|
|
heads = [1, 2, 2, 2, 5, 3, 5, 2, 2]
|
2020-07-15 15:13:58 +03:00
|
|
|
pos = ["DET", "NOUN", "VERB", "ADP", "DET", "NOUN", "NOUN", "NOUN", "PUNCT"]
|
2018-11-27 03:09:36 +03:00
|
|
|
deps = ["nk", "sb", "ROOT", "mo", "nk", "nk", "nk", "oa", "punct"]
|
2020-09-21 21:43:54 +03:00
|
|
|
# fmt: on
|
|
|
|
doc = Doc(de_vocab, words=words, pos=pos, deps=deps, heads=heads)
|
2017-05-29 23:14:31 +03:00
|
|
|
chunks = list(doc.noun_chunks)
|
|
|
|
assert len(chunks) == 3
|
|
|
|
assert chunks[0].text_with_ws == "Die Sängerin "
|
|
|
|
assert chunks[1].text_with_ws == "einer Tasse Kaffee "
|
|
|
|
assert chunks[2].text_with_ws == "Arien "
|