22,6 → 22,7 |
|
import tsimapiak.dbconnector as dbconnector |
import tsimapiak.parsenum as parsenum |
import itertools |
import re |
|
#wordlist = [{"id": 0, "navi": u"tawtute", "infix": u"tawtute", "type": u"n."}] + dbconnector.getnavilist() + [{"id": 0, "navi": u"na'vi", "infix": u"na'vi", "type": u"n."}] # XXX HACK - extra proper nouns |
88,11 → 89,35 |
# Let's lenit the dictionary |
extrawords = [] |
for word in wordlist: |
for letter, replacement in LENIT: |
if word["navi"].startswith(letter): |
new_word = word["navi"].replace(letter, replacement, 1) |
new_infix = word["infix"].replace(letter, replacement, 1) |
extrawords.append({"id": word["id"], "navi": new_word, "infix": new_infix, "type": word["type"], "lenited": True}) |
splitword = word["navi"].split(" ") |
splitinfix = word["infix"].split(" ") |
lenitword = {} |
lenitinfix = {} |
for i, wor in enumerate(splitword): |
for letter, replacement in LENIT: |
if wor.startswith(letter): |
lenitword[i] = wor.replace(letter, replacement, 1) |
lenitinfix[i] = splitinfix[i].replace(letter, replacement, 1) |
break |
|
s = list(lenitword.keys()) |
for lenits in itertools.chain.from_iterable(itertools.combinations(s, r) for r in range(1, len(s)+1)): |
new_word = "" |
new_infix = "" |
for i, wor in enumerate(splitword): |
if i in lenits: |
new_word += lenitword[i] |
new_infix += lenitinfix[i] |
else: |
new_word += wor |
new_infix += splitinfix[i] |
new_word += " " |
new_infix += " " |
print(f"Generated lenited {new_word} from {word['navi']}") |
new_word = new_word[:-1] |
new_infix = new_infix[:-1] |
extrawords.append({"id": word["id"], "navi": new_word, "infix": new_infix, "type": word["type"], "lenited": True}) |
|
wordlist = sorted(wordlist + extrawords, key=lambda x: len(x["navi"]) * 2 + (0 if x["lenited"] else 1), reverse=True) |
|
def parseword(wordin): |