From 2e696ad5c39af1922741a3d55643f288c26c4a0e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Aur=C3=A9lien=20Lamercerie?=
 <aurelien.lamercerie@tetras-libre.fr>
Date: Fri, 18 Aug 2023 10:44:38 +0200
Subject: [PATCH] Update main script

---
 main.py              | 30 ++++++++++++-------------
 ontoScorer/scorer.py | 52 +++++++++++++++++++++++++++++++-------------
 2 files changed, 52 insertions(+), 30 deletions(-)

diff --git a/main.py b/main.py
index 4c53ecd..130e11c 100644
--- a/main.py
+++ b/main.py
@@ -1,29 +1,29 @@
 #!/usr/bin/python3.10
 # -*-coding:Utf-8 -*
 
-#==============================================================================
-# ontoScorer: [brief description of the module]
-#------------------------------------------------------------------------------
-# Detailed module description, if needed
-#==============================================================================
+"""
+ontoScorer: [brief description of the module]
+------------------------------------------------------------------------------
+Detailed module description, if needed
+"""
 
 from ontoScorer.scorer import OntoScorer
 
 def main():
-    # Define the path to the data folder
+    # Paths to data
     DATA_FOLDER_PATH = "data"
-
-    # Define paths to the ontology files
     REFERENCE_ONTOLOGY_PATH = f"{DATA_FOLDER_PATH}/reference_ontology.ttl"
     GENERATED_ONTOLOGY_PATH = f"{DATA_FOLDER_PATH}/generated_ontology.ttl"
-
-    # Initialize the scorer
-    scorer = OntoScorer(REFERENCE_ONTOLOGY_PATH, GENERATED_ONTOLOGY_PATH)
-
-    # Compare the ontologies
+    
+    # Equivalent Prefix (used to harmonize the ontologies)
+    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#")
+    ]    
+
+    # Scorer Process Run
+    scorer = OntoScorer(REFERENCE_ONTOLOGY_PATH, GENERATED_ONTOLOGY_PATH, EQUIVALENT_PREFIX)
     scorer.compute_metrics()
-
-    # Generate a report
     scorer.generate_report()
 
 if __name__ == "__main__":
diff --git a/ontoScorer/scorer.py b/ontoScorer/scorer.py
index adccd3d..8abce4c 100644
--- a/ontoScorer/scorer.py
+++ b/ontoScorer/scorer.py
@@ -1,32 +1,54 @@
 #!/usr/bin/python3.10
-# -*-coding:Utf-8 -*
+# -*-coding:Utf-8 -*-
 
-#==============================================================================
-# ontoScorer: [brief description of the module]
-#------------------------------------------------------------------------------
-# Detailed module description, if needed
-#==============================================================================
+"""
+ontoScorer: Module for comparing a reference ontology with a generated one.
+------------------------------------------------------------------------------
+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 report import Report
 from metrics import Metrics
 
 class OntoScorer:
-    def __init__(self, reference_ontology_path, generated_ontology_path):
-        self.reference_ontology = Ontology(reference_ontology_path)
-        self.generated_ontology = Ontology(generated_ontology_path)
+    """
+    The OntoScorer class is used to compare a reference ontology with a generated one.
+
+    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()
 
     def compute_metrics(self):
         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):
-        report = Report(self.reference_ontology,
-                        self.generated_ontology,
-                        self.metrics)
+        report = Report(self.reference_ontology, self.generated_ontology, self.metrics)
         print(report.generate())
 
 
-    # def generate_report(self, report_path):
-    #     report = Report(self.comparison_result, self.metrics)
-    #     report.generate(report_path)
-- 
GitLab