BLLIP / bllip-parser

BLLIP reranking parser (also known as Charniak-Johnson parser, Charniak parser, Brown reranking parser) See http://pypi.python.org/pypi/bllipparser/ for Python module.
http://bllip.cs.brown.edu/
227 stars 53 forks source link

Invalid trees break tree reader internal state #33

Closed dmcc closed 9 years ago

dmcc commented 9 years ago

Example:

>>> from bllipparser import Tree
>>> s = '(S1 (NNS Markets) (: --))' # valid tree

>>> t1 = Tree('(())') # invalid tree
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/bllipparser/RerankingParser.py", line 63, in __init__
    parser.inputTreeFromString(input_tree_or_string)
RuntimeError: [first-stage/PARSE/utils.C:52]: Saw paren rather than term

>>> Tree(s) # crashes 1st time
Saw )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/bllipparser/RerankingParser.py", line 63, in __init__
    parser.inputTreeFromString(input_tree_or_string)
RuntimeError: [first-stage/PARSE/utils.C:52]: Should have seen an open paren here.

>>> Tree(s) # succeeds 2nd time
Tree('(S1 (NNS Markets) (: --))')

(Thanks @cdg720 for catching this!)