10

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.

Does SyntaxNet (Specifically the Parsey McParseface model) even do dependency parsing out of the box?

user22490234
  • 315
  • 2
  • 10

1 Answers1

14

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

This generates the following output:

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   _       _
Nirmal
  • 9,391
  • 11
  • 57
  • 81
  • 8
    To add on to this, if you simply comment-out the bazel-bin/syntaxnet/conll2tree final pipe (and args) of the models/syntaxnet/syntaxnet/demo.sh you will get this result automatically. – user22490234 May 16 '16 at 15:14
  • I'm having trouble finding an in depth explanation of this output. What do the rows of dashes stand for? Also what's the purpose of the row of numbers( Not 1 - 10. The other one ) – Kahless Aug 09 '16 at 02:15
  • 2
    @Kahless: See http://ilk.uvt.nl/conll/#dataformat for field definitions. – Nirmal Aug 12 '16 at 10:28
  • Cool. Thanks for the reference. – Kahless Aug 13 '16 at 03:19
  • @Nirmal is there some kind of man page or other documentation describing the possible values for arg_prefix? – matanster Aug 31 '16 at 12:29
  • 1
    @matanster: The possible values are either `brain_pos` or `brain_parser`. Details can be found here: https://github.com/tensorflow/models/tree/master/syntaxnet – Nirmal Aug 31 '16 at 19:19
  • Is that possible with russian language too? According to pretrained models https://github.com/tensorflow/models/blob/master/syntaxnet/universal.md – Vic Nicethemer Mar 14 '17 at 08:10
  • @VicNicethemer: Yes, just download the model from http://download.tensorflow.org/models/parsey_universal/Russian.zip and refer to the appropriate files within the folder. You might not be able to feed the context though, as the context file seems to be not available for the Parsey's Cousins languages. – Nirmal Mar 15 '17 at 19:28