Update according to precedent changes

This commit is contained in:
augustin64 2024-10-16 10:27:39 +02:00
parent 8a6b0d0963
commit a2d46b906b
2 changed files with 4 additions and 4 deletions

View File

@ -3,7 +3,7 @@
# Basic use
```bash
python cemantix.py -m <model.bin>
python src/cemantix.py -m <model.bin>
> # input your guess
> # help() to get an hint
> # clear() to remove words that are not useful

View File

@ -17,12 +17,12 @@ def random_word(model, k=5, dist=100):
complete_list += [i[0] for i in model.most_similar(word, topn=dist)]
rk_words = model.rank_by_centrality(complete_list)
return rk_words[random.randint(0,5)][1]
return rk_words[random.randint(0,5)%len(rk_words)][1]
def cemantix(model, word=None):
while word is None or len(word) < 5 or '-' in word or '_' in word:
word = random_word(model, k=1, dist=1) # augment numbers to try a "smooth selection"
word = random_word(model, k=1, dist=0) # augment dist for a "smoother selection"
nearest = [word]+[i[0] for i in model.most_similar(word, topn=1000)]
guesses = [] # guess, temp, rank
@ -96,7 +96,7 @@ def main():
parser.add_argument("-w", "--word", dest="word", action="store",
help="Specify goal word")
parser.add_argument("-m", "--model", dest="model", action="store",
default="frWac_non_lem_no_postag_no_phrase_200_skip_cut100.bin",
default="models/selected_word2vec_model.bin",
help="Specify model to use")
args = parser.parse_args()