ontolearn.utils
Ontolearn utils.
Submodules
Attributes
Functions
|
Setup logging. |
|
Compute F1-score of a concept |
|
Compute F1 score for two set |
|
Reduces a set of concepts by applying a binary operation to each pair of concepts. |
Map a set of owl concepts and a set of properties into OWL Restrictions |
|
|
Compute Jaccard Similarity |
|
|
|
|
|
|
|
|
|
|
|
Balance given two sets through sampling without replacement. |
|
Path leads a folder containing embeddings in csv format. |
|
|
|
|
Read a text file containing IRIs of Named Individuals (one per line) and return the content as a set of OWL |
|
Read a text file containing IRIs of OWL Named Classes (one per line) and return the content as a set of OWL |
Package Contents
- ontolearn.utils.setup_logging(config_file='ontolearn/logging.conf')[source]
Setup logging.
- Parameters:
config_file (str) – Filepath for logs.
- ontolearn.utils.compute_f1_score(individuals, pos, neg) float [source]
Compute F1-score of a concept
- ontolearn.utils.f1_set_similarity(y: Set[str], yhat: Set[str]) float [source]
Compute F1 score for two set :param y: A set of URIs :param yhat: A set of URIs :return:
- ontolearn.utils.concept_reducer(concepts, opt)[source]
Reduces a set of concepts by applying a binary operation to each pair of concepts.
- Parameters:
concepts (set) – A set of concepts to be reduced.
opt (function) – A binary function that takes a pair of concepts and returns a single concept.
- Returns:
A set containing the results of applying the binary operation to each pair of concepts.
- Return type:
set
Example
>>> concepts = {1, 2, 3} >>> opt = lambda x: x[0] + x[1] >>> concept_reducer(concepts, opt) {2, 3, 4, 5, 6}
Note
The operation opt should be commutative and associative to ensure meaningful reduction in the context of set operations.
- ontolearn.utils.concept_reducer_properties(concepts: Set, properties, cls: Callable = None, cardinality: int = 2) Set[owlapy.class_expression.OWLQuantifiedObjectRestriction | owlapy.class_expression.OWLObjectCardinalityRestriction] [source]
Map a set of owl concepts and a set of properties into OWL Restrictions
- Parameters:
concepts
properties
cls (Callable) – An owl Restriction class
cardinality – A positive Integer
Returns: List of OWL Restrictions
- ontolearn.utils.Factory
- ontolearn.utils.DEFAULT_FMT = 'Func:{name} took {elapsed:0.8f}s'
- ontolearn.utils.flag_for_performance = False
- ontolearn.utils.jaccard_similarity(y: Set[str], yhat: Set[str]) float [source]
Compute Jaccard Similarity :param y: A set of URIs :param yhat: A set of URIs :return:
- ontolearn.utils.balanced_sets(a: set, b: set) Tuple[Set, Set] [source]
Balance given two sets through sampling without replacement. Returned sets have the same length. @param a: @param b: @return:
- ontolearn.utils.read_csv(path) None | pandas.DataFrame [source]
Path leads a folder containing embeddings in csv format. indexes correspond subjects or predicates or objects in n-triple. @param path: @return:
- ontolearn.utils.read_individuals_file(file: str) Set[owlapy.owl_individual.OWLNamedIndividual] [source]
Read a text file containing IRIs of Named Individuals (one per line) and return the content as a set of OWL Named Individuals
- Parameters:
file – path to the text file with the IRIs of the named individuals
- Returns:
set of OWLNamedIndividual with these IRIs
- ontolearn.utils.read_named_classes_file(file: str) Set[owlapy.class_expression.OWLClass] [source]
Read a text file containing IRIs of OWL Named Classes (one per line) and return the content as a set of OWL Classes
- Parameters:
file – path to the text file with the IRIs of the classes
- Returns:
set of OWLNamedIndividual with these IRIs