-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsandhi.py
34 lines (23 loc) · 981 Bytes
/
sandhi.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
import json
sandhi_data = json.load(open("./data/sandhi.json", "r"))
def sandhi(x):
return sandhi_data.get(x, " | sandhi error | ")
def make_it(x, y):
if x[len(x) - 2:] == "ai" or x[len(x) - 2:] == "au":
if y[0:2] == "ai" or y[0:2] == "au":
join = sandhi(x[len(x) - 2:] + " " + y[0:2])
return(x[0:len(x) - 2] + join + y[2:])
else:
join = sandhi(x[len(x) - 2:] + " " + y[0])
return(x[0:len(x) - 2] + join + y[1:])
elif y[0:2] == "ai" or y[0:2] == "au":
if x[len(x) - 2:] == "ai" or x[len(x) - 2:] == "au":
join = sandhi(x[len(x) - 2:] + " " + y[0:2])
return(x[0:len(x) - 2] + join + y[2:])
else:
join = sandhi(x[len(x) - 1:] + " " + y[0:2])
return(x[0:len(x) - 1] + join + y[2:])
else:
join = sandhi(x[len(x) - 1:] + " " + y[0])
return(x[0:len(x) - 1] + join + y[1:])
print(make_it("gacchatai", "auśvaraḥ"))