Select Git revision
.env.sample
scorer.py 2.27 KiB
#!/usr/bin/python3.10
# -*-coding:Utf-8 -*-
"""
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:
"""
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)
print(report.generate())