-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgemGram665.py
46 lines (35 loc) · 1.21 KB
/
gemGram665.py
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
41
42
43
44
45
46
import nltk
from nltk.tokenize import SyllableTokenizer
import getwordsfromdbs as gwdb
import gemNumFuncs as gnf
import random
import sys
def extract_syllables(word):
syllable_tokenizer = SyllableTokenizer()
return syllable_tokenizer.tokenize(word)
def calculate_gematria(syllable):
return gnf.getGematria(syllable, "ScaExt")
def replace_syllables(word, syllable_list):
syllables = extract_syllables(word)
new_syllables = []
for syllable in syllables:
gematria_value = calculate_gematria(syllable)
matching_syllables = [s for s in syllable_list if calculate_gematria(s) == gematria_value]
new_syllables.append(random.choice(matching_syllables))
return new_syllables
syllable_list=[]
for i in gwdb.getDeepMem():
syllable_list += extract_syllables(i)
words = sys.argv[1].lower()
sentence = words.replace(" ", "")
print(words+" "+str(gnf.getGematria(sentence, "ScaExt"))+" => ")
new_syllables=[]
for i in words.split():
new_syllables += [replace_syllables(i, syllable_list)]
new_word_str=""
for i in new_syllables:
for j in i:
new_word_str+=j
new_word_str+=" "
new_sentence=new_word_str.replace(" ", "")
print (new_word_str+" "+str(gnf.getGematria(new_sentence, "ScaExt")))