def init_verbdata(verbdata_dir): # set relative path to directory containing verbdata.txt sys.path.append(verbdata_dir) import verbdata filein = '%s/verbdata.txt'%verbdata_dir verbrecs = verbdata.init_Dhaval_verbdata(filein) # Now verbrecs is a list of Dhaval_verbdata objects. # A typical element 'rec' of this list has # attributes rec.verbwithanubandha, etc. print len(verbrecs),"records from",filein return verbrecs
def init_verbdata(verbdata_dir): # set relative path to directory containing verbdata.txt sys.path.append(verbdata_dir) import verbdata filein = '%s/verbdata.txt' % verbdata_dir verbrecs = verbdata.init_Dhaval_verbdata(filein) # Now verbrecs is a list of Dhaval_verbdata objects. # A typical element 'rec' of this list has # attributes rec.verbwithanubandha, etc. print len(verbrecs), "records from", filein return verbrecs
status = 'OK' nok = nok + 1 elif cps10 == []: status = 'PROB:no class 10' else: status = '?' if status != 'OK': print "%s:%s:%s"%(root1,cpstr,status) print nok,"records are OK (have exactly 1 class 10, and it is 'A')" if __name__ == "__main__": filein = sys.argv[1] filein1 = sys.argv[2] filein2 = sys.argv[3] recs = verbdata.init_Dhaval_verbdata(filein) print len(recs),"read from",filein # make a dictionary from verbdata, using verbwithanubandha d = {} for rec in recs: root = rec.verbwithanubandha if root not in d: d[root]=[] d[root].append(rec) # check first file with codecs.open(filein1,'r','utf-8') as f: roots1 = [line.rstrip('\r\n') for line in f] print len(roots1),"roots read from",filein1 check(roots1,d) # check second file with codecs.open(filein2,'r','utf-8') as f:
sutrad[sutra]=[] sutrad[sutra].append(verbrec) ncase=0 for sutra,recs in sutrad.items(): if len(recs) > 1: #out = "%s:%s" % (sutra,','.join(dpnorms)) #fout.write(out + "\n") ncase=ncase+1 ndup = len(recs) fout.write('case %02d: sutra %s appears in %s records\n' %(ncase,sutra,ndup)) for verbrec in recs: fout.write('%s\n' % verbrec.line) fout.write('\n') fout.close() print ncase,"duplicate sutra numbers" print "duplicates written to",fileout if __name__ == "__main__": fileout = sys.argv[1] # set relative path to directory containing verbdata.txt path='../function' sys.path.append(path) import verbdata verbrecs = verbdata.init_Dhaval_verbdata('%s/verbdata.txt'%path) # Now verbrecs is a list of Dhaval_verbdata objects. # A typical element 'rec' of this list has # attributes rec.verbwithanubandha, etc. print len(verbrecs) sutra_dup(verbrecs,fileout)
sutrad[sutra].append(verbrec) ncase = 0 for sutra, recs in sutrad.items(): if len(recs) > 1: #out = "%s:%s" % (sutra,','.join(dpnorms)) #fout.write(out + "\n") ncase = ncase + 1 ndup = len(recs) fout.write('case %02d: sutra %s appears in %s records\n' % (ncase, sutra, ndup)) for verbrec in recs: fout.write('%s\n' % verbrec.line) fout.write('\n') fout.close() print ncase, "duplicate sutra numbers" print "duplicates written to", fileout if __name__ == "__main__": fileout = sys.argv[1] # set relative path to directory containing verbdata.txt path = '../function' sys.path.append(path) import verbdata verbrecs = verbdata.init_Dhaval_verbdata('%s/verbdata.txt' % path) # Now verbrecs is a list of Dhaval_verbdata objects. # A typical element 'rec' of this list has # attributes rec.verbwithanubandha, etc. print len(verbrecs) sutra_dup(verbrecs, fileout)
status = 'OK' nok = nok + 1 elif cps10 == []: status = 'PROB:no class 10' else: status = '?' if status != 'OK': print "%s:%s:%s" % (root1, cpstr, status) print nok, "records are OK (have exactly 1 class 10, and it is 'A')" if __name__ == "__main__": filein = sys.argv[1] filein1 = sys.argv[2] filein2 = sys.argv[3] recs = verbdata.init_Dhaval_verbdata(filein) print len(recs), "read from", filein # make a dictionary from verbdata, using verbwithanubandha d = {} for rec in recs: root = rec.verbwithanubandha if root not in d: d[root] = [] d[root].append(rec) # check first file with codecs.open(filein1, 'r', 'utf-8') as f: roots1 = [line.rstrip('\r\n') for line in f] print len(roots1), "roots read from", filein1 check(roots1, d) # check second file with codecs.open(filein2, 'r', 'utf-8') as f: