How can I run the "camel_parser" library?

28 Views Asked by At

I used Goolge colab to install and run the library "Camel Parser" .

I used the following codes to install the library:

!git clone https://github.com/CAMeL-Lab/camel_parser.git 
!pip install -r camel_parser/requirements.txt 
%cd camel_parser 
!python download_models.py

I used this code to parse a sentence:

! python text_to_conll_cli.py -f text -b r13 -d bert -m catib -t catib6 -s "جامعة نيويورك أبو ظبي تنشر أول أطلس لكوكب المريخ باللغة العربية."

I got the following error message:

> [2024-02-21 06:06:55 ERROR] Exception raised in get_disambiguator. exception: [Errno 2] No such file or directory: '/root/.camel_tools/data/morphology_db/calima-msa-r13/morphology.db'
Traceback (most recent call last):
  File "/content/camel_parser/src/logger.py", line 32, in wrapper
    result = func(*args, **kwargs)
  File "/content/camel_parser/src/initialize_disambiguator/disambiguator_interface.py", line 19, in get_disambiguator
    analyzer = set_up_analyzer(morphology_db)
  File "/content/camel_parser/src/initialize_disambiguator/disambiguator_interface.py", line 14, in set_up_analyzer
    db = MorphologyDB.builtin_db(db_name=db_type)
  File "/usr/local/lib/python3.10/dist-packages/camel_tools/morphology/database.py", line 95, in builtin_db
    return MorphologyDB(str(Path(db_info.path, 'morphology.db')), flags)
  File "/usr/local/lib/python3.10/dist-packages/camel_tools/morphology/database.py", line 146, in __init__
    self._parse_dbfile(fpath)
  File "/usr/local/lib/python3.10/dist-packages/camel_tools/morphology/database.py", line 185, in _parse_dbfile
    with open(fpath, 'r', encoding='utf-8') as dbfile:
FileNotFoundError: [Errno 2] No such file or directory: '/root/.camel_tools/data/morphology_db/calima-msa-r13/morphology.db'
Traceback (most recent call last):
  File "/content/camel_parser/text_to_conll_cli.py", line 110, in <module>
    main()
  File "/content/camel_parser/text_to_conll_cli.py", line 104, in main
    parsed_text_tuples = parse_text(file_type, file_type_params)
  File "/content/camel_parser/src/data_preparation.py", line 162, in parse_text
    text_tuples = handle_text(file_type_params)
  File "/content/camel_parser/src/data_preparation.py", line 118, in handle_text
    disambiguator = get_disambiguator(disambiguator_param, morphology_db_type)
  File "/content/camel_parser/src/logger.py", line 40, in wrapper
    raise e
  File "/content/camel_parser/src/logger.py", line 32, in wrapper
    result = func(*args, **kwargs)
  File "/content/camel_parser/src/initialize_disambiguator/disambiguator_interface.py", line 19, in get_disambiguator
    analyzer = set_up_analyzer(morphology_db)
  File "/content/camel_parser/src/initialize_disambiguator/disambiguator_interface.py", line 14, in set_up_analyzer
    db = MorphologyDB.builtin_db(db_name=db_type)
  File "/usr/local/lib/python3.10/dist-packages/camel_tools/morphology/database.py", line 95, in builtin_db
    return MorphologyDB(str(Path(db_info.path, 'morphology.db')), flags)
  File "/usr/local/lib/python3.10/dist-packages/camel_tools/morphology/database.py", line 146, in __init__
    self._parse_dbfile(fpath)
  File "/usr/local/lib/python3.10/dist-packages/camel_tools/morphology/database.py", line 185, in _parse_dbfile
    with open(fpath, 'r', encoding='utf-8') as dbfile:
FileNotFoundError: [Errno 2] No such file or directory: '/root/.camel_tools/data/morphology_db/calima-msa-r13/morphology.db'

How can this be solved? I asked chatGPT for solutions but nothing worked. I'm new to Python and your response would be much appreciated!

====================================================

UPDATE

This error was solved by installing the morphology database as stated in the documentation of the library, with the following code:

!camel_data -i morphology-db-msa-s31
!camel_data -i disambig-bert-unfactored-msa
0

There are 0 best solutions below