Sunday 15 May 2011

java - Treebank-style tree parser python -



java - Treebank-style tree parser python -

recently have been trying parse syntactic trees returned stanford parser in python. have been trying nltk tree = tree.parse(result['sentences'][0]['parsetree']) , parsing succeeds tree class of nltk offers few processing methods. need methods tree.isprepreterminal() not included understand. found this alternative seems doesnt 64bit architectures , gives me error importerror: inputtree/_inputtree.so: wrong elf class: elfclass32 though compiled -m64 flag. have been looking lastly 2 days, if know way create above module work 64bit systems or alternate library or @ to the lowest degree nltk.tree documentation implement methods myself please allow me know.

unfortunately, pyinputtree no longer maintained. however, inputtree class charniak parser lives on in wrapped form tree class in bllip parser. doesn't implement isprepreterminal() here's 1 way it:

import bllipparser def is_prepreterminal(node): """returns true iff children of node preterminals.""" subtrees = node.subtrees() homecoming len(subtrees) > 0 , \ all(subtree.is_preterminal() subtree in subtrees) # testing code tree = bllipparser.tree('(s1 (s (np (dt this)) (vp (vbz is) (np (dt a) (adjp (rb fairly) (jj simple)) (nn parse) (nn tree))) (. .)))') subtree in tree.all_subtrees(): print subtree, is_prepreterminal(subtree)

see bllipparser on pypi more information.

java python nlp nltk

No comments:

Post a Comment