Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Get Dependency Parse Output from 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.

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

like image 626
user22490234 Avatar asked May 13 '16 21:05

user22490234


People also ask

What is dependency parsing?

What is Dependency Parsing? Dependency Parsing is the process to analyze the grammatical structure in a sentence and find out related words as well as the type of the relationship between them. Has one head and a dependent that modifies the head. Is labeled according to the nature of the dependency between the head and the dependent.

What are the fundamentals of dependency parsing in NLP?

In this article, we will look at the fundamentals of Dependency Parsing to gain perspective on how it is implemented in NLP. Dependency Parsing (DP) refers to examining the dependencies between the words of a sentence to analyze its grammatical structure.

How to use NLTK for dependency parsing?

We can use NLTK to achieve dependency parsing through one of the following methods: Probabilistic, projective dependency parser: These parsers use the knowledge of human language gleaned from hand-parsed sentences to predict new sentences. They are known to make mistakes and work with a restricted set of training data.

What is a graph-based Dependency Parser?

In a Graph-based dependency parser, graphs are directed, which means links have different directions, and there can be multiple arcs between nodes, this is called a multi-digraph. You can note that some arrows are thicker than others. This represents the weight of arcs. The more an arc weighs, the stronger the link between two nodes.


Video Answer


1 Answers

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   _       _
like image 68
Nirmal Avatar answered Sep 25 '22 18:09

Nirmal