From 187be369e594dd4483e0f56f61c38d8313964ff3 Mon Sep 17 00:00:00 2001 From: K-hongou Date: Sat, 1 Aug 2020 08:51:57 +0900 Subject: [PATCH] test --- word2vec.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/word2vec.py b/word2vec.py index d3a1aa0..2c549a1 100644 --- a/word2vec.py +++ b/word2vec.py @@ -1,5 +1,28 @@ import gensim import sys -word = sys.argv[1] -model = gensim.models.Word2Vec.load('./ja/ja.bin') -print(model[word]) \ No newline at end of file +hogeword = sys.argv #コマンドライン引数 +hogehoge = gensim.models.Word2Vec.load('./ja/ja.bin') #データベース読み込み +print(hogeword) +print(len(hogeword)) +if len(hogeword) == 6: + UpTab = hogeword[1] + DownTab = hogeword[2] + LeftTab = hogeword[3] + RightTab = hogeword[4] + Word = hogeword[5] + #単語の類似度を表示 + #Y軸の値を算出 + UpAxis = hogehoge.wv.similarity(UpTab,Word) #上下軸の単語と検証する単語の類似性を出す + DownAxis = hogehoge.wv.similarity(DownTab,Word) + DownAxis *= -1 + YAxis = DownAxis + UpAxis /2 + #X軸の値を算出 + LeftAxis = hogehoge.wv.similarity(LeftTab,Word)#左右軸の単語と検証する単語の類似性を出す + RightAxis = hogehoge.wv.similarity(RightTab,Word) + RightAxis *= -1 + XAxis = RightAxis + LeftAxis /2 + #printでY軸 X軸 wordを入力 + print("XY単語",YAxis,XAxis,Word) +else: + print("エラー 入力する単語が多すぎるか少なすぎます") +print("デバッグ",UpAxis,DownAxis,LeftAxis,RightAxis) \ No newline at end of file