Skip to content

Commit b7e4e0e

Browse files
authoredFeb 22, 2022
Merge pull request #13 from bio-ontology-research-group/owl2vec
🎨 ✨ ✅ Moved OWL2VecStar from develop di…
2 parents 09c5814 + 460a954 commit b7e4e0e

File tree

11 files changed

+64
-2335
lines changed

11 files changed

+64
-2335
lines changed
 

‎docs/source/api/embedding/graph_based/index.rst

+9-1
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,21 @@ DL2Vec
1111
:undoc-members:
1212
:show-inheritance:
1313

14-
1514
Example of use
1615
^^^^^^^^^^^^^^^
1716
An example of use can be found at :doc:`../../../tutorials/DL2Vec`
1817

1918

2019

20+
OWL2Vec*
21+
--------
22+
23+
.. automodule:: mowl.embeddings.graph_based.owl2vec_star.model
24+
:members:
25+
:undoc-members:
26+
:show-inheritance:
27+
28+
2129
Translational Embeddings
2230
-------------------------
2331

‎mowl/develop/owl2vec/model.py

-34
This file was deleted.

‎mowl/embeddings/graph_based/dl2vec/model.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,18 @@ class DL2Vec(Model):
2929
:type outfile: str
3030
:param bidirectional_taxonomy: If true, the ontology projection into a graph will add inverse edges per each subclass axiom
3131
:type bidirectional_taxonomy: bool
32+
:param walking_method: Method for generating the walks. Choices are: deepwalk (default), node2vec, walkrdfowl.
33+
:type walking_method: str
3234
:param walk_length: Length of the walk performed for each node
3335
:type walk_length: int
3436
:param num_walks: Number of walks performed per node
3537
:type num_walks: int
36-
:param alpha: Probability of restart in the walking phase
38+
:param alpha: Probability of restart in the walking phase. Applicable with DeepWalk
3739
:type alpha: float
40+
:param p: Return hyperparameter. Default is 1. Applicable with Node2Vec
41+
:type p: float
42+
:param q: In-out hyperparameter. Default is 1. Applicable with Node2Vec.
43+
:type q: float
3844
:param vector_size: Dimensionality of the word vectors. Same as :class:`gensim.models.word2vec.Word2Vec`
3945
:type vector_size: int
4046
:param wv_epochs: Number of epochs for the Word2Vec model

‎mowl/embeddings/graph_based/owl2vec/model.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,39 @@
2020

2121
logging.basicConfig(level=logging.INFO)
2222

23-
class OWL2Vec(Model):
24-
23+
class OWL2VecStar(Model):
2524
'''
2625
:param dataset: Dataset composed by training, validation and testing sets, each of which are in OWL format.
2726
:type dataset: :class:`mowl.datasets.base.Dataset`
2827
:param outfile: Path to save the final model
2928
:type outfile: str
3029
:param bidirectional_taxonomy: If true, the ontology projection into a graph will add inverse edges per each subclass axiom
3130
:type bidirectional_taxonomy: bool
32-
:param include_literals: If true the graph will also include triples involving data property assertions and annotations. Default is False.
33-
:type include_literals: bool
34-
:param only_taxonomy: If true, the projection will only include subClass edges
31+
:param only_taxonomy: If true, the ontology projection will consider only subclass axioms.
3532
:type only_taxonomy: bool
33+
:param include_literals: If true, the graph will also include triples involving data property assertions and annotations.
34+
:type include_literals: bool
35+
:param walking_method: Method for generating the walks. Choices are: deepwalk (default), node2vec, walkrdfowl.
36+
:type walking_method: str
3637
:param walk_length: Length of the walk performed for each node
3738
:type walk_length: int
3839
:param num_walks: Number of walks performed per node
3940
:type num_walks: int
40-
:param alpha: Probability of restart in the walking phase
41+
:param alpha: Probability of restart in the walking phase. Applicable with DeepWalk
4142
:type alpha: float
43+
:param p: Return hyperparameter. Default is 1. Applicable with Node2Vec
44+
:type p: float
45+
:param q: In-out hyperparameter. Default is 1. Applicable with Node2Vec.
46+
:type q: float
4247
:param vector_size: Dimensionality of the word vectors. Same as :class:`gensim.models.word2vec.Word2Vec`
4348
:type vector_size: int
4449
:param wv_epochs: Number of epochs for the Word2Vec model
4550
:type wv_epochs: int
4651
:param window: Maximum distance between the current and predicted word within a sentence. Same as :class:`gensim.models.word2vec.Word2Vec`
4752
:type window: int
48-
:param num_procs: Number of threads to use for the random walks and the Word2Vec model.
49-
:type num_procs: int
53+
:param workers: Number of threads to use for the random walks and the Word2Vec model.
54+
:type workers: int
5055
'''
51-
5256

5357
def __init__(self, dataset, outfile, bidirectional_taxonomy=False, include_literals = False, only_taxonomy = False, walking_method = "deepwalk", walk_length = 30, wv_epochs = 10, alpha = 0, num_walks = 100, vector_size = 100, window = 5, workers = 1, p = 1, q=1):
5458

‎mowl/graph/factory.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from mowl.graph.taxonomyRels.model import TaxonomyWithRelsParser
33
from mowl.graph.dl2vec.model import DL2VecParser
44

5-
from mowl.graph.owl2vec_star.model import OWL2VecParser
5+
from mowl.graph.owl2vec_star.model import OWL2VecStarParser
66

77
def parser_factory(method_name, dataset, bidirectional_taxonomy, include_literals = False, only_taxonomy = False):
88
methods = [
@@ -19,6 +19,6 @@ def parser_factory(method_name, dataset, bidirectional_taxonomy, include_literal
1919
elif method_name == "dl2vec":
2020
return DL2VecParser(dataset, bidirectional_taxonomy= bidirectional_taxonomy)
2121
elif method_name == "owl2vec_star":
22-
return OWL2VecParser(dataset, bidirectional_taxonomy=bidirectional_taxonomy, include_literals = include_literals, only_taxonomy = only_taxonomy)
22+
return OWL2VecStarParser(dataset, bidirectional_taxonomy=bidirectional_taxonomy, include_literals = include_literals, only_taxonomy = only_taxonomy)
2323
else:
2424
raise Exception(f"Graph generation method unrecognized. Recognized methods are: {methods}")

0 commit comments

Comments
 (0)
Please sign in to comment.