コード例 #1
0
def main(headers,fileout):
 empty_conj = ['nil' for i in xrange(0,9)]
 empty_tab = '[' + (' '.join(empty_conj)) + ']' # string form
 fout = open(fileout,"w")
 nin = 0
 nout=0
 for rec in headers:
  nin = nin + 1
  if nin > 10:
   #print "DEBUG. stop after",nin
   #break
   pass
  root = rec.stem
  theclass = rec.theclass
  voice = pada_to_voice(rec.pada)
  #tense = htense_to_slptense(rec.tense)
  tense = rec.tense
  dtype = None # or 'c' for causal
  temp=None
  if sanskritverb_flag:
   if (root in ["kfRv","Dinv","Sru"]) and (theclass=='1'):
    # These roots are called class 1 in sanskritverb, but their
    # present tense conjugations (at least) are like class 5 roots
    # For kfRv, Dinv see: https://github.com/funderburkjim/elispsanskrit/issues/47#issuecomment-249459765
    # for Sru, see: ?
    dtemp = {'kfRv':'kf','Dinv':'Di','Sru':'Sf'}
    root1 = dtemp[root]
    theclass1 = '5'
    temp = pysan_conj(root1,theclass1,voice,tense,dtype,dbg=False)
   elif (root == 'akz') and (theclass=='1'):
    # SanskritVerb provides a normal class 1 and a class 5 conjugation
    temp1a = pysan_conj(root,theclass,voice,tense,dtype,dbg=False)
    
    temp1 = temp1a.split(':')[-1]
    theclass1 = '5'
    root1 = root
    temp2a = pysan_conj(root1,theclass1,voice,tense,dtype,dbg=False)
    temp2 = temp2a.split(':')[-1]
    # merge the two
    temp3 = conjstr_join(temp1,temp2)
    temp = ":" + temp3 # see split statement below for why the ':'
  if temp == None: # the usual case, no adjustment
   temp = pysan_conj(root,theclass,voice,tense,dtype,dbg=False)
  if temp == None:
   tab = empty_tab
  else:
   parts = temp.split(':')
   tab = parts[-1]
  out = '%s:%s' %(rec.head,tab)
  fout.write('%s\n' % out)
  nout = nout + 1
 fout.close()
 print nout,'lines written to',fileout
コード例 #2
0
def main(filein,fileout):
 empty_conj = ['nil' for i in xrange(0,9)]
 empty_tab = '[' + (' '.join(empty_conj)) + ']' # string form
 f = codecs.open(filein,"r","utf-8")
 fout = codecs.open(fileout,"w","utf-8")
 nin = 0
 nout=0
 for line in f:
  line = line.rstrip('\r\n')
  nin = nin + 1
  if line == '':
   continue
  if nin > 10:
   #print "DEBUG. stop after",nin
   #break
   pass
  rec = Input(line)
  root = rec.stem
  theclass = rec.theclass
  voice = pada_to_voice(rec.pada)
  tense = htense_to_slptense(rec.tense)
  dtype = None # or 'c' for causal
  if theclass == '11':
   tab = empty_tab
  else:
   temp = pysan_conj(root,theclass,voice,tense,dtype,dbg=False)
   if temp == None:
    tab = empty_tab
   else:
    parts = temp.split(':')
    tab = parts[-1]
  out = '%s:%s' %(rec.head,tab)
  fout.write('%s\n' % out)
  nout = nout + 1
  continue
  #print "dictstr=",dictstr,"\ndictwords=",dictwords
  for g in genderstr:
   try:
    (key1,key2) = deduce_gender_stem(subanta,words1,g,genderstr,rec.mwtype)
    outputs = s_file_init_alt_helper(key1,g,key2,dbg=dbg)
   except (NameError,MyException) as err:
    print "\ncase=",nin,"line=",line
    print err
    outputs = None
   if isinstance(outputs,list):
    #print "outputs is a list of length",len(outputs)
    pass
   elif outputs == None:
    outputs = []
   elif  ';' in outputs: ##outputs.startswith(':adj'):
    outputs = outputs.split(';')
   else:
    #print "outputs is not a list"
    outputs = [outputs]
   for output in outputs:
    # change form so comparable with huet_noun_tables.txt
    (p0,p1,p2,p3,decl) = output.split(':')
    output1 = "%s %s:%s" %(subanta,g,decl)
    fout.write("%s\n" % output1)
    nout = nout + 1
   if len(outputs) == 0:
    decl0 = ['nil' for i in xrange(0,24)]
    decl = '[' + (' '.join(decl0)) + ']'
    output1 = "%s %s:%s" %(subanta,g,decl)
    fout.write("%s\n" % output1)
    nout = nout + 1
 f.close()
 fout.close()
 print nout,'lines written to',fileout
