def v_file_init_alt1_aorvar(intab, indir, outtab, outdir, n1, n2, tensecode, voicecode): """ Read from file like construct/dcpforms-MW.txt, and write information for each line to output outdir/outtab Determine aorist varieties Sample records are: (Ap 5 P <MW=Ap,35737,1>) (As 2 A <MW=As,39445,1>) (BA 2 A <MW=vy-ati-BA,262287,1>) NOTE: Uses aorist_varieties function. In this function, the 'pada' is assumed to be a lower case 'p' (parasmaipada) or 'a' (atmanepada). I mention this since we are, in particular, NOT using the Scharf convention of 'a' (for active voice, same as parasmaipada) or 'm' (for middle voice, same as atmanepada). """ nin = 0 nout = 0 filein = "%s/%s" % (indir, intab) fileout = "%s/%s" % (outdir, outtab) f = codecs.open(filein, "r", "utf-8") fout = codecs.open(fileout, "w", "utf-8") # phase 1 roots = {} rootlist = [] dbg = False dbg1 = True dbg1 = False for line in f: line = line.rstrip('\r\n') if line == '': continue m = re.search(r'\((.*?)<', line) if not m: print "PROBLEM WITH INPUT LINE:", line exit(1) temp = m.group(1).strip() #print "temp=",temp words = temp.split(' ') #print "words=",words (root, theclass, pada) = words # voice is used only in output, for comparision with Elisp output if pada == 'P': voice = 'a' else: voice = 'm' nin = nin + 1 if not ((n1 <= nin) and (nin <= n2)): continue upasargas = None pada1 = pada.lower() aorvars = aorist_varieties(root, theclass, pada1, upasargas, dbg) if aorvars == None: aorvars = [] output1 = "(" + (' '.join(aorvars)) + ")" output = ':%s %s %s%s:%s' % (root, "aorvars", theclass, voice, output1) fout.write("%s\n" % output) nout = nout + 1 if dbg1: pass fout.close()
def v_file_init_alt1_aorvar(intab,indir,outtab,outdir,n1,n2,tensecode,voicecode): """ Read from file like construct/dcpforms-MW.txt, and write information for each line to output outdir/outtab Determine aorist varieties Sample records are: (Ap 5 P <MW=Ap,35737,1>) (As 2 A <MW=As,39445,1>) (BA 2 A <MW=vy-ati-BA,262287,1>) NOTE: Uses aorist_varieties function. In this function, the 'pada' is assumed to be a lower case 'p' (parasmaipada) or 'a' (atmanepada). I mention this since we are, in particular, NOT using the Scharf convention of 'a' (for active voice, same as parasmaipada) or 'm' (for middle voice, same as atmanepada). """ nin = 0 nout = 0 filein = "%s/%s" %(indir,intab) fileout = "%s/%s" %(outdir,outtab) f = codecs.open(filein,"r","utf-8") fout = codecs.open(fileout,"w","utf-8") # phase 1 roots = {} rootlist=[] dbg=False dbg1=True dbg1=False for line in f: line = line.rstrip('\r\n') if line == '': continue m = re.search(r'\((.*?)<',line) if not m: print "PROBLEM WITH INPUT LINE:",line exit(1) temp = m.group(1).strip() #print "temp=",temp words =temp.split(' ') #print "words=",words (root,theclass,pada) = words # voice is used only in output, for comparision with Elisp output if pada == 'P': voice = 'a' else: voice = 'm' nin = nin + 1 if not ((n1 <= nin) and (nin <= n2)): continue upasargas = None pada1 = pada.lower() aorvars=aorist_varieties(root,theclass,pada1,upasargas,dbg) if aorvars == None: aorvars = [] output1 = "(" + (' '.join(aorvars)) + ")" output = ':%s %s %s%s:%s' %(root,"aorvars",theclass,voice,output1) fout.write("%s\n" % output) nout = nout + 1 if dbg1: pass fout.close()
def v_file_init_alt1_aor(intab, indir, outtab, outdir, n1, n2, tensecode, voicecode): """ Read from file like construct/dcpforms-MW.txt, and write information for each line to output outdir/outtab Determine aorist varieties, and for each variety, compute the conjugation of that variety with the given root, class, voice as read from input Sample records are: (Ap 5 P <MW=Ap,35737,1>) (As 2 A <MW=As,39445,1>) (BA 2 A <MW=vy-ati-BA,262287,1>) NOTE: Uses aorist_varieties function. In this function, the 'pada' is assumed to be a lower case 'p' (parasmaipada) or 'a' (atmanepada). I mention this since we are, in particular, NOT using the Scharf convention of 'a' (for active voice, same as parasmaipada) or 'm' (for middle voice, same as atmanepada). """ nin = 0 nout = 0 filein = "%s/%s" % (indir, intab) fileout = "%s/%s" % (outdir, outtab) f = codecs.open(filein, "r", "utf-8") fout = codecs.open(fileout, "w", "utf-8") # phase 1 roots = {} rootlist = [] dbg = False dbg1 = True dbg1 = False for line in f: line = line.rstrip('\r\n') if line == '': continue m = re.search(r'\((.*?)<', line) if not m: print "PROBLEM WITH INPUT LINE:", line exit(1) temp = m.group(1).strip() #print "temp=",temp words = temp.split(' ') #print "words=",words (root, theclass, pada) = words # voice is used only in output, for comparision with Elisp output if pada == 'P': voice = 'a' else: voice = 'm' nin = nin + 1 if not ((n1 <= nin) and (nin <= n2)): continue upasargas = None pada1 = pada.lower() aorvars = aorist_varieties(root, theclass, pada1, upasargas, dbg) if aorvars == None: aorvars = [] for aorvar in aorvars: tense = "aor%s" % aorvar dtype = None #print "v_file_init_alt1_pre_helper(%s,%s,%s,%s,%s)" %(root,theclass,voice,tense,dtype) try: outputs = v_file_init_alt1_pre_helper(root, theclass, voice, tense, dtype=dtype, dbg=dbg) except (NameError, MyException) as err: print "\ncase=", nin, "line=", line, "tense=", tense print err continue if isinstance(outputs, list): #print "outputs is a list of length",len(outputs) pass elif outputs == None: continue else: #print "outputs is not a list" outputs = [outputs] for output in outputs: fout.write("%s\n" % output) nout = nout + 1 if len(outputs) == 0: print "Warning(no result)", root, theclass, voice, tense f.close() fout.close()
def v_file_init_alt1_aor(intab,indir,outtab,outdir,n1,n2,tensecode,voicecode): """ Read from file like construct/dcpforms-MW.txt, and write information for each line to output outdir/outtab Determine aorist varieties, and for each variety, compute the conjugation of that variety with the given root, class, voice as read from input Sample records are: (Ap 5 P <MW=Ap,35737,1>) (As 2 A <MW=As,39445,1>) (BA 2 A <MW=vy-ati-BA,262287,1>) NOTE: Uses aorist_varieties function. In this function, the 'pada' is assumed to be a lower case 'p' (parasmaipada) or 'a' (atmanepada). I mention this since we are, in particular, NOT using the Scharf convention of 'a' (for active voice, same as parasmaipada) or 'm' (for middle voice, same as atmanepada). """ nin = 0 nout = 0 filein = "%s/%s" %(indir,intab) fileout = "%s/%s" %(outdir,outtab) f = codecs.open(filein,"r","utf-8") fout = codecs.open(fileout,"w","utf-8") # phase 1 roots = {} rootlist=[] dbg=False dbg1=True dbg1=False for line in f: line = line.rstrip('\r\n') if line == '': continue m = re.search(r'\((.*?)<',line) if not m: print "PROBLEM WITH INPUT LINE:",line exit(1) temp = m.group(1).strip() #print "temp=",temp words =temp.split(' ') #print "words=",words (root,theclass,pada) = words # voice is used only in output, for comparision with Elisp output if pada == 'P': voice = 'a' else: voice = 'm' nin = nin + 1 if not ((n1 <= nin) and (nin <= n2)): continue upasargas = None pada1 = pada.lower() aorvars=aorist_varieties(root,theclass,pada1,upasargas,dbg) if aorvars == None: aorvars = [] for aorvar in aorvars: tense = "aor%s" % aorvar dtype = None #print "v_file_init_alt1_pre_helper(%s,%s,%s,%s,%s)" %(root,theclass,voice,tense,dtype) try: outputs = v_file_init_alt1_pre_helper(root,theclass,voice,tense,dtype=dtype,dbg=dbg) except (NameError,MyException) as err: print "\ncase=",nin,"line=",line,"tense=",tense print err continue if isinstance(outputs,list): #print "outputs is a list of length",len(outputs) pass elif outputs == None: continue else: #print "outputs is not a list" outputs = [outputs] for output in outputs: fout.write("%s\n" % output) nout = nout + 1 if len(outputs) == 0: print "Warning(no result)",root,theclass,voice,tense f.close() fout.close()