问题描述
如何从SyntaxNet( https: //github.com/tensorflow/models/tree/master/syntaxnet )?我看到了对依赖关系解析的描述...对如何训练模型的描述,但没有关于如何获得依赖关系解析输出的描述.
How do you get a dependency parse (not syntax tree) output from SyntaxNet (https://github.com/tensorflow/models/tree/master/syntaxnet) ? I see a description of dependency parsing...a description of how to train a model, but not how to get dependency parse output.
SyntaxNet(特别是Parsey McParseface模型)是否甚至可以立即进行依赖项解析?
Does SyntaxNet (Specifically the Parsey McParseface model) even do dependency parsing out of the box?
推荐答案
将--arg_prefix brain_parser
传递给parser_eval.py
应该可以解决问题.但这需要将标记的输出作为输入.
Passing --arg_prefix brain_parser
to the parser_eval.py
should do the trick. But this requires the tagged output to be fed as input.
这是一个示例,其中第一遍标记单词,第二遍解析依赖性:
Here's an example where the first pass tags the words and the second pass resolves dependencies:
echo 'The quick brown fox ran over the lazy dog.' | bazel-bin/syntaxnet/parser_eval \
--input stdin \
--output stdout-conll \
--model syntaxnet/models/parsey_mcparseface/tagger-params \
--task_context syntaxnet/models/parsey_mcparseface/context.pbtxt \
--hidden_layer_sizes 64 \
--arg_prefix brain_tagger \
--graph_builder structured \
--slim_model \
--batch_size 1024 | bazel-bin/syntaxnet/parser_eval \
--input stdin-conll \
--output stdout-conll \
--hidden_layer_sizes 512,512 \
--arg_prefix brain_parser \
--graph_builder structured \
--task_context syntaxnet/models/parsey_mcparseface/context.pbtxt \
--model_path syntaxnet/models/parsey_mcparseface/parser-params \
--slim_model --batch_size 1024
这将产生以下输出:
1 The _ DET DT _ 4 det _ _
2 quick _ ADJ JJ _ 4 amod _ _
3 brown _ ADJ JJ _ 4 amod _ _
4 fox _ NOUN NN _ 5 nsubj _ _
5 ran _ VERB VBD _ 0 ROOT _ _
6 over _ ADP IN _ 5 prep _ _
7 the _ DET DT _ 9 det _ _
8 lazy _ ADJ JJ _ 9 amod _ _
9 dog _ NOUN NN _ 6 pobj _ _
10 . _ . . _ 5 punct _ _
这篇关于如何从SyntaxNet获取依赖项解析输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!