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

AttributeError: type object 'CharniakParser' has no attribute 'loadModel' #71

Open liutaonuist opened 1 year ago

liutaonuist commented 1 year ago

AttributeError: type object 'CharniakParser' has no attribute 'loadModel', from . import CharniakParser as parser from . import JohnsonReranker as reranker

dmcc commented 1 year ago

Thanks for the report! Seems like BLLIP Parser might not have been installed correctly. Can you give more information on the issue? These would be helpful:

  1. Full traceback of the error
  2. More context on what code you were running which triggered the error
  3. How BLLIP Parser was installed and/or built (i.e., with pip, as a dependency of something else, etc.)
  4. Your OS/distribution

Also, can you add more detail on how this issue relates to your comment on https://github.com/dmcc/bllip-parser/commit/558adf67aaf11925eec007b1451a729c21bad57d#commitcomment-88965788 ?

liutaonuist commented 1 year ago

1、Problem(1、Full traceback of the error) Traceback (most recent call last): File "amr_parsing.py", line 435, in main() File "amr_parsing.py", line 168, in main instances = preprocess(amr_file,START_SNLP=True,INPUT_AMR=args.amrfmt, PRP_FORMAT=args.prpfmt) File "/root/autodl-tmp/CLEVE-main/camr/preprocessing.py", line 504, in preprocess dparser.parse(tok_sent_filename) File "/root/autodl-tmp/CLEVE-main/camr/depparser.py", line 24, in parse from bllipparser.ModelFetcher import download_and_install_model File "/root/autodl-tmp/CLEVE-main/camr/bllipparser/init.py", line 400, in from .RerankingParser import RerankingParser, Tree, Sentence, tokenize File "/root/autodl-tmp/CLEVE-main/camr/bllipparser/RerankingParser.py", line 21, in from . import CharniakParser as parser ImportError: cannot import name CharniakParser 2、The problem appears in the RerankingParser.py,the head file in it is under followed.it cannot find CharniakParser in RerankingParser.py,note that the tips “Higher-level python frontend to the BLLIP reranking parser. Wraps the lower-level (SWIG-generated) CharniakParser and JohnsonReranker modules so you don't need to interact with them directly”,but the question is that when i want to use the CharniakParser,how can i call(import) it? import sys sys.path.append("..") from os.path import exists, join from six import string_types from . import CharniakParser as parser from . import JohnsonReranker as reranker from .Utility import cleanup_input_token, normalize_logprobs

dmcc commented 1 year ago

Thanks for the information! From your stack trace, it looks like you're running BLLIP Parser from CAMR which has a script to install BLLIP Parser.

Have you run that script? What happens when you run pip install --user bllipparser?

The answer to question 4 would be helpful for debugging (as you may also need to install things like swig and flex, the setup of which would depend on your OS/distribution).