我正在尝试让 NLTK 中的 StanfordDependencyParser 与德语一起运行。
from nltk.parse.stanford import StanfordDependencyParser
dep_parser = StanfordDependencyParser('../Stanford/stanford-parser-full-2015-12-09/stanford-parser.jar',
'../Stanford/stanford-parser-full-2015-12-09/stanford-parser-3.6.0-models.jar',
model_path='edu/stanford/nlp/models/lexparser/germanPCFG.ser.gz')
result = dep_parser.raw_parse("Deutschland ist ein foederal verfasster Staat in Mitteleuropa, der aus den 16 deutschen Laendern gebildet wird.")
dep = result.next()
print dep.to_dot()
我可以生成一棵树,但所有依赖项都标记为 NULL。
digraph G{
edge [dir=forward]
node [shape=plaintext]
0 [label="0 (None)"]
0 -> 2 [label="root"]
1 [label="1 (Deutschland)"]
2 [label="2 (ist)"]
2 -> 1 [label="NULL"]
2 -> 6 [label="NULL"]
2 -> 18 [label="NULL"]
3 [label="3 (ein)"]
4 [label="4 (foederal)"]
4 -> 5 [label="NULL"]
5 [label="5 (verfasster)"]
6 [label="6 (Staat)"]
6 -> 3 [label="NULL"]
6 -> 4 [label="NULL"]
6 -> 7 [label="NULL"]
6 -> 9 [label="NULL"]
6 -> 17 [label="NULL"]
7 [label="7 (in)"]
7 -> 8 [label="NULL"]
8 [label="8 (Mitteleuropa)"]
9 [label="9 (,)"]
10 [label="10 (der)"]
11 [label="11 (aus)"]
11 -> 12 [label="NULL"]
11 -> 13 [label="NULL"]
11 -> 14 [label="NULL"]
11 -> 15 [label="NULL"]
12 [label="12 (den)"]
13 [label="13 (16)"]
14 [label="14 (deutschen)"]
15 [label="15 (Laendern)"]
16 [label="16 (gebildet)"]
16 -> 11 [label="NULL"]
17 [label="17 (wird)"]
17 -> 10 [label="NULL"]
17 -> 16 [label="NULL"]
18 [label="18 (.)"]
}
我究竟做错了什么?它在切换到英语时有效。德语不支持依赖解析吗?