31,6 → 31,15 |
u"pukap", |
u"kinä"] |
|
NUMLEN = [u"hew", |
u"aw", |
u"mune", |
u"pey", |
u"sìng", |
u"mrr", |
u"fukap", |
u"hinä"] |
|
NUMORD = [u"kew", |
u"'aw", |
u"mu", |
40,6 → 49,15 |
u"pu", |
u"ki"] |
|
NUMORDLEN = [u"hew", |
u"aw", |
u"mu", |
u"pey", |
u"sì", |
u"mrr", |
u"fu", |
u"hi"] |
|
REM = [u"aw", |
u"mun", |
u"pey", |
64,19 → 82,31 |
u"pu", |
u"ki"] |
|
BASELEN = [u"", |
u"me", |
u"pe", |
u"sì", |
u"mrr", |
u"fu", |
u"hi"] |
|
def parse(numin): |
if u"mm" in numin: |
return None |
if (numin == u"") or ((numin[0] == u"a") and (numin[len(numin) - 1] == u"a")): |
if (numin == u"") or len(numin) == 1 or ((numin[0] == u"a" and numin[1] != "w") and (numin[len(numin) - 1] == u"a")): |
return None |
prefs = [] |
posts = [] |
outoct = 0 |
outdec = 0 |
ret = {"word": {"id": 0, "navi": u"", "infix": u"", "type": u""}, "pref": [prefs], "post": [posts], "inf": [u"", u"", u""], "len": False, "dec": outdec, "oct": outoct} |
if numin[0] == u"a": |
frac = False |
ret = {"word": {"id": 0, "navi": u"", "orig_navi": "", "infix": u"", "type": u""}, "pref": [prefs], "post": [posts], "inf": [u"", u"", u""], "len": False, "dec": outdec, "oct": outoct} |
if numin[0] == u"a" and len(numin) > 1 and numin[1] != "w": |
prefs.append((u"a", "a")) |
numin = numin[1:] |
elif numin[0:2] == "nì": |
prefs.append(("nì", "nì")) |
numin = numin[2:] |
if numin[len(numin) - 1] == u"a": |
posts.append((u"a", None)) |
numin = numin[:-1] |
83,7 → 113,21 |
if numin[-2:] == u"ve": |
posts.append((u"ve", None)) |
numin = numin[:-2] |
if numin[-3:] == u"pxì": |
posts.append((u"pxì", None)) |
numin = numin[:-3] |
|
# Special fractions |
if numin in ("mawl", "pan", "fan"): |
outoct = 2 if numin == "mawl" else 3 |
outdec = 2 if numin == "mawl" else 3 |
ret["word"]["navi"] = "1/" + str(outdec) |
ret["word"]["orig_navi"] = "mawl" if numin == "mawl" else "pan" |
ret["dec"] = outdec |
ret["oct"] = outoct |
ret["len"] = True if numin == "fan" else False |
return ret |
|
#BASE numbers |
for n in range(len(NUM)): |
if (u"ve", None) in posts: |
91,80 → 135,156 |
outoct = n |
outdec = n |
ret["word"]["navi"] = str(outdec) + u"." |
ret["word"]["orig_navi"] = NUMORD[n] |
ret["dec"] = outdec |
ret["oct"] = outoct |
return ret |
if numin == NUMORDLEN[n]: |
outoct = n |
outdec = n |
ret["word"]["navi"] = str(outdec) + u"." |
ret["word"]["orig_navi"] = NUMORD[n] |
ret["dec"] = outdec |
ret["oct"] = outoct |
ret["len"] = True |
return ret |
elif ("pxì", None) in posts and n > 3: |
if numin == NUMORD[n]: |
outoct = n |
outdec = n |
ret["word"]["navi"] = "1/" + str(outdec) |
ret["word"]["orig_navi"] = NUMORD[n] |
ret["dec"] = outdec |
ret["oct"] = outoct |
return ret |
if numin == NUMORDLEN[n]: |
outoct = n |
outdec = n |
ret["word"]["navi"] = "1/" + str(outdec) |
ret["word"]["orig_navi"] = NUMORD[n] |
ret["dec"] = outdec |
ret["oct"] = outoct |
ret["len"] = True |
return ret |
else: |
if numin == NUM[n]: |
outoct = n |
outdec = n |
ret["word"]["navi"] = str(outdec) |
ret["word"]["orig_navi"] = NUM[n] |
ret["dec"] = outdec |
ret["oct"] = outoct |
return ret |
if numin == NUMLEN[n]: |
outoct = n |
outdec = n |
ret["word"]["navi"] = str(outdec) |
ret["word"]["orig_navi"] = NUM[n] |
ret["dec"] = outdec |
ret["oct"] = outoct |
ret["len"] = True |
return ret |
#other numbers |
notbase = False |
orig_navi = "" |
for n in range(len(BASE)): |
if numin.startswith(BASE[n] + u"vozazam"): |
if numin.startswith(BASE[n] + u"vozaza") or (not notbase and numin.startswith(BASELEN[n] + "vozaza")): |
base = BASE[n] |
if not numin.startswith(BASE[n]): |
base = BASELEN[n] |
ret["len"] = True |
outoct += (n + 1) * (10 ** 5) |
outdec += (n + 1) * (8 ** 5) |
if numin[len(BASE[n]) + 6:].startswith(u"mrr") or numin[len(BASE[n]) + 6:].startswith(u"me"): |
numin = numin[len(BASE[n]) + 6:] |
if numin[len(base) + 6:].startswith(u"mrr") or numin[len(base) + 6:].startswith(u"me") or numin[len(base) + 6:].startswith("mu") or not numin[len(base) + 6:].startswith("m"): |
orig_navi += BASE[n] + "vozaza" |
numin = numin[len(base) + 6:] |
else: |
numin = numin[len(BASE[n]) + 7:] |
orig_navi += BASE[n] + "vozazam" |
numin = numin[len(base) + 7:] |
notbase = True |
for n in range(len(BASE)): |
if numin.startswith(BASE[n] + u"zazam"): |
if numin.startswith(BASE[n] + u"zaza") or (not notbase and numin.startswith(BASELEN[n] + "zaza")): |
base = BASE[n] |
if not numin.startswith(BASE[n]): |
base = BASELEN[n] |
ret["len"] = True |
outoct += (n + 1) * (10 ** 4) |
outdec += (n + 1) * (8 ** 4) |
if numin[len(BASE[n]) + 4:].startswith(u"mrr") or numin[len(BASE[n]) + 4:].startswith(u"me"): |
numin = numin[len(BASE[n]) + 4:] |
if numin[len(base) + 4:].startswith(u"mrr") or numin[len(base) + 4:].startswith(u"me") or numin[len(base) + 4:].startswith("mu") or not numin[len(base) + 4:].startswith("m"): |
orig_navi += BASE[n] + "zaza" |
numin = numin[len(base) + 4:] |
else: |
numin = numin[len(BASE[n]) + 5:] |
orig_navi += BASE[n] + "zazam" |
numin = numin[len(base) + 5:] |
notbase = True |
for n in range(len(BASE)): |
if numin.startswith(BASE[n] + u"vozam"): |
if numin.startswith(BASE[n] + u"voza") or (not notbase and numin.startswith(BASELEN[n] + "voza")): |
base = BASE[n] |
if not numin.startswith(BASE[n]): |
base = BASELEN[n] |
ret["len"] = True |
outoct += (n + 1) * (10 ** 3) |
outdec += (n + 1) * (8 ** 3) |
if numin[len(BASE[n]) + 4:].startswith(u"mrr") or numin[len(BASE[n]) + 4:].startswith(u"me"): |
numin = numin[len(BASE[n]) + 4:] |
if numin[len(base) + 4:].startswith(u"mrr") or numin[len(base) + 4:].startswith(u"me") or numin[len(base) + 4:].startswith("mu") or not numin[len(base) + 4:].startswith("m"): |
orig_navi += BASE[n] + "voza" |
numin = numin[len(base) + 4:] |
else: |
numin = numin[len(BASE[n]) + 5:] |
orig_navi += BASE[n] + "vozam" |
numin = numin[len(base) + 5:] |
notbase = True |
for n in range(len(BASE)): |
if numin.startswith(BASE[n] + u"zam"): |
if numin.startswith(BASE[n] + u"za") or (not notbase and numin.startswith(BASELEN[n] + "za")): |
base = BASE[n] |
if not numin.startswith(BASE[n]): |
base = BASELEN[n] |
ret["len"] = True |
outoct += (n + 1) * (10 ** 2) |
outdec += (n + 1) * (8 ** 2) |
if numin[len(BASE[n]) + 2:].startswith(u"mrr") or numin[len(BASE[n]) + 2:].startswith(u"me"): |
numin = numin[len(BASE[n]) + 2:] |
if numin[len(base) + 2:].startswith(u"mrr") or numin[len(base) + 2:].startswith(u"me") or numin[len(base) + 2:].startswith("mu") or not numin[len(base) + 2:].startswith("m"): |
orig_navi += BASE[n] + "za" |
numin = numin[len(base) + 2:] |
else: |
numin = numin[len(BASE[n]) + 3:] |
orig_navi += BASE[n] + "zam" |
numin = numin[len(base) + 3:] |
notbase = True |
for n in range(len(BASE)): |
if numin.startswith(BASE[n] + u"vol"): |
if numin.startswith(BASE[n] + u"vol") or (not notbase and numin.startswith(BASELEN[n] + "vol")): |
base = BASE[n] |
if not numin.startswith(BASE[n]): |
base = BASELEN[n] |
ret["len"] = True |
outoct += (n + 1) * 10 |
outdec += (n + 1) * 8 |
numin = numin[len(BASE[n]) + 3:] |
numin = numin[len(base) + 3:] |
notbase = True |
if numin.startswith(BASE[n] + u"vo"): |
orig_navi += BASE[n] + "vol" |
if numin.startswith(BASE[n] + u"vo") or (not notbase and numin.startswith(BASELEN[n] + "vo")): |
base = BASE[n] |
if not numin.startswith(BASE[n]): |
base = BASELEN[n] |
ret["len"] = True |
outoct += (n + 1) * 10 |
outdec += (n + 1) * 8 |
numin = numin[len(BASE[n]) + 2:] |
numin = numin[len(base) + 2:] |
notbase = True |
orig_navi += BASE[n] + "vo" |
if notbase: |
for n in range(len(REM)): |
if (u"ve", None) in posts: |
if (u"ve", None) in posts or ("pxì", None) in posts: |
if numin == REMORD[n]: |
orig_navi += numin |
outoct += n + 1 |
outdec += n + 1 |
numin = u"" |
else: |
if numin == REM[n]: |
orig_navi += numin |
outoct += n + 1 |
outdec += n + 1 |
numin = u"" |
if numin == u"": |
ret["word"]["navi"] = str(outdec) if not (u"ve", None) in posts else str(outdec) + u"." |
ret["word"]["navi"] = ("" if not ("pxì", None) in posts else "1/") + str(outdec) + ("" if not (u"ve", None) in posts else ".") |
ret["word"]["orig_navi"] = orig_navi |
ret["dec"] = outdec |
ret["oct"] = outoct |
return ret |