Skip to content

UnboundLocalError: local variable 'rule_dir' referenced before assignment

Sur le notebook suivant : https://unsel.tetras-lab.io/jupyter/lab/tree/dashboards/TetrasMARS/tetras-mars-demo/selfContainedDemo.ipynb

après avoir lancé :

factoids = tenet.create_ontology_from_amrld_file(amrTtlPath,
    onto_prefix="https://tenet.tetras-libre.fr/demo/",
    out_file_path=uuidDirPath+"factoid.ttl",
    technical_dir_path=uuidDirPath)

J'ai l'erreur ci dessous :

[TENET] Extraction Processing

 === Process Initialization === 
-- Process Setting 
----- Corpus source: /opt/dashboards/TetrasMARS/tetras-mars-demo/tmp/dd3d9ffa-3b04-45c6-a7df-d0ef3e7a6ad9/file.amr.ttl (amr)
----- Base output dir: /opt/dashboards/TetrasMARS/tetras-mars-demo/tmp/dd3d9ffa-3b04-45c6-a7df-d0ef3e7a6ad9/factoid.ttl
----- technical dir path: /opt/dashboards/TetrasMARS/tetras-mars-demo/tmp/dd3d9ffa-3b04-45c6-a7df-d0ef3e7a6ad9/
----- Ontology target (id): https://tenet.tetras-libre.fr/demo/
----- Current path: /opt/dashboards/TetrasMARS/tenet

 === Extraction Processing === 
-- Work Structure Preparation
2023-02-19 18:12:51,807 - ERROR (extraction.structure, 193)
!!! An exception occurred !!!
-- Loading Extraction Scheme (amr_scheme_1)
2023-02-19 18:12:51,810 - ERROR (extraction.process, 44)
 *** Error while loading scheme (load_cts) ***
2023-02-19 18:12:51,812 - ERROR (extraction.process, 425)
 *** Error while processing extraction (apply) ***

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File /opt/dashboards/TetrasMARS/tenet/tenet/extraction/process.py:391, in apply(config, graph)
    390 logger.info("-- Loading Extraction Scheme ({0})".format(config.cts_ref))
--> 391 rule_dir, prefix_list, scheme = load_cts(config)
    392 logger.debug("----- Step number: {0}".format(len(scheme)))

TypeError: cannot unpack non-iterable NoneType object

During handling of the above exception, another exception occurred:

UnboundLocalError                         Traceback (most recent call last)
Input In [10], in <cell line: 1>()
----> 1 factoids = tenet.create_ontology_from_amrld_file(amrTtlPath,
      2 onto_prefix="https://tenet.tetras-libre.fr/demo/",
      3 out_file_path=uuidDirPath+"factoid.ttl",
      4 technical_dir_path=uuidDirPath)

File /opt/dashboards/TetrasMARS/tenet/tenet/utility/timer.py:40, in timed.<locals>.wrapper(*args, **kwargs)
     37 exec_start = time.perf_counter()
     38 process_start = time.process_time()
---> 40 result = func(*args, **kwargs)
     42 exec_end = time.perf_counter()
     43 process_end = time.process_time()

File /opt/dashboards/TetrasMARS/tenet/tenet/main.py:138, in create_ontology_from_amrld_file(amrld_file_path, base_ontology_path, onto_prefix, out_file_path, technical_dir_path)
    136 logger.info('\n === Extraction Processing === ')
    137 config.sentence_output_dir = f'-0'
--> 138 result_triple_list = __apply_extraction(config, amrld_file_path)
    140 # -- Final Ontology Generation (factoid_graph)
    141 logger.info('\n === Final Ontology Generation  === ') 

File /opt/dashboards/TetrasMARS/tenet/tenet/main.py:69, in __apply_extraction(config, sentence_file)
     67 os.makedirs(config.sentence_output_dir, exist_ok=True)
     68 work_graph = structure.prepare_sentence_work(config, sentence_file)
---> 69 _, new_triple_list = process.apply(config, work_graph)
     70 return new_triple_list

File /opt/dashboards/TetrasMARS/tenet/tenet/extraction/process.py:427, in apply(config, graph)
    425 logger.error(' *** Error while processing extraction (apply) ***') 
    426 logger.debug(f' ----- config.cts_ref = {config.cts_ref}')  
--> 427 logger.debug(f' ----- rule_dir = {rule_dir}')  
    428 logger.debug(f' ----- scheme = {scheme}')      
    429 logger.debug(f' ----- step = {step_name}, {step_sequence_def}')

UnboundLocalError: local variable 'rule_dir' referenced before assignment