forked from cminson/embeddedbible
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenwordmodel.py
More file actions
40 lines (29 loc) · 876 Bytes
/
Copy pathgenwordmodel.py
File metadata and controls
40 lines (29 loc) · 876 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sys
import os
import textinput
import gensim
import string
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent
MODEL_PATH = BASE_DIR / "MODELS"
MODEL_WORDS = 'model.words'
MAX_WORD2VEC_WINDOW = 10
WORD2VEC_SG = 1
WORD2VEC_SIZE = 300
WORD2VEC_MINWORD_COUNT = 1
def build_word_model(word_list):
print('building word models')
model = gensim.models.Word2Vec(word_list,
min_count = WORD2VEC_MINWORD_COUNT,
vector_size = WORD2VEC_SIZE,
window = MAX_WORD2VEC_WINDOW,
sg = WORD2VEC_SG)
print(MODEL_PATH)
MODEL_PATH.mkdir(parents=True, exist_ok=True)
path = MODEL_PATH / f"{MODEL_WORDS}.{MAX_WORD2VEC_WINDOW}"
print(f'Saving word model: {path}')
model.save(str(path))
if __name__ == '__main__':
textinput.load_bible()
build_word_model(textinput.AllStoppedWords)
print('done')