KRR-Oxford / OWL2Vec-Star

Embedding OWL ontologies
Apache License 2.0
84 stars 25 forks source link

Output format #2

Closed fanavarro closed 3 years ago

fanavarro commented 3 years ago

Hi, first of all, thanks for making available owl2vec*!

I am pretty new in embeddings, and I am wondering how to manage the output provided by the standalone app for calculating the embeddings for a single ontology. I guess the output is in the cache folder, but I have several python notebooks and one file called "output". in addition to txt files with the information extracted from the ontology (axioms, annotations and entities). My question is: how can I access to the embeddings?

Thanks in advance, Francisco Abad

ernestojimenezruiz commented 3 years ago

Hi Francisco

I'm glad you are interested in OWL2Vec, and thanks for the pull request (we will approve it soon). We had this in the TODO list but we could not find the time. We would also like to release OWL2Vec on pypip eventually.

I have to commit a few changes I made locally so that my students could use OWL2Vec*:

I added these lines to save the embeddings in different formats: model_.save(config['BASIC']['embeddingdir']) model.wv.save_word2vec_format(config['BASIC']['embeddingdir']+".txt", binary=False) model.wv.save_word2vec_format(config['BASIC']['embedding_dir']+".bin", binary=True)

As embedding_dir I use: embedding_dir = ./output_embedding/onto.embeddings

Then I use KeyedVectors to load the vectors: from gensim.models import KeyedVectors wv = KeyedVectors.load("pizza.embeddings", mmap='r')

fanavarro commented 3 years ago

Hi Ernesto, thanks so much for your reply and sorry for answering 2 weeks later. I'll try your suggestion tomorrow in the evening and I'll post my results here. Hopefully I will be able to successfully close this issue.

Thanks again. Kind regards.

fanavarro commented 3 years ago

Hi @ernestojimenezruiz , I've tested your suggestion and it worked for me. Now, I am able to generate the txt version of the embeddings. Thanks so much!