def parse_to_readings(self, sentence): """:see: ReadingCommand.parse_to_readings()""" from nltk.sem import root_semrep tokens = sentence.split() trees = self._parser.parse(tokens) return [root_semrep(tree) for tree in trees]
def _get_readings(self, sentence): """ Build a list of semantic readings for a sentence. @rtype: C{list} of L{logic.Expression}. """ tokens = sentence.split() trees = self._parser.nbest_parse(tokens) return [root_semrep(tree) for tree in trees]
def demo(): cp = parse.load_parser('file:rdf.fcfg', trace=0) tokens = 'list the actors in the_shining'.split() trees = cp.nbest_parse(tokens) tree = trees[0] semrep = sem.root_semrep(tree) trans = SPARQLTranslator() trans.translate(semrep) print trans.query
def parse_to_readings(self, sentence): """@see: ReadingCommand.parse_to_readings()""" tokens = sentence.split() trees = self._parser.nbest_parse(tokens) return [root_semrep(tree) for tree in trees]