def unused_pysan_parse_feminine(key1,tabstr): """ Example: This ununsed for prmp. It is only used for prap. :prap ard-6 f:(ardatI ardantI):(ardatI ardantI):[(ardatI ardantI) (ardatyO ardantyO) (ardatyaH ardantyaH) (ardatIm ardantIm) (ardatyO ardantyO) (ardatIH ardantIH) (ardatyA ardantyA) (ardatIByAm ardantIByAm) (ardatIBiH ardantIBiH) (ardatyE ardantyE) (ardatIByAm ardantIByAm) (ardatIByaH ardantIByaH) (ardatyAH ardantyAH) (ardatIByAm ardantIByAm) (ardatIByaH ardantIByaH) (ardatyAH ardantyAH) (ardatyoH ardantyoH) (ardatInAm ardantInAm) (ardatyAm ardantyAm) (ardatyoH ardantyoH) (ardatIzu ardantIzu) (ardati ardanti) (ardatyO ardantyO) (ardatyaH ardantyaH)] """ stems = key1[1:-1].split(' ') # drop initial '(' and final ')' stems.sort() # since declstr_listify sorts (see below) if len(stems) != 2: print "pysan_parse_feminine error 0:%s"%key1 exit(1) (stem1,stem2) = stems assert (stem1.endswith('ntI') and stem2.endswith('tI')),"pysan_parse_feminine error 1:%s"%key1 s1 = stem1[0:-1] # drop final 'I' s2 = stem2[0:-1] tabold = declstr_listify(tabstr) tab1=[] tab2=[] for t in tabold: t = list(t) t.sort() (f1,f2)=t assert (f1.startswith(s1) and f2.startswith(s2)),"pysan_parse_feminine error 2:(%s,%s)" %(f1,f2) tab1.append([f1]) tab2.append([f2]) # convert back to strings tab1str = prettify(tab1) tab2str = prettify(tab2) """ print "stem1=%s,\ntab1=%s\ntab1str=%s"%(stem1,tab1,tab1str) print "stem2=%s,\ntab2=%s\ntab2str=%s"%(stem2,tab2,tab2str) exit(1) """ ans=[(s1,tab1str),(s1,tab2str)] #print ans return ans
def pysan_parse_feminine(key1, tabstr): """ Example: :fap aMS-10 f:(aMSApayizyatI aMSApayizyantI):(aMSApayizyatI aMSApayizyantI):[(aMSApayizyatI aMSApayizyantI) (aMSApayizyatyO aMSApayizyantyO) (aMSApayizyatyaH aMSApayizyantyaH) (aMSApayizyatIm aMSApayizyantIm) (aMSApayizyatyO aMSApayizyantyO) (aMSApayizyatIH aMSApayizyantIH) (aMSApayizyatyA aMSApayizyantyA) (aMSApayizyatIByAm aMSApayizyantIByAm) (aMSApayizyatIBiH aMSApayizyantIBiH) (aMSApayizyatyE aMSApayizyantyE) (aMSApayizyatIByAm aMSApayizyantIByAm) (aMSApayizyatIByaH aMSApayizyantIByaH) (aMSApayizyatyAH aMSApayizyantyAH) (aMSApayizyatIByAm aMSApayizyantIByAm) (aMSApayizyatIByaH aMSApayizyantIByaH) (aMSApayizyatyAH aMSApayizyantyAH) (aMSApayizyatyoH aMSApayizyantyoH) (aMSApayizyatInAm aMSApayizyantInAm) (aMSApayizyatyAm aMSApayizyantyAm) (aMSApayizyatyoH aMSApayizyantyoH) (aMSApayizyatIzu aMSApayizyantIzu) (aMSApayizyati aMSApayizyanti) (aMSApayizyatyO aMSApayizyantyO) (aMSApayizyatyaH aMSApayizyantyaH)] """ stems = key1[1:-1].split(" ") # drop initial '(' and final ')' stems.sort() # since declstr_listify sorts (see below) if len(stems) != 2: print "pysan_parse_feminine error 0:%s" % key1 exit(1) (stem1, stem2) = stems assert stem1.endswith("ntI") and stem2.endswith("tI"), "pysan_parse_feminine error 1:%s" % key1 s1 = stem1[0:-1] # drop final 'I' s2 = stem2[0:-1] tabold = declstr_listify(tabstr) tab1 = [] tab2 = [] for t in tabold: t = list(t) t.sort() (f1, f2) = t assert f1.startswith(s1) and f2.startswith(s2), "pysan_parse_feminine error 2:(%s,%s)" % (f1, f2) tab1.append([f1]) tab2.append([f2]) # convert back to strings tab1str = prettify(tab1) tab2str = prettify(tab2) """ print "stem1=%s,\ntab1=%s\ntab1str=%s"%(stem1,tab1,tab1str) print "stem2=%s,\ntab2=%s\ntab2str=%s"%(stem2,tab2,tab2str) exit(1) """ ans = [(s2, tab1str), (s2, tab2str)] # print ans # exit(1) return ans
def pysan_parse_feminine(key1, tabstr): """ Example: :fap aMS-10 f:(aMSApayizyatI aMSApayizyantI):(aMSApayizyatI aMSApayizyantI):[(aMSApayizyatI aMSApayizyantI) (aMSApayizyatyO aMSApayizyantyO) (aMSApayizyatyaH aMSApayizyantyaH) (aMSApayizyatIm aMSApayizyantIm) (aMSApayizyatyO aMSApayizyantyO) (aMSApayizyatIH aMSApayizyantIH) (aMSApayizyatyA aMSApayizyantyA) (aMSApayizyatIByAm aMSApayizyantIByAm) (aMSApayizyatIBiH aMSApayizyantIBiH) (aMSApayizyatyE aMSApayizyantyE) (aMSApayizyatIByAm aMSApayizyantIByAm) (aMSApayizyatIByaH aMSApayizyantIByaH) (aMSApayizyatyAH aMSApayizyantyAH) (aMSApayizyatIByAm aMSApayizyantIByAm) (aMSApayizyatIByaH aMSApayizyantIByaH) (aMSApayizyatyAH aMSApayizyantyAH) (aMSApayizyatyoH aMSApayizyantyoH) (aMSApayizyatInAm aMSApayizyantInAm) (aMSApayizyatyAm aMSApayizyantyAm) (aMSApayizyatyoH aMSApayizyantyoH) (aMSApayizyatIzu aMSApayizyantIzu) (aMSApayizyati aMSApayizyanti) (aMSApayizyatyO aMSApayizyantyO) (aMSApayizyatyaH aMSApayizyantyaH)] """ stems = key1[1:-1].split(' ') # drop initial '(' and final ')' stems.sort() # since declstr_listify sorts (see below) if len(stems) != 2: print "pysan_parse_feminine error 0:%s" % key1 exit(1) (stem1, stem2) = stems assert (stem1.endswith('ntI') and stem2.endswith('tI')), "pysan_parse_feminine error 1:%s" % key1 s1 = stem1[0:-1] # drop final 'I' s2 = stem2[0:-1] tabold = declstr_listify(tabstr) tab1 = [] tab2 = [] for t in tabold: t = list(t) t.sort() (f1, f2) = t assert (f1.startswith(s1) and f2.startswith(s2) ), "pysan_parse_feminine error 2:(%s,%s)" % (f1, f2) tab1.append([f1]) tab2.append([f2]) # convert back to strings tab1str = prettify(tab1) tab2str = prettify(tab2) """ print "stem1=%s,\ntab1=%s\ntab1str=%s"%(stem1,tab1,tab1str) print "stem2=%s,\ntab2=%s\ntab2str=%s"%(stem2,tab2,tab2str) exit(1) """ ans = [(s2, tab1str), (s2, tab2str)] #print ans #exit(1) return ans
def update(self, cpm, tabstr): if cpm not in self.cpms: self.cpms.append(cpm) self.tables[cpm] = tabstr else: # handle duplicates toldstr = self.tables[cpm] told = declstr_listify(toldstr) tnew = declstr_listify(tabstr) for i in xrange(0, len(told)): old = told[i] # a list of strings new = tnew[i] # ditto for x in new: if x not in old: old.append(x) told[i] = old self.tables[cpm] = prettify(told)
def update(self,cpm,tabstr): if cpm not in self.cpms: self.cpms.append(cpm) self.tables[cpm] = tabstr else: # handle duplicates toldstr = self.tables[cpm] told = declstr_listify(toldstr) tnew = declstr_listify(tabstr) for i in xrange(0,len(told)): old = told[i] # a list of strings new = tnew[i] # ditto for x in new: if x not in old: old.append(x) told[i] = old self.tables[cpm] = prettify(told)