我正在与斯坦福解析器合作,从复习句子中提取语法依赖结构。我的问题是,出于某种原因,我的代码生成的输出与生成我的斯坦福在线工具的输出不同。下面是一个例子。
评论句:相机的图片质量不好。
My代码输出(它使用了 EnglishPCFG 模型和EnglishPCFG结构)
root(ROOT-0, -LSB--1),
det(quality-4, The-2),
nn(quality-4, picture-3),
nsubj(-RSB--11, quality-4),
det(camera-7, the-6),
prep_of(quality-4, camera-7),
cop(-RSB--11, is-8),
neg(-RSB--11, not-9),
amod(-RSB--11, good-10),
ccomp(-LSB--1, -RSB--11)
斯坦福在线工具输出:
det(quality-3, The-1)
nn(quality-3, picture-2)
nsubj(good-9, quality-3)
det(camera-6, the-5)
prep_of(quality-3, camera-6)
cop(good-9, is-7)
neg(good-9, not-8)
root(ROOT-0, good-9)
我正在寻找这种差异的原因。在线解析器使用什么样的模型和依赖结构?如果我错过了一些显而易见的东西,我很抱歉。任何帮助都将不胜感激。
如果需要,我可以添加代码片段。
更新:
我更改了代码,以忽略SP标记程序生成的LSB
和RSB
,但是生成的语法结构仍然与在线工具不同。下面是一个示例:
评论句:相机的大小和图片质量是完美的。
我的代码输出
det(quality-5, The-1),
nn(quality-5, size-2),
conj_and(size-2, picture-4),
nsubj(perfect-10, quality-5),
det(camera-8, the-7),
prep_of(quality-5, camera-8),
cop(perfect-10, is-9),
root(ROOT-0, perfect-10)
斯坦福在线工具输出:
det(quality-5, The-1)
nn(quality-5, size-2)
conj_and(size-2, picture-4)
**nn(quality-5, picture-4)**
nsubj(perfect-10, quality-5)
det(camera-8, the-7)
prep_of(quality-5, camera-8)
cop(perfect-10, is-9)
root(ROOT-0, perfect-10)
注意我的代码输出中缺少的nn
依赖项。我想弄清楚为什么会发生这种事。任何帮助都将不胜感激。
更新(下面相关代码片段)
rawWords2 = -LSB-,尺寸,图片,质量,相机,是完美的,-RSB-
lp = LexicalizedParser使用EnglishPCFG模型
Tree parse = lp.apply(rawWords2.subList(1,rawWords2.size() - 1));
TreebankLanguagePack tlp = new PennTreebankLanguagePack();
GrammaticalStructureFactory gsf = tlp.grammaticalStructureFactory();
GrammaticalStructure gs = gsf.newGrammaticalStructure(parse);
tdl = (List<TypedDependency>) gs.typedDependenciesCollapsed();
System.out.println(tdl.toString());
如文章前面所提到的,输出到屏幕。
另一个观察。
我与斯坦福图书馆合作,向我展示了quality
和picture
之间的依赖关系,如斯坦福在线工具nn
所示,但库显示的依赖关系是dep
(即找不到更合适的依赖项)。现在的问题是,为什么斯坦福在线工具显示quality
和picture
之间的nn依赖关系,而斯坦福库则显示dep
作为依赖项。
发布于 2014-02-23 21:23:39
是否获得额外的nn
依赖关系的主要问题是是否存在跨协调的依赖关系传播(size
是quality
的nn
,它与picture
协调,因此我们也将其称为quality
的nn
)。在线输出显示带传播的折叠输出,而调用不包括传播的API方法。您可以从命令行中看到使用选项,如本文底部所示。在API中,要获得协调传播,您应该调用
gs.typedDependenciesCCprocessed()
(而不是gs.typedDependenciesCollapsed()
)。
其他评论:
-LSB-
)从何而来?它们不应该由令牌程序引入。如果是的话,那就是窃听器。你能说出你为它们的生成做了些什么吗?我怀疑它们可能来自你的预处理?在一个句子中,意想不到的事情往往会导致解析质量严重下降。parser-user
列表),您的准确性是否会因为代码以外的其他原因而下降,因为它们在早期版本中是为了期望依赖项名称。使用命令行的差异示例:
[manning]$ cat > camera.txt
The size and picture quality of the camera is perfect.
[manning]$ java edu.stanford.nlp.parser.lexparser.LexicalizedParser -outputFormat typedDependencies -outputFormatOptions collapsedDependencies edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz camera.txt
Loading parser from serialized file edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz ... done [2.4 sec].
Parsing file: camera.txt
Parsing [sent. 1 len. 11]: The size and picture quality of the camera is perfect .
det(quality-5, The-1)
nn(quality-5, size-2)
conj_and(size-2, picture-4)
nsubj(perfect-10, quality-5)
det(camera-8, the-7)
prep_of(quality-5, camera-8)
cop(perfect-10, is-9)
root(ROOT-0, perfect-10)
Parsed file: camera.txt [1 sentences].
Parsed 11 words in 1 sentences (6.94 wds/sec; 0.63 sents/sec).
[manning]$ java edu.stanford.nlp.parser.lexparser.LexicalizedParser -outputFormat typedDependencies -outputFormatOptions CCPropagatedDependencies edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz camera.txt
Loading parser from serialized file edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz ... done [2.2 sec].
Parsing file: camera.txt
Parsing [sent. 1 len. 11]: The size and picture quality of the camera is perfect .
det(quality-5, The-1)
nn(quality-5, size-2)
conj_and(size-2, picture-4)
nn(quality-5, picture-4)
nsubj(perfect-10, quality-5)
det(camera-8, the-7)
prep_of(quality-5, camera-8)
cop(perfect-10, is-9)
root(ROOT-0, perfect-10)
Parsed file: camera.txt [1 sentences].
Parsed 11 words in 1 sentences (12.85 wds/sec; 1.17 sents/sec).
发布于 2014-02-21 10:44:57
根据我的观察,斯坦福在线解析器的后端仍然使用旧版本。
我已经使用斯坦福解析器一年了。我们已经使用3.2.0版本很长时间了。当3.3.0版本发布时,附带了情感分析的附加功能,我尝试使用更新的版本。但是,它与3.2.0版本略有不同的依赖关系和我们产品的效率已经下降。
如果您的需求只是提取依赖关系,而不是使用情感分析。我建议您使用3.2.0版本。
检查此页的末尾以下载早期版本的解析器。
https://stackoverflow.com/questions/21921625
复制相似问题