M1-Arborator-NaijaSUD/arborator/lib/treebankfiles.py
def enterConll(dbname,filename,annotatorName=None, eraseAllAnnos=False, dbtextname=None, corrdic={"tag":"cat","t":"orthotext"}): 
	""" 
	TODO: think about when to erase all tokens and features of existing annotations. maybe put warnings and confirm?
	"""
	sql = database.SQL(dbname)
	db,cursor=sql.open()
	sentences=conll.conllFile2trees(filename,corrdic)
	
	if dbtextname:
		textid = sql.enter(cursor, "texts",["textname"],(dbtextname,))
	else:
		#M016.XML.Paola.trees.conll10
		if filename[-14:-2]=='.trees.conll':
			dbtextname=".".join(filename.split("/")[-1].split(".")[:-3])
			
			# TODO: remove:
			dbtextname= "Rhap-"+dbtextname[:2] + "0" + dbtextname[2:4]+"-Synt.xml"
			#print dbtextname
			
			textid = sql.enter(cursor, "texts",["textname"],(dbtextname,))
			#print textid
			if not annotatorName: annotatorName=filename.split(".")[-3]
		else:
			dbtextname=filename.split("/")[-1]
			textid = sql.enter(cursor, "texts",["textname"],(dbtextname,))
			
	enterSentences(sql,cursor,sentences,filename, textid,annotatorName,eraseAllAnnos )
	db.commit()
	db.close()
	return len(sentences)
 
	TODO: think about when to erase all tokens and features of existing annotations. maybe put warnings and confirm?
	
think about when to erase all tokens and features of existing annotations.
think about when to erase all tokens and features of existing annotations .
def enterConll(dbname,filename,annotatorName=None, eraseAllAnnos=False, dbtextname=None, corrdic={"tag":"cat","t":"orthotext"}): 
	sql = database.SQL(dbname)
	db,cursor=sql.open()
	sentences=conll.conllFile2trees(filename,corrdic)
	if dbtextname:
		textid = sql.enter(cursor, "texts",["textname"],(dbtextname,))
	else:
		if filename[-14:-2]=='.trees.conll':
			dbtextname=".".join(filename.split("/")[-1].split(".")[:-3])
			dbtextname= "Rhap-"+dbtextname[:2] + "0" + dbtextname[2:4]+"-Synt.xml"
			textid = sql.enter(cursor, "texts",["textname"],(dbtextname,))
			if not annotatorName: annotatorName=filename.split(".")[-3]
		else:
			dbtextname=filename.split("/")[-1]
			textid = sql.enter(cursor, "texts",["textname"],(dbtextname,))
	enterSentences(sql,cursor,sentences,filename, textid,annotatorName,eraseAllAnnos )
	db.commit()
	db.close()
	return len(sentences)
def enterConll ( dbname , filename , annotatorName = None , eraseAllAnnos = False , dbtextname = None , corrdic = { "tag" : "cat" , "t" : "orthotext" } ) : sql = database . SQL ( dbname ) db , cursor = sql . open ( ) sentences = conll . conllFile2trees ( filename , corrdic ) if dbtextname : textid = sql . enter ( cursor , "texts" , [ "textname" ] , ( dbtextname , ) ) else : if filename [ - 14 : - 2 ] == '.trees.conll' : dbtextname = "." . join ( filename . split ( "/" ) [ - 1 ] . split ( "." ) [ : - 3 ] ) dbtextname = "Rhap-" + dbtextname [ : 2 ] + "0" + dbtextname [ 2 : 4 ] + "-Synt.xml" textid = sql . enter ( cursor , "texts" , [ "textname" ] , ( dbtextname , ) ) if not annotatorName : annotatorName = filename . split ( "." ) [ - 3 ] else : dbtextname = filename . split ( "/" ) [ - 1 ] textid = sql . enter ( cursor , "texts" , [ "textname" ] , ( dbtextname , ) ) enterSentences ( sql , cursor , sentences , filename , textid , annotatorName , eraseAllAnnos ) db . commit ( ) db . close ( ) return len ( sentences )
TODO: think about when to erase all tokens and features of existing annotations.
TODO : think about when to erase all tokens and features of existing annotations .
""" 
	TODO: think about when to erase all tokens and features of existing annotations. maybe put warnings and confirm?
	""" #M016.XML.Paola.trees.conll10 # TODO: remove: #print dbtextname #print textid
dbname
filename
annotatorName
eraseAllAnnos
dbtextname
corrdic