Stanford Parser

Views
From Spatial Language
Jump to: navigation, search

We developed a python interface to the Stanford Parser. It uses JPype to create a Java virtual machine, instantiate the parser, and call methods on it. Most of the code is focused on getting the Stanford Dependencies, but it's easy to add API to call any method on the parser. You can download it here.

Here's what the python code looks like, to get the Stanford dependencies:

       dependencies = self.parser.parseToStanfordDependencies("Pick up the tire pallet.")
       tupleResult = [(rel, gov.text, dep.text) for rel, gov, dep in dependencies.dependencies]
       self.assertEqual(tupleResult, [('prt', 'Pick', 'up'),
                                      ('det', 'pallet', 'the'),
                                      ('nn', 'pallet', 'tire'),
                                      ('dobj', 'Pick', 'pallet')

Personal tools