Skip to content
Snippets Groups Projects
Commit 2e696ad5 authored by Aurélien Lamercerie's avatar Aurélien Lamercerie
Browse files

Update main script

parent 264e7d15
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/python3.10 #!/usr/bin/python3.10
# -*-coding:Utf-8 -* # -*-coding:Utf-8 -*
#============================================================================== """
# ontoScorer: [brief description of the module] ontoScorer: [brief description of the module]
#------------------------------------------------------------------------------ ------------------------------------------------------------------------------
# Detailed module description, if needed Detailed module description, if needed
#============================================================================== """
from ontoScorer.scorer import OntoScorer from ontoScorer.scorer import OntoScorer
def main(): def main():
# Define the path to the data folder # Paths to data
DATA_FOLDER_PATH = "data" DATA_FOLDER_PATH = "data"
# Define paths to the ontology files
REFERENCE_ONTOLOGY_PATH = f"{DATA_FOLDER_PATH}/reference_ontology.ttl" REFERENCE_ONTOLOGY_PATH = f"{DATA_FOLDER_PATH}/reference_ontology.ttl"
GENERATED_ONTOLOGY_PATH = f"{DATA_FOLDER_PATH}/generated_ontology.ttl" GENERATED_ONTOLOGY_PATH = f"{DATA_FOLDER_PATH}/generated_ontology.ttl"
# Initialize the scorer # Equivalent Prefix (used to harmonize the ontologies)
scorer = OntoScorer(REFERENCE_ONTOLOGY_PATH, GENERATED_ONTOLOGY_PATH) EQUIVALENT_PREFIX = [
("base", "https://reference.tetras-libre.fr/base-ontology#", "https://tenet.tetras-libre.fr/base-ontology#"),
("result", "https://reference.tetras-libre.fr/expected-result#", "https://tenet.tetras-libre.fr/extract-result#")
]
# Compare the ontologies # Scorer Process Run
scorer = OntoScorer(REFERENCE_ONTOLOGY_PATH, GENERATED_ONTOLOGY_PATH, EQUIVALENT_PREFIX)
scorer.compute_metrics() scorer.compute_metrics()
# Generate a report
scorer.generate_report() scorer.generate_report()
if __name__ == "__main__": if __name__ == "__main__":
......
#!/usr/bin/python3.10 #!/usr/bin/python3.10
# -*-coding:Utf-8 -* # -*-coding:Utf-8 -*-
#============================================================================== """
# ontoScorer: [brief description of the module] ontoScorer: Module for comparing a reference ontology with a generated one.
#------------------------------------------------------------------------------ ------------------------------------------------------------------------------
# Detailed module description, if needed This module provides functionality to compute various metrics comparing
#============================================================================== a manually crafted reference ontology and a generated ontology. It also
facilitates the creation of detailed comparison reports.
"""
from ontology import Ontology from ontology import Ontology
from report import Report from report import Report
from metrics import Metrics from metrics import Metrics
class OntoScorer: class OntoScorer:
def __init__(self, reference_ontology_path, generated_ontology_path): """
self.reference_ontology = Ontology(reference_ontology_path) The OntoScorer class is used to compare a reference ontology with a generated one.
self.generated_ontology = Ontology(generated_ontology_path)
Attributes:
- reference_ontology (Ontology): The manually crafted reference ontology.
- generated_ontology (Ontology): The automatically generated ontology.
- metrics (Metrics): An instance of the Metrics class to compute scores for comparison.
Methods:
- compute_metrics(): Computes various metrics comparing reference and generated ontologies.
- generate_report(): Produces a detailed report based on computed metrics.
"""
def __init__(self, reference_ontology_path, generated_ontology_path, equivalent_prefix):
"""
Initializes the OntoScorer with paths to reference and generated ontologies.
Args:
- reference_ontology_path (str): Path to the reference ontology file.
- generated_ontology_path (str): Path to the generated ontology file.
- equivalent_prefix (str): Prefix to handle equivalent terms or concepts.
"""
self.reference_ontology = Ontology(reference_ontology_path, equivalent_prefix)
self.generated_ontology = Ontology(generated_ontology_path, equivalent_prefix)
self.metrics = Metrics() self.metrics = Metrics()
def compute_metrics(self): def compute_metrics(self):
self.metrics.compute_entity_scores(self.reference_ontology, self.generated_ontology) self.metrics.compute_entity_scores(self.reference_ontology, self.generated_ontology)
self.metrics.compute_taxonomic_relation_scores(self.reference_ontology, self.generated_ontology)
self.metrics.compute_non_taxonomic_relation_scores(self.reference_ontology, self.generated_ontology)
self.metrics.compute_axiom_scores(self.reference_ontology, self.generated_ontology)
def generate_report(self): def generate_report(self):
report = Report(self.reference_ontology, report = Report(self.reference_ontology, self.generated_ontology, self.metrics)
self.generated_ontology,
self.metrics)
print(report.generate()) print(report.generate())
# def generate_report(self, report_path):
# report = Report(self.comparison_result, self.metrics)
# report.generate(report_path)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment