You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
deftest_compare_embeddings():
""" Compare our embeddings database with the old database. """# Test 1: Check old glove embedding is the same as new glove# embedding:mentions= ["apple"]
embs=rel_utils.get_db_emb(
"resources/rel_db/embedding_database.db", mentions, "snd"
)
withsqlite3.connect("resources/rel_db/generic/common_drawl.db") asconn2:
c2=conn2.cursor()
result=c2.execute(
"SELECT emb FROM embeddings WHERE word=?", ("apple",)
).fetchone()
result=resultifresultisNoneelsearray("f", result[0]).tolist()
assertembs[0] ==result# Test 2: Check old glove embedding is different from new wiki2vec# word embedding:mentions= ["apple"]
embs=rel_utils.get_db_emb(
"resources/rel_db/embedding_database.db", mentions, "snd"
)
withsqlite3.connect("resources/rel_db/generic/entity_word_embedding.db") asconn2:
c2=conn2.cursor()
result=c2.execute(
"SELECT emb FROM embeddings WHERE word=?", ("apple",)
).fetchone()
result=resultifresultisNoneelsearray("f", result[0]).tolist()
assertembs[0] !=result# Test 3: Check old wiki2vec word embedding is the same as new wiki2vec# word embedding:mentions= ["apple"]
embs=rel_utils.get_db_emb(
"resources/rel_db/embedding_database.db", mentions, "word"
)
withsqlite3.connect("resources/rel_db/generic/entity_word_embedding.db") asconn2:
c2=conn2.cursor()
result=c2.execute(
"SELECT emb FROM embeddings WHERE word=?", ("apple",)
).fetchone()
result=resultifresultisNoneelsearray("f", result[0]).tolist()
assertembs[0] ==result# Test 4: Check old wiki2vec entity embedding is the same as new wiki2vec# entity embedding (old requires wikipedia input, new requires wikidata# input):mentions= ["Q84"]
embs=rel_utils.get_db_emb(
"resources/rel_db/embedding_database.db", mentions, "entity"
)
withsqlite3.connect("resources/rel_db/generic/entity_word_embedding.db") asconn2:
c2=conn2.cursor()
result=c2.execute(
"SELECT emb FROM embeddings WHERE word=?", ("ENTITY/London",)
).fetchone()
result=resultifresultisNoneelsearray("f", result[0]).tolist()
assertembs[0] ==result# Test 5: Check old wiki2vec entity embedding is the same as new wiki2vec# entity embedding (old requires wikipedia input, new requires wikidata# input):mentions= ["Q84"]
embs=rel_utils.get_db_emb(
"resources/rel_db/embedding_database.db", mentions, "entity"
)
withsqlite3.connect("resources/rel_db/generic/entity_word_embedding.db") asconn2:
c2=conn2.cursor()
result=c2.execute(
"SELECT emb FROM embeddings WHERE word=?", ("London",)
).fetchone()
result=resultifresultisNoneelsearray("f", result[0]).tolist()
assertembs[0] !=result
The text was updated successfully, but these errors were encountered:
Test from other repository:
The text was updated successfully, but these errors were encountered: