Commit 1314d757 authored by markus's avatar markus
Browse files

Argument support for pykeen_embeddings file

parent 6e5caccb
from rdflib import Graph
from pykeen.triples import TriplesFactory
from pykeen.pipeline import pipeline
from rdflib import Graph
import os.path
import argparse
import tempfile
def _create_tsv(g: Graph, tsv_target_file : str):
......@@ -75,3 +78,26 @@ def load_embeddings_from_file(embeddings_file : str) -> dict:
embeddings[entity] = embedding
return embeddings
def main():
parser = argparse.ArgumentParser(description='Create embeddings based on owl KG')
parser.add_argument('owl_file', metavar='OWL File', type=str,
help='XML file containing graph to embed.')
parser.add_argument('triple_file', metavar='Triple File', type=str,
help='Path to .tsv style to store graph tripels')
parser.add_argument('model_name', metavar='Model Name', type=str,
help='Model to use for embeddings, e.g. TransR or TransE. Model must be supported by PyKeen.')
parser.add_argument('dim', metavar='Dimension', type=int,
help='Target dimension of embeddings.')
parser.add_argument('target_file', metavar='Target file', type=str,
help='File to save generated embeddings in. Should be of type .tsv.')
args = parser.parse_args()
g = Graph()
g.parse(args.owl_file, format='application/rdf+xml')
new_file, filename = tempfile.mkstemp()
generate_and_save_embeddings(g, args.triple_file, args.target_file, args.model_name, args.dim)
if __name__ == "__main__":
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment