From a3a49ac0712ee814d2cc929e1e67e39be8687051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Lamercerie?= <aurelien.lamercerie@tetras-libre.fr> Date: Fri, 3 Mar 2023 18:17:05 +0100 Subject: [PATCH] Add class WorkData --- amrbatch/amrld/wk/test-01.stog.amr.nt | 22 --- amrbatch/amrld/wk/test-01.stog.amr.penman | 4 - amrbatch/amrld/wk/test-02.stog.amr.nt | 19 --- amrbatch/amrld/wk/test-02.stog.amr.penman | 6 - amrbatch/filepath_manager.py | 60 -------- amrbatch/main.py | 128 ++++++------------ amrbatch/work_data.py | 105 ++++++++++++++ tests/amrbatch.log | 79 +++++------ tests/output/SSC-ABSTRACT-01.sentence.txt | 10 -- tests/output/SSC-ABSTRACT-02.sentence.txt | 10 -- tests/output/SSC-ABSTRACT-03.sentence.txt | 3 - .../Test-20230303/SSC-ABSTRACT.sentence.txt | 23 ---- .../Test-20230303/test-01/test-01.stog.amr.nt | 24 ++-- .../test-01/test-01.stog.amr.ttl | 32 ++--- .../Test-20230303/test-02/test-02.stog.amr.nt | 20 +-- tests/output/test-1.sentence.txt | 2 - tests/test_amrbatch_main.py | 2 +- 17 files changed, 216 insertions(+), 333 deletions(-) delete mode 100644 amrbatch/amrld/wk/test-01.stog.amr.nt delete mode 100644 amrbatch/amrld/wk/test-01.stog.amr.penman delete mode 100644 amrbatch/amrld/wk/test-02.stog.amr.nt delete mode 100644 amrbatch/amrld/wk/test-02.stog.amr.penman create mode 100644 amrbatch/work_data.py delete mode 100644 tests/output/SSC-ABSTRACT-01.sentence.txt delete mode 100644 tests/output/SSC-ABSTRACT-02.sentence.txt delete mode 100644 tests/output/SSC-ABSTRACT-03.sentence.txt delete mode 100644 tests/output/Test-20230303/SSC-ABSTRACT.sentence.txt delete mode 100644 tests/output/test-1.sentence.txt diff --git a/amrbatch/amrld/wk/test-01.stog.amr.nt b/amrbatch/amrld/wk/test-01.stog.amr.nt deleted file mode 100644 index c3de20a5..00000000 --- a/amrbatch/amrld/wk/test-01.stog.amr.nt +++ /dev/null @@ -1,22 +0,0 @@ -<http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Role> . -<http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . -<http://amr.isi.edu/amr_data/test-01#root01> <http://amr.isi.edu/rdf/core-amr#root> <http://amr.isi.edu/amr_data/test-01#s> . -<http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> . -<http://amr.isi.edu/amr_data/test-01#s> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/entity-types#star> . -<http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-PropBank-Frame" . -<http://amr.isi.edu/amr_data/test-01#s> <http://amr.isi.edu/rdf/amr-terms#domain> <http://amr.isi.edu/amr_data/test-01#s2> . -<http://amr.isi.edu/amr_data/test-01#s2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/amr-terms#sun> . -<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Term" . -<http://amr.isi.edu/amr_data/test-01#root01> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#AMR> . -<http://amr.isi.edu/rdf/amr-terms#domain> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Role> . -<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Concept" . -<http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Role" . -<http://amr.isi.edu/rdf/amr-terms#sun> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> . -<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-EntityType" . -<http://amr.isi.edu/amr_data/test-01#root01> <http://amr.isi.edu/rdf/core-amr#has-id> "test-01" . -<http://amr.isi.edu/amr_data/test-01#root01> <http://amr.isi.edu/rdf/core-amr#has-sentence> "The sun is a star." . -<http://amr.isi.edu/entity-types#star> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#NamedEntity> . -<http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-PropBank-Role" . -<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . -<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> . - diff --git a/amrbatch/amrld/wk/test-01.stog.amr.penman b/amrbatch/amrld/wk/test-01.stog.amr.penman deleted file mode 100644 index 4f70746d..00000000 --- a/amrbatch/amrld/wk/test-01.stog.amr.penman +++ /dev/null @@ -1,4 +0,0 @@ -# ::id test-01 -# ::snt The sun is a star. -(s / star - :domain (s2 / sun)) \ No newline at end of file diff --git a/amrbatch/amrld/wk/test-02.stog.amr.nt b/amrbatch/amrld/wk/test-02.stog.amr.nt deleted file mode 100644 index d51b316c..00000000 --- a/amrbatch/amrld/wk/test-02.stog.amr.nt +++ /dev/null @@ -1,19 +0,0 @@ -<http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> . -<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> . -<http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Role" . -<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-EntityType" . -<http://amr.isi.edu/amr_data/test-02#root01> <http://amr.isi.edu/rdf/core-amr#has-sentence> "Earth is a planet." . -<http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Role> . -<http://amr.isi.edu/amr_data/test-02#p> <http://www.w3.org/2000/01/rdf-schema#label> "Earth" . -<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Concept" . -<http://amr.isi.edu/amr_data/test-02#p> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/entity-types#planet> . -<http://amr.isi.edu/entity-types#planet> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#NamedEntity> . -<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . -<http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-PropBank-Frame" . -<http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-PropBank-Role" . -<http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . -<http://amr.isi.edu/amr_data/test-02#root01> <http://amr.isi.edu/rdf/core-amr#root> <http://amr.isi.edu/amr_data/test-02#p> . -<http://amr.isi.edu/amr_data/test-02#root01> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#AMR> . -<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Term" . -<http://amr.isi.edu/amr_data/test-02#root01> <http://amr.isi.edu/rdf/core-amr#has-id> "test-02" . - diff --git a/amrbatch/amrld/wk/test-02.stog.amr.penman b/amrbatch/amrld/wk/test-02.stog.amr.penman deleted file mode 100644 index c43f2d1e..00000000 --- a/amrbatch/amrld/wk/test-02.stog.amr.penman +++ /dev/null @@ -1,6 +0,0 @@ -# ::id test-02 -# ::snt Earth is a planet. -(p / planet - :domain p - :name (n / name - :op1 "Earth")) \ No newline at end of file diff --git a/amrbatch/filepath_manager.py b/amrbatch/filepath_manager.py index 4075cff5..f40b348e 100644 --- a/amrbatch/filepath_manager.py +++ b/amrbatch/filepath_manager.py @@ -11,19 +11,7 @@ import sys, os, glob import shutil # Reference Suffix -TEXT_SUFFIX = ".txt" SENTENCE_SUFFIX = ".sentence.txt" -PENMAN_AMR_GRAPH_SUFFIX = ".stog.amr.penman" -DOT_AMR_GRAPH_SUFFIX = ".stog.amr.dot" -PNG_AMR_GRAPH_SUFFIX = ".stog.amr.png" -AMR_RDF_SUFFIX = ".stog.amr.nt" -AMR_TTL_SUFFIX = ".stog.amr.ttl" - -# AMRLD Parameters -LIB_PATH = os.path.dirname(os.path.abspath(__file__)) + '/' -AMRLD_DIR = f'{LIB_PATH}amrld/' -WK_DIR = 'wk/' -AMRLD_WORKDIR = AMRLD_DIR + WK_DIR #============================================================================== @@ -61,52 +49,4 @@ class FilepathManager: def get_sentence_output_filepath(self): return f'{self.output_dirpath}{self.base_reference}{SENTENCE_SUFFIX}' - def get_data_output_filepath(self, data): - return f'{self.output_dirpath}{data["output_data_dir"]}' - - def get_penman_amr_graph_output_filepath(self, data): - dirpath = self.get_data_output_filepath(data) - filename = f'{data["data_ref"]}{PENMAN_AMR_GRAPH_SUFFIX}' - return f'{dirpath}{filename}' - - def get_dot_amr_graph_output_filepath(self, data): - dirpath = self.get_data_output_filepath(data) - filename = f'{data["data_ref"]}{DOT_AMR_GRAPH_SUFFIX}' - return f'{dirpath}{filename}' - - def get_png_amr_graph_output_filepath(self, data): - dirpath = self.get_data_output_filepath(data) - filename = f'{data["data_ref"]}{PNG_AMR_GRAPH_SUFFIX}' - return f'{dirpath}{filename}' - - def get_amr_rdf_triple_output_filepath(self, data): - dirpath = self.get_data_output_filepath(data) - filename = f'{data["data_ref"]}{AMR_RDF_SUFFIX}' - return f'{dirpath}{filename}' - - def get_amr_rdf_turtle_output_filepath(self, data): - dirpath = self.get_data_output_filepath(data) - filename = f'{data["data_ref"]}{AMR_TTL_SUFFIX}' - return f'{dirpath}{filename}' - - def get_amr_graph_amrld_filepath(self, data): - dirpath = f'{AMRLD_WORKDIR}' - filename = f'{data["data_ref"]}{PENMAN_AMR_GRAPH_SUFFIX}' - return f'{dirpath}{filename}' - - def get_amr_rdf_amrld_filepath(self, data): - dirpath = f'{AMRLD_WORKDIR}' - filename = f'{data["data_ref"]}{AMR_RDF_SUFFIX}' - return f'{dirpath}{filename}' - - def get_amr_graph_wk_filepath(self, data): - dirpath = f'{WK_DIR}' - filename = f'{data["data_ref"]}{PENMAN_AMR_GRAPH_SUFFIX}' - return f'{dirpath}{filename}' - - def get_amr_rdf_wk_filepath(self, data): - dirpath = f'{WK_DIR}' - filename = f'{data["data_ref"]}{AMR_RDF_SUFFIX}' - return f'{dirpath}{filename}' - diff --git a/amrbatch/main.py b/amrbatch/main.py index 0e665a7c..a933ae0d 100644 --- a/amrbatch/main.py +++ b/amrbatch/main.py @@ -17,6 +17,7 @@ import logging.config from amrlib.graph_processing.amr_plot import AMRPlot from filepath_manager import FilepathManager +from work_data import WorkData # -- Config File Path LIB_PATH = os.path.dirname(os.path.abspath(__file__)) + '/' @@ -31,13 +32,13 @@ AMRLD_WORKDIR = f'{AMRLD_DIR}wk/' logging.config.fileConfig(LOGGING_CONF_FILE_PATH, disable_existing_loggers=True) logger = logging.getLogger('root') - - + + #============================================================================== -# Functions to manage in-process data +# Preparation Steps #============================================================================== -def is_valid_sentence(sentence): +def __is_valid_sentence(sentence): """ True if the sentence is correct. """ is_empty = ((sentence == "") | (sentence == "\n")) @@ -46,45 +47,6 @@ def is_valid_sentence(sentence): return not (is_empty | is_language_mark) -def clean_sentence(sentence): - """ Sentence cleanup as needed """ - sentence = re.sub("(\.)*\\n", "", sentence) - return sentence - - -def define_new_data(base_ref, number, sentence): - - number_str = str(number).rjust(2,"0") - data_ref = base_ref + "-" + number_str - output_data_dir = data_ref + "/" - id_line_str = "# ::id " + data_ref + "\n" - sentence = clean_sentence(sentence) - sentence += "." - - new_data = { - "base_ref" : data_ref, - "number" : number, - "output_data_dir" : output_data_dir, - "data_ref" : data_ref, - "id_line_str" : id_line_str, - "sentence" : sentence, - "graph" : "" - } - - return new_data - - -def get_amr_graph_list(workdata_list): - amr_graph_list = [] - for workdata in workdata_list: - amr_graph_list.append(workdata['graph']) - return amr_graph_list - - -#============================================================================== -# Preparation Steps -#============================================================================== - def __prepare_workdata(filepath_manager): logger.info('-- Reading input files to recover a list of sentences') input_filepath = filepath_manager.input_filepath @@ -97,9 +59,9 @@ def __prepare_workdata(filepath_manager): for line in reading_file.readlines(): sentences = line.split(". ") for sentence in sentences: - if is_valid_sentence(sentence): + if __is_valid_sentence(sentence): sentence_number += 1 - new_data = define_new_data(base_reference, sentence_number, sentence) + new_data = WorkData(sentence, sentence_number, filepath_manager) workdata_list.append(new_data) logger.debug(f' *** sentence {sentence_number} *** \n{new_data}') @@ -112,7 +74,7 @@ def __build_output_dir_tree(filepath_manager, workdata_list): logger.debug(f'-- Making output directory tree ({base_output_dirpath})') os.makedirs(base_output_dirpath, exist_ok=True) for data in workdata_list: - output_dir = filepath_manager.get_workdata_output_dirpath(data["output_data_dir"]) + output_dir = data.output_dirpath os.makedirs(output_dir, exist_ok=True) @@ -123,11 +85,10 @@ def __generate_sentence_file(filepath_manager, workdata_list): first = True for workdata in workdata_list: if not first: writing_file.write("\n") - writing_file.write(workdata["sentence"]) + writing_file.write(workdata.sentence) first = False - #============================================================================== # Conversion Steps @@ -135,40 +96,34 @@ def __generate_sentence_file(filepath_manager, workdata_list): def __generate_penman_amr_graph(filepath_manager, data): """ AMR graph generation in penman format """ - - graph = data["graph"] - output_filepath = filepath_manager.get_penman_amr_graph_output_filepath(data) + + output_filepath = data.get_penman_amr_graph_output_filepath() logger.debug(f"----- AMR Graph file (penman): {os.path.basename(output_filepath)}") with open(output_filepath, "w") as writing_file: # w = write - writing_file.write(data["id_line_str"]) - writing_file.write(graph) - + writing_file.write(data.id_line_str) + writing_file.write(data.graph) def __generate_dot_amr_graph(filepath_manager, data): """ AMR graph generation in dot and png format """ - - graph = data["graph"] - + try: # -- generating dot/png files using AMRLib and GraphViz - dot_filename = filepath_manager.get_dot_amr_graph_output_filepath(data) + dot_filename = data.get_dot_amr_graph_output_filepath() format = 'png' logger.debug(f'----- AMR Graph file (dot): {os.path.basename(dot_filename)}') plot = AMRPlot(dot_filename, format) - plot.build_from_graph(graph) + plot.build_from_graph(data.graph) plot.graph.render() render_fn = dot_filename + '.' + format # -- renaming PNG file - good_png_fn = filepath_manager.get_png_amr_graph_output_filepath(data) + good_png_fn = data.get_png_amr_graph_output_filepath() logger.debug(f'----- AMR Graph file (png): {{os.path.basename(good_png_fn)}}') os.rename(render_fn, good_png_fn) except: logger.warning('Exception when trying to plot') traceback.print_exc() - - def __convert_sentences_to_graphs(amr_model, workdata_list): @@ -181,15 +136,14 @@ def __convert_sentences_to_graphs(amr_model, workdata_list): wd_number = 0 for data in workdata_list: wd_number += 1 - stog_result = stog.parse_sents([data["sentence"]]) + stog_result = stog.parse_sents([data.sentence]) logger.info(f'----- Sentence {wd_number} successfully processed') logger.debug(stog_result) - data["graph"] = stog_result[0] + data.graph = stog_result[0] logger.info(f'----- Total processed graph number: {wd_number}') return workdata_list - def __generate_amr_graph_files(filepath_manager, workdata_list): logger.info("-- Generating AMR graph files") @@ -206,13 +160,14 @@ def __generate_amr_graph_files(filepath_manager, workdata_list): def __serialize_amr_graph_to_rdf_triple(filepath_manager, data): """ Serialize AMR graph to AMR-RDF triple """ - # -- Filepath - input_file = filepath_manager.get_penman_amr_graph_output_filepath(data) - input_amrld_file = filepath_manager.get_amr_graph_amrld_filepath(data) - output_amrld_file = filepath_manager.get_amr_rdf_amrld_filepath(data) - input_wk_file = filepath_manager.get_amr_graph_wk_filepath(data) - output_wk_file = filepath_manager.get_amr_rdf_wk_filepath(data) - amr_triple_file = filepath_manager.get_amr_rdf_triple_output_filepath(data) + # -- Filepath + input_file = data.get_penman_amr_graph_output_filepath() + input_amrld_file = data.get_amr_graph_amrld_filepath() + output_amrld_file = data.get_amr_rdf_amrld_filepath() + input_wk_file = data.get_amr_graph_wk_filepath() + output_wk_file = data.get_amr_rdf_wk_filepath() + amr_triple_file = data.get_amr_rdf_triple_output_filepath() + amr_turtle_file = data.get_amr_rdf_turtle_output_filepath() # -- AMR-LD processing amrld_process = ["python3", "amr_to_rdf.py", @@ -228,7 +183,7 @@ def __serialize_amr_graph_to_rdf_triple(filepath_manager, data): subprocess.run(amrld_process) os.chdir(current_dirpath) - # -- Copy result + # -- File Generation (AMR-RDF triple) if (os.path.isfile(output_amrld_file)): logger.info(f'-- Generating AMR RDF file (triple): {os.path.basename(amr_triple_file)}') shutil.copyfile(output_amrld_file, amr_triple_file) @@ -238,8 +193,8 @@ def __convert_rdf_triple_to_rdf_turtle(filepath_manager, data): """ Converting AMR-RDF triple to AMR-RDF turtle """ # -- Filepath - amr_triple_file = filepath_manager.get_amr_rdf_triple_output_filepath(data) - amr_turtle_file = filepath_manager.get_amr_rdf_turtle_output_filepath(data) + amr_triple_file = data.get_amr_rdf_triple_output_filepath() + amr_turtle_file = data.get_amr_rdf_turtle_output_filepath() # -- Conversion if (os.path.isfile(amr_triple_file)): @@ -247,16 +202,7 @@ def __convert_rdf_triple_to_rdf_turtle(filepath_manager, data): g = Graph() g.parse(amr_triple_file) g.serialize(destination=amr_turtle_file, format='turtle') - - - -def __convert_amr_graphs_to_rdf(filepath_manager, data_list): - """ Converting AMR graphs to AMR-RDF """ - - for data in data_list: - __serialize_amr_graph_to_rdf_triple(filepath_manager, data) - __convert_rdf_triple_to_rdf_turtle(filepath_manager, data) - + #============================================================================== @@ -313,8 +259,14 @@ def parse_document_file_to_produce_amr_graph( # -- Convert graphs to RDF logger.info('\n === AMR Graphs Serialization to AMR-RDF Representation === ') logger.info("-- library: amrlk") - __convert_amr_graphs_to_rdf(filepath_manager, workdata_list) + for data in workdata_list: + __serialize_amr_graph_to_rdf_triple(filepath_manager, data) + __convert_rdf_triple_to_rdf_turtle(filepath_manager, data) - - return get_amr_graph_list(workdata_list) + # -- Getting AMR graph list + amr_graph_list = [] + for workdata in workdata_list: + if workdata.graph != "": amr_graph_list.append(workdata.graph) + + return amr_graph_list diff --git a/amrbatch/work_data.py b/amrbatch/work_data.py new file mode 100644 index 00000000..724a49b3 --- /dev/null +++ b/amrbatch/work_data.py @@ -0,0 +1,105 @@ +#============================================================================== +# AMR Batch: WorkData +#------------------------------------------------------------------------------ +# Class to handle amrbatch work data +#============================================================================== + +import sys, os, glob +import shutil, re +import subprocess +import amrlib +from rdflib import Graph +import traceback +import logging.config + +from amrlib.graph_processing.amr_plot import AMRPlot +from filepath_manager import FilepathManager + +# Reference Suffix +TEXT_SUFFIX = ".txt" +SENTENCE_SUFFIX = ".sentence.txt" +PENMAN_AMR_GRAPH_SUFFIX = ".stog.amr.penman" +DOT_AMR_GRAPH_SUFFIX = ".stog.amr.dot" +PNG_AMR_GRAPH_SUFFIX = ".stog.amr.png" +AMR_RDF_SUFFIX = ".stog.amr.nt" +AMR_TTL_SUFFIX = ".stog.amr.ttl" + +# AMRLD Parameters +LIB_PATH = os.path.dirname(os.path.abspath(__file__)) + '/' +AMRLD_DIR = f'{LIB_PATH}amrld/' +WK_DIR = 'wk/' +AMRLD_WORKDIR = AMRLD_DIR + WK_DIR + + + +#============================================================================== +# Class +#============================================================================== + +class WorkData: + """ Class to handle AMR-Batch work data. + """ + + #-------------------------------------------------------------------------- + # Constructor + #-------------------------------------------------------------------------- + + def __init__(self, sentence, number, filepath_manager): + + # -- Reference + number_str = str(number).rjust(2,"0") + self.reference = f'{filepath_manager.base_reference}-{number_str}' + self.number = number + + # -- Sentence + self.id_line_str = f'# ::id {self.reference}\n' + clean_sentence = re.sub("(\.)*\\n", "", sentence) + self.sentence = f'{clean_sentence}.' + + # -- Graph + self.graph = '' + + # -- Output dirpath + self.output_dirpath = f'{filepath_manager.output_dirpath}{self.reference}/' + + + + #-------------------------------------------------------------------------- + # Path Accessors + #-------------------------------------------------------------------------- + + def get_penman_amr_graph_output_filepath(self): + suffix = PENMAN_AMR_GRAPH_SUFFIX + return f'{self.output_dirpath}{self.reference}{suffix}' + + def get_dot_amr_graph_output_filepath(self): + suffix = DOT_AMR_GRAPH_SUFFIX + return f'{self.output_dirpath}{self.reference}{suffix}' + + def get_png_amr_graph_output_filepath(self): + suffix = PNG_AMR_GRAPH_SUFFIX + return f'{self.output_dirpath}{self.reference}{suffix}' + + def get_amr_rdf_triple_output_filepath(self): + suffix = AMR_RDF_SUFFIX + return f'{self.output_dirpath}{self.reference}{suffix}' + + def get_amr_rdf_turtle_output_filepath(self): + suffix = AMR_TTL_SUFFIX + return f'{self.output_dirpath}{self.reference}{suffix}' + + def get_amr_graph_amrld_filepath(self): + suffix = PENMAN_AMR_GRAPH_SUFFIX + return f'{AMRLD_WORKDIR}{self.reference}{suffix}' + + def get_amr_rdf_amrld_filepath(self): + suffix = AMR_RDF_SUFFIX + return f'{AMRLD_WORKDIR}{self.reference}{suffix}' + + def get_amr_graph_wk_filepath(self): + suffix = PENMAN_AMR_GRAPH_SUFFIX + return f'{WK_DIR}{self.reference}{suffix}' + + def get_amr_rdf_wk_filepath(self): + suffix = AMR_RDF_SUFFIX + return f'{WK_DIR}{self.reference}{suffix}' \ No newline at end of file diff --git a/tests/amrbatch.log b/tests/amrbatch.log index 351bd692..8adfc5ce 100644 --- a/tests/amrbatch.log +++ b/tests/amrbatch.log @@ -1,57 +1,15 @@ - INFO - [AMR Batch] NL Document Parsing - INFO - === Preparation === -- INFO - -- base reference: SSC-ABSTRACT -- INFO - -- input filepath: /home/lamenji/Workspace/Tetras/amrbatch/tests/input/SSC-ABSTRACT.txt +- INFO - -- base reference: test +- INFO - -- input filepath: /home/lamenji/Workspace/Tetras/amrbatch/tests/input/test.txt - INFO - -- output dirpath: /home/lamenji/Workspace/Tetras/amrbatch/tests/output/Test-20230303/ - INFO - -- Reading input files to recover a list of sentences - DEBUG - *** sentence 1 *** -{'base_ref': 'SSC-ABSTRACT-01', 'number': 1, 'output_data_dir': 'SSC-ABSTRACT-01/', 'data_ref': 'SSC-ABSTRACT-01', 'id_line_str': '# ::id SSC-ABSTRACT-01\n', 'sentence': 'The Solar System is the gravitationally bound system of the Sun and the objects that orbit it, either directly or indirectly.', 'graph': ''} +<work_data.WorkData object at 0x7fa71e5702b0> - DEBUG - *** sentence 2 *** -{'base_ref': 'SSC-ABSTRACT-02', 'number': 2, 'output_data_dir': 'SSC-ABSTRACT-02/', 'data_ref': 'SSC-ABSTRACT-02', 'id_line_str': '# ::id SSC-ABSTRACT-02\n', 'sentence': 'Of the objects that orbit the Sun directly, the largest are the eight planets, with the remainder being smaller objects, the dwarf planets and small Solar System bodies.', 'graph': ''} -- DEBUG - *** sentence 3 *** -{'base_ref': 'SSC-ABSTRACT-03', 'number': 3, 'output_data_dir': 'SSC-ABSTRACT-03/', 'data_ref': 'SSC-ABSTRACT-03', 'id_line_str': '# ::id SSC-ABSTRACT-03\n', 'sentence': 'Of the objects that orbit the Sun indirectly—the natural satellites—two are larger than the smallest planet, Mercury, and one more almost equals it in size.', 'graph': ''} -- DEBUG - *** sentence 4 *** -{'base_ref': 'SSC-ABSTRACT-04', 'number': 4, 'output_data_dir': 'SSC-ABSTRACT-04/', 'data_ref': 'SSC-ABSTRACT-04', 'id_line_str': '# ::id SSC-ABSTRACT-04\n', 'sentence': 'The Solar System formed 4.6 billion years ago from the gravitational collapse of a giant interstellar molecular cloud.', 'graph': ''} -- DEBUG - *** sentence 5 *** -{'base_ref': 'SSC-ABSTRACT-05', 'number': 5, 'output_data_dir': 'SSC-ABSTRACT-05/', 'data_ref': 'SSC-ABSTRACT-05', 'id_line_str': '# ::id SSC-ABSTRACT-05\n', 'sentence': "The vast majority of the system's mass is in the Sun, with the majority of the remaining mass contained in Jupiter.", 'graph': ''} -- DEBUG - *** sentence 6 *** -{'base_ref': 'SSC-ABSTRACT-06', 'number': 6, 'output_data_dir': 'SSC-ABSTRACT-06/', 'data_ref': 'SSC-ABSTRACT-06', 'id_line_str': '# ::id SSC-ABSTRACT-06\n', 'sentence': 'The four smaller inner system planets, Mercury, Venus, Earth and Mars, are terrestrial planets, being primarily composed of rock and metal.', 'graph': ''} -- DEBUG - *** sentence 7 *** -{'base_ref': 'SSC-ABSTRACT-07', 'number': 7, 'output_data_dir': 'SSC-ABSTRACT-07/', 'data_ref': 'SSC-ABSTRACT-07', 'id_line_str': '# ::id SSC-ABSTRACT-07\n', 'sentence': 'The four outer system planets are giant planets, being substantially more massive than the terrestrials.', 'graph': ''} -- DEBUG - *** sentence 8 *** -{'base_ref': 'SSC-ABSTRACT-08', 'number': 8, 'output_data_dir': 'SSC-ABSTRACT-08/', 'data_ref': 'SSC-ABSTRACT-08', 'id_line_str': '# ::id SSC-ABSTRACT-08\n', 'sentence': 'The two largest planets, Jupiter and Saturn, are gas giants, being composed mainly of hydrogen and helium; the two outermost planets, Uranus and Neptune, are ice giants, being composed mostly of substances with relatively high melting points compared with hydrogen and helium, called volatiles, such as water, ammonia and methane.', 'graph': ''} -- DEBUG - *** sentence 9 *** -{'base_ref': 'SSC-ABSTRACT-09', 'number': 9, 'output_data_dir': 'SSC-ABSTRACT-09/', 'data_ref': 'SSC-ABSTRACT-09', 'id_line_str': '# ::id SSC-ABSTRACT-09\n', 'sentence': 'All eight planets have almost circular orbits that lie within a nearly flat disc called the ecliptic.', 'graph': ''} -- DEBUG - *** sentence 10 *** -{'base_ref': 'SSC-ABSTRACT-10', 'number': 10, 'output_data_dir': 'SSC-ABSTRACT-10/', 'data_ref': 'SSC-ABSTRACT-10', 'id_line_str': '# ::id SSC-ABSTRACT-10\n', 'sentence': 'The Solar System also contains smaller objects.', 'graph': ''} -- DEBUG - *** sentence 11 *** -{'base_ref': 'SSC-ABSTRACT-11', 'number': 11, 'output_data_dir': 'SSC-ABSTRACT-11/', 'data_ref': 'SSC-ABSTRACT-11', 'id_line_str': '# ::id SSC-ABSTRACT-11\n', 'sentence': 'The asteroid belt, which lies between the orbits of Mars and Jupiter, mostly contains objects composed, like the terrestrial planets, of rock and metal.', 'graph': ''} -- DEBUG - *** sentence 12 *** -{'base_ref': 'SSC-ABSTRACT-12', 'number': 12, 'output_data_dir': 'SSC-ABSTRACT-12/', 'data_ref': 'SSC-ABSTRACT-12', 'id_line_str': '# ::id SSC-ABSTRACT-12\n', 'sentence': "Beyond Neptune's orbit lie the Kuiper belt and scattered disc, which are populations of trans-Neptunian objects composed mostly of ices, and beyond them a newly discovered population of sednoids.", 'graph': ''} -- DEBUG - *** sentence 13 *** -{'base_ref': 'SSC-ABSTRACT-13', 'number': 13, 'output_data_dir': 'SSC-ABSTRACT-13/', 'data_ref': 'SSC-ABSTRACT-13', 'id_line_str': '# ::id SSC-ABSTRACT-13\n', 'sentence': 'Within these populations, some objects are large enough to have rounded under their own gravity, though there is considerable debate as to how many there will prove to be.', 'graph': ''} -- DEBUG - *** sentence 14 *** -{'base_ref': 'SSC-ABSTRACT-14', 'number': 14, 'output_data_dir': 'SSC-ABSTRACT-14/', 'data_ref': 'SSC-ABSTRACT-14', 'id_line_str': '# ::id SSC-ABSTRACT-14\n', 'sentence': 'Such objects are categorized as dwarf planets.', 'graph': ''} -- DEBUG - *** sentence 15 *** -{'base_ref': 'SSC-ABSTRACT-15', 'number': 15, 'output_data_dir': 'SSC-ABSTRACT-15/', 'data_ref': 'SSC-ABSTRACT-15', 'id_line_str': '# ::id SSC-ABSTRACT-15\n', 'sentence': 'Astronomers generally accept at least nine objects as dwarf planets: the asteroid Ceres and the trans-Neptunian objects Pluto, Eris, Haumea, Makemake, Gonggong, Quaoar, Sedna, and Orcus.', 'graph': ''} -- DEBUG - *** sentence 16 *** -{'base_ref': 'SSC-ABSTRACT-16', 'number': 16, 'output_data_dir': 'SSC-ABSTRACT-16/', 'data_ref': 'SSC-ABSTRACT-16', 'id_line_str': '# ::id SSC-ABSTRACT-16\n', 'sentence': 'In addition to these two regions, various other small-body populations, including comets, centaurs and interplanetary dust clouds, freely travel between regions.', 'graph': ''} -- DEBUG - *** sentence 17 *** -{'base_ref': 'SSC-ABSTRACT-17', 'number': 17, 'output_data_dir': 'SSC-ABSTRACT-17/', 'data_ref': 'SSC-ABSTRACT-17', 'id_line_str': '# ::id SSC-ABSTRACT-17\n', 'sentence': 'Six of the planets, the six largest possible dwarf planets, and many of the smaller bodies are orbited by natural satellites, usually termed "moons" after the Moon.', 'graph': ''} -- DEBUG - *** sentence 18 *** -{'base_ref': 'SSC-ABSTRACT-18', 'number': 18, 'output_data_dir': 'SSC-ABSTRACT-18/', 'data_ref': 'SSC-ABSTRACT-18', 'id_line_str': '# ::id SSC-ABSTRACT-18\n', 'sentence': 'Each of the outer planets is encircled by planetary rings of dust and other small objects.', 'graph': ''} -- DEBUG - *** sentence 19 *** -{'base_ref': 'SSC-ABSTRACT-19', 'number': 19, 'output_data_dir': 'SSC-ABSTRACT-19/', 'data_ref': 'SSC-ABSTRACT-19', 'id_line_str': '# ::id SSC-ABSTRACT-19\n', 'sentence': 'The solar wind, a stream of charged particles flowing outwards from the Sun, creates a bubble-like region in the interstellar medium known as the heliosphere.', 'graph': ''} -- DEBUG - *** sentence 20 *** -{'base_ref': 'SSC-ABSTRACT-20', 'number': 20, 'output_data_dir': 'SSC-ABSTRACT-20/', 'data_ref': 'SSC-ABSTRACT-20', 'id_line_str': '# ::id SSC-ABSTRACT-20\n', 'sentence': 'The heliopause is the point at which pressure from the solar wind is equal to the opposing pressure of the interstellar medium; it extends out to the edge of the scattered disc.', 'graph': ''} -- DEBUG - *** sentence 21 *** -{'base_ref': 'SSC-ABSTRACT-21', 'number': 21, 'output_data_dir': 'SSC-ABSTRACT-21/', 'data_ref': 'SSC-ABSTRACT-21', 'id_line_str': '# ::id SSC-ABSTRACT-21\n', 'sentence': 'The Oort cloud, which is thought to be the source for long-period comets, may also exist at a distance roughly a thousand times further than the heliosphere.', 'graph': ''} -- DEBUG - *** sentence 22 *** -{'base_ref': 'SSC-ABSTRACT-22', 'number': 22, 'output_data_dir': 'SSC-ABSTRACT-22/', 'data_ref': 'SSC-ABSTRACT-22', 'id_line_str': '# ::id SSC-ABSTRACT-22\n', 'sentence': 'The Solar System is located 26,000 light-years from the center of the Milky Way galaxy in the Orion Arm, which contains most of the visible stars in the night sky.', 'graph': ''} -- DEBUG - *** sentence 23 *** -{'base_ref': 'SSC-ABSTRACT-23', 'number': 23, 'output_data_dir': 'SSC-ABSTRACT-23/', 'data_ref': 'SSC-ABSTRACT-23', 'id_line_str': '# ::id SSC-ABSTRACT-23\n', 'sentence': 'The nearest stars are within the so-called Local Bubble, with the closest, Proxima Centauri, at 4.25 light-years.', 'graph': ''} -- INFO - ----- number of sentences: 23 +<work_data.WorkData object at 0x7fa71e570280> +- INFO - ----- number of sentences: 2 - DEBUG - -- Making output directory tree (/home/lamenji/Workspace/Tetras/amrbatch/tests/output/Test-20230303/) - DEBUG - -- Generating sentence file - INFO - @@ -62,3 +20,30 @@ - DEBUG - (/home/lamenji/Workspace/Tetras/amrbatch/tests/../amr_models/model_parse_xfm_bart_large-v0_1_0) - DEBUG - -- working directory: /home/lamenji/Workspace/Tetras/amrbatch/amrbatch/amrld/wk/ - INFO - -- Loading AMR model +- INFO - -- Converting sentences to AMR graphs +- INFO - ----- Sentence 1 successfully processed +- DEBUG - ['# ::snt The sun is a star.\n(s / star\n :domain (s2 / sun))'] +- WARNING - gid=x Start paren present but planet is not a new concept +- INFO - ----- Sentence 2 successfully processed +- DEBUG - ['# ::snt Earth is a planet.\n(p / planet\n :domain p\n :name (n / name\n :op1 "Earth"))'] +- INFO - ----- Total processed graph number: 2 +- INFO - -- Generating AMR graph files +- DEBUG - ----- AMR Graph file (penman): test-01.stog.amr.penman +- DEBUG - ----- AMR Graph file (dot): test-01.stog.amr.dot +- DEBUG - ----- AMR Graph file (png): {os.path.basename(good_png_fn)} +- DEBUG - ----- AMR Graph file (penman): test-02.stog.amr.penman +- DEBUG - ----- AMR Graph file (dot): test-02.stog.amr.dot +- DEBUG - ----- AMR Graph file (png): {os.path.basename(good_png_fn)} +- INFO - + === AMR Graphs Serialization to AMR-RDF Representation === +- INFO - -- library: amrlk +- INFO - -- Serialize AMR graphs to RDF using amr-ld library +- DEBUG - ----- penman filepath: /home/lamenji/Workspace/Tetras/amrbatch/tests/output/Test-20230303/test-01/test-01.stog.amr.penman +- DEBUG - ----- AMRLD filepath: /home/lamenji/Workspace/Tetras/amrbatch/amrbatch/amrld/wk/test-01.stog.amr.penman +- INFO - -- Generating AMR RDF file (triple): test-01.stog.amr.nt +- INFO - -- Generating AMR RDF file (turtle): test-01.stog.amr.ttl +- INFO - -- Serialize AMR graphs to RDF using amr-ld library +- DEBUG - ----- penman filepath: /home/lamenji/Workspace/Tetras/amrbatch/tests/output/Test-20230303/test-02/test-02.stog.amr.penman +- DEBUG - ----- AMRLD filepath: /home/lamenji/Workspace/Tetras/amrbatch/amrbatch/amrld/wk/test-02.stog.amr.penman +- INFO - -- Generating AMR RDF file (triple): test-02.stog.amr.nt +- INFO - -- Generating AMR RDF file (turtle): test-02.stog.amr.ttl diff --git a/tests/output/SSC-ABSTRACT-01.sentence.txt b/tests/output/SSC-ABSTRACT-01.sentence.txt deleted file mode 100644 index 3a243308..00000000 --- a/tests/output/SSC-ABSTRACT-01.sentence.txt +++ /dev/null @@ -1,10 +0,0 @@ -The Solar System is the gravitationally bound system of the Sun and the objects that orbit it, either directly or indirectly -Of the objects that orbit the Sun directly, the largest are the eight planets, with the remainder being smaller objects, the dwarf planets and small Solar System bodies -Of the objects that orbit the Sun indirectly—the natural satellites—two are larger than the smallest planet, Mercury, and one more almost equals it in size -The Solar System formed 4.6 billion years ago from the gravitational collapse of a giant interstellar molecular cloud -The vast majority of the system's mass is in the Sun, with the majority of the remaining mass contained in Jupiter -The four smaller inner system planets, Mercury, Venus, Earth and Mars, are terrestrial planets, being primarily composed of rock and metal -The four outer system planets are giant planets, being substantially more massive than the terrestrials -The two largest planets, Jupiter and Saturn, are gas giants, being composed mainly of hydrogen and helium; the two outermost planets, Uranus and Neptune, are ice giants, being composed mostly of substances with relatively high melting points compared with hydrogen and helium, called volatiles, such as water, ammonia and methane -All eight planets have almost circular orbits that lie within a nearly flat disc called the ecliptic -The Solar System also contains smaller objects \ No newline at end of file diff --git a/tests/output/SSC-ABSTRACT-02.sentence.txt b/tests/output/SSC-ABSTRACT-02.sentence.txt deleted file mode 100644 index 725d0703..00000000 --- a/tests/output/SSC-ABSTRACT-02.sentence.txt +++ /dev/null @@ -1,10 +0,0 @@ -The asteroid belt, which lies between the orbits of Mars and Jupiter, mostly contains objects composed, like the terrestrial planets, of rock and metal -Beyond Neptune's orbit lie the Kuiper belt and scattered disc, which are populations of trans-Neptunian objects composed mostly of ices, and beyond them a newly discovered population of sednoids -Within these populations, some objects are large enough to have rounded under their own gravity, though there is considerable debate as to how many there will prove to be -Such objects are categorized as dwarf planets -Astronomers generally accept at least nine objects as dwarf planets: the asteroid Ceres and the trans-Neptunian objects Pluto, Eris, Haumea, Makemake, Gonggong, Quaoar, Sedna, and Orcus -In addition to these two regions, various other small-body populations, including comets, centaurs and interplanetary dust clouds, freely travel between regions -Six of the planets, the six largest possible dwarf planets, and many of the smaller bodies are orbited by natural satellites, usually termed "moons" after the Moon -Each of the outer planets is encircled by planetary rings of dust and other small objects -The solar wind, a stream of charged particles flowing outwards from the Sun, creates a bubble-like region in the interstellar medium known as the heliosphere -The heliopause is the point at which pressure from the solar wind is equal to the opposing pressure of the interstellar medium; it extends out to the edge of the scattered disc \ No newline at end of file diff --git a/tests/output/SSC-ABSTRACT-03.sentence.txt b/tests/output/SSC-ABSTRACT-03.sentence.txt deleted file mode 100644 index 4cf2c2b7..00000000 --- a/tests/output/SSC-ABSTRACT-03.sentence.txt +++ /dev/null @@ -1,3 +0,0 @@ -The Oort cloud, which is thought to be the source for long-period comets, may also exist at a distance roughly a thousand times further than the heliosphere -The Solar System is located 26,000 light-years from the center of the Milky Way galaxy in the Orion Arm, which contains most of the visible stars in the night sky -The nearest stars are within the so-called Local Bubble, with the closest, Proxima Centauri, at 4.25 light-years \ No newline at end of file diff --git a/tests/output/Test-20230303/SSC-ABSTRACT.sentence.txt b/tests/output/Test-20230303/SSC-ABSTRACT.sentence.txt deleted file mode 100644 index ebee7931..00000000 --- a/tests/output/Test-20230303/SSC-ABSTRACT.sentence.txt +++ /dev/null @@ -1,23 +0,0 @@ -The Solar System is the gravitationally bound system of the Sun and the objects that orbit it, either directly or indirectly. -Of the objects that orbit the Sun directly, the largest are the eight planets, with the remainder being smaller objects, the dwarf planets and small Solar System bodies. -Of the objects that orbit the Sun indirectly—the natural satellites—two are larger than the smallest planet, Mercury, and one more almost equals it in size. -The Solar System formed 4.6 billion years ago from the gravitational collapse of a giant interstellar molecular cloud. -The vast majority of the system's mass is in the Sun, with the majority of the remaining mass contained in Jupiter. -The four smaller inner system planets, Mercury, Venus, Earth and Mars, are terrestrial planets, being primarily composed of rock and metal. -The four outer system planets are giant planets, being substantially more massive than the terrestrials. -The two largest planets, Jupiter and Saturn, are gas giants, being composed mainly of hydrogen and helium; the two outermost planets, Uranus and Neptune, are ice giants, being composed mostly of substances with relatively high melting points compared with hydrogen and helium, called volatiles, such as water, ammonia and methane. -All eight planets have almost circular orbits that lie within a nearly flat disc called the ecliptic. -The Solar System also contains smaller objects. -The asteroid belt, which lies between the orbits of Mars and Jupiter, mostly contains objects composed, like the terrestrial planets, of rock and metal. -Beyond Neptune's orbit lie the Kuiper belt and scattered disc, which are populations of trans-Neptunian objects composed mostly of ices, and beyond them a newly discovered population of sednoids. -Within these populations, some objects are large enough to have rounded under their own gravity, though there is considerable debate as to how many there will prove to be. -Such objects are categorized as dwarf planets. -Astronomers generally accept at least nine objects as dwarf planets: the asteroid Ceres and the trans-Neptunian objects Pluto, Eris, Haumea, Makemake, Gonggong, Quaoar, Sedna, and Orcus. -In addition to these two regions, various other small-body populations, including comets, centaurs and interplanetary dust clouds, freely travel between regions. -Six of the planets, the six largest possible dwarf planets, and many of the smaller bodies are orbited by natural satellites, usually termed "moons" after the Moon. -Each of the outer planets is encircled by planetary rings of dust and other small objects. -The solar wind, a stream of charged particles flowing outwards from the Sun, creates a bubble-like region in the interstellar medium known as the heliosphere. -The heliopause is the point at which pressure from the solar wind is equal to the opposing pressure of the interstellar medium; it extends out to the edge of the scattered disc. -The Oort cloud, which is thought to be the source for long-period comets, may also exist at a distance roughly a thousand times further than the heliosphere. -The Solar System is located 26,000 light-years from the center of the Milky Way galaxy in the Orion Arm, which contains most of the visible stars in the night sky. -The nearest stars are within the so-called Local Bubble, with the closest, Proxima Centauri, at 4.25 light-years. \ No newline at end of file diff --git a/tests/output/Test-20230303/test-01/test-01.stog.amr.nt b/tests/output/Test-20230303/test-01/test-01.stog.amr.nt index c3de20a5..93215638 100644 --- a/tests/output/Test-20230303/test-01/test-01.stog.amr.nt +++ b/tests/output/Test-20230303/test-01/test-01.stog.amr.nt @@ -1,22 +1,22 @@ +<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . +<http://amr.isi.edu/amr_data/test-01#s> <http://amr.isi.edu/rdf/amr-terms#domain> <http://amr.isi.edu/amr_data/test-01#s2> . <http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Role> . -<http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . -<http://amr.isi.edu/amr_data/test-01#root01> <http://amr.isi.edu/rdf/core-amr#root> <http://amr.isi.edu/amr_data/test-01#s> . +<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> . <http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> . +<http://amr.isi.edu/rdf/amr-terms#sun> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> . +<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Concept" . +<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-EntityType" . +<http://amr.isi.edu/amr_data/test-01#root01> <http://amr.isi.edu/rdf/core-amr#has-id> "test-01" . <http://amr.isi.edu/amr_data/test-01#s> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/entity-types#star> . -<http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-PropBank-Frame" . -<http://amr.isi.edu/amr_data/test-01#s> <http://amr.isi.edu/rdf/amr-terms#domain> <http://amr.isi.edu/amr_data/test-01#s2> . <http://amr.isi.edu/amr_data/test-01#s2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/amr-terms#sun> . <http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Term" . +<http://amr.isi.edu/amr_data/test-01#root01> <http://amr.isi.edu/rdf/core-amr#root> <http://amr.isi.edu/amr_data/test-01#s> . <http://amr.isi.edu/amr_data/test-01#root01> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#AMR> . +<http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-PropBank-Frame" . <http://amr.isi.edu/rdf/amr-terms#domain> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Role> . -<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Concept" . -<http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Role" . -<http://amr.isi.edu/rdf/amr-terms#sun> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> . -<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-EntityType" . -<http://amr.isi.edu/amr_data/test-01#root01> <http://amr.isi.edu/rdf/core-amr#has-id> "test-01" . <http://amr.isi.edu/amr_data/test-01#root01> <http://amr.isi.edu/rdf/core-amr#has-sentence> "The sun is a star." . -<http://amr.isi.edu/entity-types#star> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#NamedEntity> . <http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-PropBank-Role" . -<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . -<http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> . +<http://amr.isi.edu/entity-types#star> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#NamedEntity> . +<http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . +<http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Role" . diff --git a/tests/output/Test-20230303/test-01/test-01.stog.amr.ttl b/tests/output/Test-20230303/test-01/test-01.stog.amr.ttl index 4ad04c79..85be531d 100644 --- a/tests/output/Test-20230303/test-01/test-01.stog.amr.ttl +++ b/tests/output/Test-20230303/test-01/test-01.stog.amr.ttl @@ -1,36 +1,36 @@ -@prefix ns1: <http://amr.isi.edu/rdf/core-amr#> . -@prefix ns2: <http://amr.isi.edu/rdf/amr-terms#> . +@prefix ns1: <http://amr.isi.edu/rdf/amr-terms#> . +@prefix ns2: <http://amr.isi.edu/rdf/core-amr#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . -ns1:Concept a rdfs:Class ; +ns2:Concept a rdfs:Class ; rdfs:label "AMR-Concept" . -ns1:Role a rdfs:Class ; +ns2:Role a rdfs:Class ; rdfs:label "AMR-Role" . -<http://amr.isi.edu/amr_data/test-01#root01> a ns1:AMR ; - ns1:has-id "test-01" ; - ns1:has-sentence "The sun is a star." ; - ns1:root <http://amr.isi.edu/amr_data/test-01#s> . +<http://amr.isi.edu/amr_data/test-01#root01> a ns2:AMR ; + ns2:has-id "test-01" ; + ns2:has-sentence "The sun is a star." ; + ns2:root <http://amr.isi.edu/amr_data/test-01#s> . -<http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> a ns1:Role ; +<http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> a ns2:Role ; rdfs:label "AMR-PropBank-Role" . -ns2:domain a ns1:Role . +ns1:domain a ns2:Role . -ns1:Frame a ns1:Concept ; +ns2:Frame a ns2:Concept ; rdfs:label "AMR-PropBank-Frame" . <http://amr.isi.edu/amr_data/test-01#s> a <http://amr.isi.edu/entity-types#star> ; - ns2:domain <http://amr.isi.edu/amr_data/test-01#s2> . + ns1:domain <http://amr.isi.edu/amr_data/test-01#s2> . -<http://amr.isi.edu/amr_data/test-01#s2> a ns2:sun . +<http://amr.isi.edu/amr_data/test-01#s2> a ns1:sun . -<http://amr.isi.edu/entity-types#star> a ns1:NamedEntity . +<http://amr.isi.edu/entity-types#star> a ns2:NamedEntity . -ns2:sun a ns1:Concept . +ns1:sun a ns2:Concept . -ns1:NamedEntity a ns1:Concept ; +ns2:NamedEntity a ns2:Concept ; rdfs:label "AMR-EntityType", "AMR-Term" . diff --git a/tests/output/Test-20230303/test-02/test-02.stog.amr.nt b/tests/output/Test-20230303/test-02/test-02.stog.amr.nt index d51b316c..0d9635e7 100644 --- a/tests/output/Test-20230303/test-02/test-02.stog.amr.nt +++ b/tests/output/Test-20230303/test-02/test-02.stog.amr.nt @@ -1,19 +1,19 @@ -<http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> . +<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . +<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Concept" . +<http://amr.isi.edu/amr_data/test-02#p> <http://www.w3.org/2000/01/rdf-schema#label> "Earth" . <http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> . +<http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Role> . <http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Role" . +<http://amr.isi.edu/amr_data/test-02#root01> <http://amr.isi.edu/rdf/core-amr#has-id> "test-02" . <http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-EntityType" . +<http://amr.isi.edu/entity-types#planet> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#NamedEntity> . <http://amr.isi.edu/amr_data/test-02#root01> <http://amr.isi.edu/rdf/core-amr#has-sentence> "Earth is a planet." . -<http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Role> . -<http://amr.isi.edu/amr_data/test-02#p> <http://www.w3.org/2000/01/rdf-schema#label> "Earth" . -<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Concept" . +<http://amr.isi.edu/amr_data/test-02#root01> <http://amr.isi.edu/rdf/core-amr#root> <http://amr.isi.edu/amr_data/test-02#p> . <http://amr.isi.edu/amr_data/test-02#p> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/entity-types#planet> . -<http://amr.isi.edu/entity-types#planet> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#NamedEntity> . -<http://amr.isi.edu/rdf/core-amr#Concept> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . -<http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-PropBank-Frame" . <http://amr.isi.edu/frames/ld/v1.2.2/FrameRole> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-PropBank-Role" . -<http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . -<http://amr.isi.edu/amr_data/test-02#root01> <http://amr.isi.edu/rdf/core-amr#root> <http://amr.isi.edu/amr_data/test-02#p> . <http://amr.isi.edu/amr_data/test-02#root01> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#AMR> . <http://amr.isi.edu/rdf/core-amr#NamedEntity> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-Term" . -<http://amr.isi.edu/amr_data/test-02#root01> <http://amr.isi.edu/rdf/core-amr#has-id> "test-02" . +<http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/2000/01/rdf-schema#label> "AMR-PropBank-Frame" . +<http://amr.isi.edu/rdf/core-amr#Frame> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://amr.isi.edu/rdf/core-amr#Concept> . +<http://amr.isi.edu/rdf/core-amr#Role> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . diff --git a/tests/output/test-1.sentence.txt b/tests/output/test-1.sentence.txt deleted file mode 100644 index 57654ef9..00000000 --- a/tests/output/test-1.sentence.txt +++ /dev/null @@ -1,2 +0,0 @@ -The sun is a star -Earth is a planet. diff --git a/tests/test_amrbatch_main.py b/tests/test_amrbatch_main.py index 4b92f612..89883a48 100644 --- a/tests/test_amrbatch_main.py +++ b/tests/test_amrbatch_main.py @@ -26,7 +26,7 @@ from utility import file_cutter # -- Input Data input_filename = f'test.txt' -input_filename = f'SSC-ABSTRACT.txt' +# input_filename = f'SSC-ABSTRACT.txt' input_filepath = f'{INPUT_DIR_PATH}{input_filename}' -- GitLab