Search code examples
parsingnlpstanford-nlp

How to convert from Stanford Universal Dependencies to Phrase Grammar?


In my application I am using Stanford CoreNLP for parsing english text into a graph data structure (Universal Dependencies).

After some modifications of the graph I need to generate a natural language output for which I am using SimpleNLG: https://github.com/simplenlg/simplenlg

However SimpleNLG is using Phrase Grammar.

Therefore in order to successfully use SimpleNLG for natural language generation I need to convert from Universal Dependencies into Phrase Grammar.

What is the easiest way of achieving this?

So far I have only come across this article on this topic: http://delivery.acm.org/10.1145/1080000/1072147/p14-xia.pdf?ip=86.52.161.138&id=1072147&acc=OPEN&key=4D4702B0C3E38B35%2E4D4702B0C3E38B35%2E4D4702B0C3E38B35%2E6D218144511F3437&CFID=642131329&CFTOKEN=21335001&acm=1468166339_844b802736ce07dab89064efb7f8ede9

I am hoping that someone might have some more practical code examples to share on this issue?


Solution

  • Phrase-structure trees contain more information than dependency trees and therefore you cannot deterministically convert dependency trees to phrase-structure trees.

    But if you are using CoreNLP to parse the sentences, take a look at the parse annotator. Unlike the dependency parser, this parser also outputs phrase-structure trees, so you can use this annotator to directly parse your sentences to phrase-structure trees.