コード例 #3
0
def main(headers, fileout):
    empty_conj = ['nil' for i in xrange(0, 9)]
    empty_tab = '[' + (' '.join(empty_conj)) + ']'  # string form
    fout = open(fileout, "w")
    nin = 0
    nout = 0
    for rec in headers:
        nin = nin + 1
        if nin > 10:
            #print "DEBUG. stop after",nin
            #break
            pass
        root = rec.stem
        theclass = rec.theclass
        voice = pada_to_voice(rec.pada)
        #tense = htense_to_slptense(rec.tense)
        tense = rec.tense
        dtype = None  # or 'c' for causal
        temp = None
        if sanskritverb_flag:
            if (root in ["kfRv", "Dinv", "Sru"]) and (theclass == '1'):
                # These roots are called class 1 in sanskritverb, but their
                # present tense conjugations (at least) are like class 5 roots
                # For kfRv, Dinv see: https://github.com/funderburkjim/elispsanskrit/issues/47#issuecomment-249459765
                # for Sru, see: ?
                dtemp = {'kfRv': 'kf', 'Dinv': 'Di', 'Sru': 'Sf'}
                root1 = dtemp[root]
                theclass1 = '5'
                temp = pysan_conj(root1,
                                  theclass1,
                                  voice,
                                  tense,
                                  dtype,
                                  dbg=False)
            elif (root == 'akz') and (theclass == '1'):
                # SanskritVerb provides a normal class 1 and a class 5 conjugation
                temp1a = pysan_conj(root,
                                    theclass,
                                    voice,
                                    tense,
                                    dtype,
                                    dbg=False)

                temp1 = temp1a.split(':')[-1]
                theclass1 = '5'
                root1 = root
                temp2a = pysan_conj(root1,
                                    theclass1,
                                    voice,
                                    tense,
                                    dtype,
                                    dbg=False)
                temp2 = temp2a.split(':')[-1]
                # merge the two
                temp3 = conjstr_join(temp1, temp2)
                temp = ":" + temp3  # see split statement below for why the ':'
        if temp == None:  # the usual case, no adjustment
            temp = pysan_conj(root, theclass, voice, tense, dtype, dbg=False)
        if temp == None:
            tab = empty_tab
        else:
            parts = temp.split(':')
            tab = parts[-1]
        out = '%s:%s' % (rec.head, tab)
        fout.write('%s\n' % out)
        nout = nout + 1
    fout.close()
    print nout, 'lines written to', fileout
コード例 #4
0
def main(filein, fileout):
    empty_conj = ['nil' for i in xrange(0, 9)]
    empty_tab = '[' + (' '.join(empty_conj)) + ']'  # string form
    f = codecs.open(filein, "r", "utf-8")
    fout = codecs.open(fileout, "w", "utf-8")
    nin = 0
    nout = 0
    for line in f:
        line = line.rstrip('\r\n')
        nin = nin + 1
        if line == '':
            continue
        if nin > 10:
            #print "DEBUG. stop after",nin
            #break
            pass
        rec = Input(line)
        root = rec.stem
        theclass = rec.theclass
        voice = pada_to_voice(rec.pada)
        tense = htense_to_slptense(rec.tense)
        dtype = None  # or 'c' for causal
        if theclass == '11':
            tab = empty_tab
        else:
            temp = pysan_conj(root, theclass, voice, tense, dtype, dbg=False)
            if temp == None:
                tab = empty_tab
            else:
                parts = temp.split(':')
                tab = parts[-1]
        out = '%s:%s' % (rec.head, tab)
        fout.write('%s\n' % out)
        nout = nout + 1
        continue
        #print "dictstr=",dictstr,"\ndictwords=",dictwords
        for g in genderstr:
            try:
                (key1, key2) = deduce_gender_stem(subanta, words1, g,
                                                  genderstr, rec.mwtype)
                outputs = s_file_init_alt_helper(key1, g, key2, dbg=dbg)
            except (NameError, MyException) as err:
                print "\ncase=", nin, "line=", line
                print err
                outputs = None
            if isinstance(outputs, list):
                #print "outputs is a list of length",len(outputs)
                pass
            elif outputs == None:
                outputs = []
            elif ';' in outputs:  ##outputs.startswith(':adj'):
                outputs = outputs.split(';')
            else:
                #print "outputs is not a list"
                outputs = [outputs]
            for output in outputs:
                # change form so comparable with huet_noun_tables.txt
                (p0, p1, p2, p3, decl) = output.split(':')
                output1 = "%s %s:%s" % (subanta, g, decl)
                fout.write("%s\n" % output1)
                nout = nout + 1
            if len(outputs) == 0:
                decl0 = ['nil' for i in xrange(0, 24)]
                decl = '[' + (' '.join(decl0)) + ']'
                output1 = "%s %s:%s" % (subanta, g, decl)
                fout.write("%s\n" % output1)
                nout = nout + 1
    f.close()
    fout.close()
    print nout, 'lines written to', fileout