Datasets:
File size: 1,504 Bytes
b81a0d5 | 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 | V={'அ':'a','ஆ':'aa','இ':'i','ஈ':'ee','உ':'u','ஊ':'oo','எ':'e','ஏ':'ae','ஐ':'ai','ஒ':'o','ஓ':'oa','ஔ':'au','ஃ':'h'}
C={'க':'k','ங':'ng','ச':'s','ஞ':'nj','ட':'t','ண':'n','த':'th','ந':'n','ப':'p','ம':'m','ய':'y','ர':'r','ல':'l','வ':'v','ழ':'zh','ள':'l','ற':'r','ன':'n','ஜ':'j','ஷ':'sh','ஸ':'s','ஹ':'h','ஶ':'sh'}
S={'ா':'aa','ி':'i','ீ':'ee','ு':'u','ூ':'oo','ெ':'e','ே':'ae','ை':'ai','ொ':'o','ோ':'oa','ௌ':'au','்':''}
D={chr(0x0BE6+i):str(i) for i in range(10)}
def tanglish(s):
out=[];i=0
while i<len(s):
ch=s[i]
if ch in C:
nx=s[i+1] if i+1<len(s) else ''
if nx in S: out.append(C[ch]+S[nx]); i+=2; continue
out.append(C[ch]+'a')
elif ch in V: out.append(V[ch])
elif ch in D: out.append(D[ch])
elif ch in S: out.append(S[ch])
else: out.append(ch)
i+=1
return ''.join(out)
if __name__=="__main__":
import json
from tokenizers import Tokenizer
t=Tokenizer.from_file("toks/Beam.json")
ta={(d["link"]):d["flores_passage"] for d in map(json.loads,open("tam_Taml.jsonl"))}
en={(d["link"]):d["flores_passage"] for d in map(json.loads,open("eng_Latn.jsonl"))}
n=lambda L:sum(len(t.encode(x,add_special_tokens=False).ids) for x in L)
T=list(ta.values()); E=[en[k] for k in ta]
print(tanglish(T[0])[:300])
a,b,c=n(E),n(T),n([tanglish(x) for x in T]); print(a,b,c,b/a,c/a, 1-c/b)
|