Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ontoScorer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tetras MARS
ontoScorer
Commits
2e696ad5
Commit
2e696ad5
authored
1 year ago
by
Aurélien Lamercerie
Browse files
Options
Downloads
Patches
Plain Diff
Update main script
parent
264e7d15
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
main.py
+15
-15
15 additions, 15 deletions
main.py
ontoScorer/scorer.py
+37
-15
37 additions, 15 deletions
ontoScorer/scorer.py
with
52 additions
and
30 deletions
main.py
+
15
−
15
View file @
2e696ad5
#!/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 p
ath to
the data folder
#
P
ath
s
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__
"
:
...
...
This diff is collapsed.
Click to expand it.
ontoScorer/scorer.py
+
37
−
15
View file @
2e696ad5
#!/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)
This diff is collapsed.
Click to expand it.
Aurélien Lamercerie
@alam
mentioned in issue
#5 (closed)
·
1 year ago
mentioned in issue
#5 (closed)
mentioned in issue #5
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment