Subversion Repositories navi

Compare Revisions

Ignore whitespace Rev 90 → Rev 91

/tsimapiak/parse2.py
10,10 → 10,12
infixes2 = [u"ìyev", u"iyev", u"ìmìy", u"arm", u"asy", u"ilv", u"ìmv", u"imv", u"ìrm", u"irv", u"ìsy", u"aly", u"ary", u"ìly", u"ìry", u"ìlm", u"alm", u"am", u"ay", u"er", u"ìm", u"iv", u"ìy", u"ol", u""]
infixes3 = [u"äng", u"ats", u"eiy", u"ei", u"uy", u""]
prefixes = [u"tsay", u"fay", u"tsa", u"fra", u"pxe", u"ay", u"me", u"pe", u"le", u"nì", u"sä", u"tì", u"ke", u"fì", u"a"]
postfixes = [u"eyä", u"ìri", u"an", u"ìl", u"it", u"lo", u"ng", u"ri", u"ru", u"ti", u"ur", u"ve", u"yä", u"ya", u"tu", u"vi", u"yu", u"e", u"l", u"o", u"t", u"y", u"a", u"ä"]
postfixes = [u"tsyìp", u"eyä", u"ìri", u"an", u"ìl", u"it", u"lo", u"ng", u"ri", u"ru", u"ti", u"ur", u"ve", u"yä", u"ya", u"tu", u"vi", u"yu", u"e", u"l", u"o", u"t", u"y", u"a", u"ä"]
#prefixesn = ur"(?P<npr>(?:(?:fì|tsa)?(?:me|pxe|ay|fra)?|(?:fay)?|(?:tsay)?)(?:fne)?(?:tì|sä)?"
#prefixesv = ur"(?P<vpr>(?:nì|sä|tì|rä'ä |ke )?)"
 
lenit = ((u"px", u"p"), (u"tx", u"t"), (u"kx", u"k"), (u"ts", u"s"), (u"t", u"s"), (u"p", u"f"), (u"k", u"h"), (u"'", u""))
 
def parseword(wordin):
ret = {"word": {"id": 0, "navi": u"[" + wordin[0] + u"]", "infix": u"", "type": u""}}
for word in wordlist:
46,21 → 48,37
else:
if splitword[wor] in wordin[wor]:
center = splitword[wor]
else:
for i in lenit:
if splitword[wor].startswith(i[0]):
splitword[wor][:len(i[0])] = i[1]
if splitword[wor] in wordin[wor]:
center = splitword[wor]
 
if center == u"":
foundit = False
break
pref, posf = wordin[wor].split(center)
for pre in prefixes:
if pref.endswith(pre):
foundprefs[wor].append(pre)
pref = pref[:-len(pre)]
temp = wordin[wor].split(center)
if len(temp) != 2:
foundit = False
break
pref, posf = temp
last = u""
while pref != last:
last = pref
for pre in prefixes:
if pref.endswith(pre):
foundprefs[wor].append(pre)
pref = pref[:-len(pre)]
if pref != u"":
foundit = False
break
for pos in postfixes:
if posf.startswith(pos):
foundposts[wor].append(pos)
posf = posf[len(pos):]
last = u""
while posf != last:
for pos in postfixes:
if posf.startswith(pos):
foundposts[wor].append(pos)
posf = posf[len(pos):]
if posf != u"":
foundit = False
break
76,7 → 94,7
 
def parsesent(sent):
sent = sent.strip().lower()
sent = re.sub(ur"[^\w ]",u"",sent)
sent = re.sub(ur"[^\wìä ]",u"",sent)
sent = re.sub(ur"\ +",u" ",sent)
sent = sent.split(u" ")
ret = []