M1-Arborator-NaijaSUD/arborator/lib/treebankfiles.py
def enterDegraded(project, filenameGood, filenameDegraded=None, goodAnnotatorName="prof", degradedAnnotatorName="parser", eraseAllAnnos=True): 
	"""
	if filenameDegraded is not given, the files have to be named xxx.orig and xxx.deg
	"""
	if not filenameDegraded: 
		filenameDegraded=filenameGood[:-len(".orig")]+".deg"
		
	dbtextname = filenameGood.split("/")[-1] #.decode("utf-8")
	if dbtextname.endswith(".orig"): dbtextname=dbtextname[:-len(".orig")]
	for exten in ".conll10 .conll14 .malt .tab .txt.conll_parse .txt.conll_parse.orig".split():
		if dbtextname.endswith(exten):
			dbtextname=dbtextname[:-len(exten)]
			break
		
	sql=database.SQL(project)
	print filenameGood
	trees=conll.conllFile2trees(filenameGood)
	
	simpleEnterSentences(sql, trees, dbtextname, annotatorName=goodAnnotatorName, eraseAllAnnos=True)
	
	#db,cursor=sql.open()
	#textid = sql.enter(cursor, "texts",["textname"],(dbtextname,))
	#enterSentences(sql, cursor, trees, dbtextname, textid, goodAnnotatorName, eraseAllAnnos=True)
	#db.commit()
	#db.close()
	
	trees=conll.conllFile2trees(filenameDegraded)
	textid=simpleEnterSentences(sql, trees, dbtextname, annotatorName=degradedAnnotatorName, eraseAllAnnos=False)
	print "==",sql.getNumberTokensPerText(textid, recompute=True)

	if filenameDegraded is not given, the files have to be named xxx.orig and xxx.deg
	
if filenameDegraded is not given, the files have to be named xxx.orig and xxx.deg
if filenameDegraded is not given the files have to be named xxx . orig and xxx . deg
def enterDegraded(project, filenameGood, filenameDegraded=None, goodAnnotatorName="prof", degradedAnnotatorName="parser", eraseAllAnnos=True): 
	if not filenameDegraded: 
		filenameDegraded=filenameGood[:-len(".orig")]+".deg"
	dbtextname = filenameGood.split("/")[-1] 
	if dbtextname.endswith(".orig"): dbtextname=dbtextname[:-len(".orig")]
	for exten in ".conll10 .conll14 .malt .tab .txt.conll_parse .txt.conll_parse.orig".split():
		if dbtextname.endswith(exten):
			dbtextname=dbtextname[:-len(exten)]
			break
	sql=database.SQL(project)
	print filenameGood
	trees=conll.conllFile2trees(filenameGood)
	simpleEnterSentences(sql, trees, dbtextname, annotatorName=goodAnnotatorName, eraseAllAnnos=True)
	trees=conll.conllFile2trees(filenameDegraded)
	textid=simpleEnterSentences(sql, trees, dbtextname, annotatorName=degradedAnnotatorName, eraseAllAnnos=False)
	print "==",sql.getNumberTokensPerText(textid, recompute=True)
def enterDegraded ( project , filenameGood , filenameDegraded = None , goodAnnotatorName = "prof" , degradedAnnotatorName = "parser" , eraseAllAnnos = True ) : if not filenameDegraded : filenameDegraded = filenameGood [ : - len ( ".orig" ) ] + ".deg" dbtextname = filenameGood . split ( "/" ) [ - 1 ] if dbtextname . endswith ( ".orig" ) : dbtextname = dbtextname [ : - len ( ".orig" ) ] for exten in ".conll10 .conll14 .malt .tab .txt.conll_parse .txt.conll_parse.orig" . split ( ) : if dbtextname . endswith ( exten ) : dbtextname = dbtextname [ : - len ( exten ) ] break sql = database . SQL ( project ) print filenameGood trees = conll . conllFile2trees ( filenameGood ) simpleEnterSentences ( sql , trees , dbtextname , annotatorName = goodAnnotatorName , eraseAllAnnos = True ) trees = conll . conllFile2trees ( filenameDegraded ) textid = simpleEnterSentences ( sql , trees , dbtextname , annotatorName = degradedAnnotatorName , eraseAllAnnos = False ) print "==" , sql . getNumberTokensPerText ( textid , recompute = True )
if filenameDegraded is not given, the files have to be named xxx.orig and xxx.deg
if filenameDegraded is not given the files have to be named xxx . orig and xxx . deg
"""
	if filenameDegraded is not given, the files have to be named xxx.orig and xxx.deg
	""" #.decode("utf-8") #db,cursor=sql.open() #textid = sql.enter(cursor, "texts",["textname"],(dbtextname,)) #enterSentences(sql, cursor, trees, dbtextname, textid, goodAnnotatorName, eraseAllAnnos=True) #db.commit() #db.close()
project
filenameGood
filenameDegraded
goodAnnotatorName
degradedAnnotatorName
eraseAllAnnos