M1-Arborator-NaijaSUD/arborator/lib/database.py
def conllSentenceExport(self, sid, cursor, treeid, outf):
		"""
		called for each sentence in the conll export procss
		if outf=None, also used from outside tools, like trees2train.py
		"""
		doublegovs=False

		tree = Tree()
		for nr,at,va, in cursor.execute("""select features.nr, features.attr, features.value
					from trees, features
					where trees.rowid=features.treeid and trees.rowid=?;""",(treeid,)).fetchall():
			tree[nr]=tree.get(nr,{})
			tree[nr][at]=va
		for nr in sorted(tree): # for each token:
			g = self.getall(cursor, "links", ["treeid", "depid"], [treeid, nr])
			gd = dict([(govid,function) for _,trid,depid,govid,function in g if govid>=0]) #trid==treeid and
			tree[nr]["gov"]=gd
			if len(gd)>1:doublegovs=True
		for at,va, in cursor.execute("""select sentencefeatures.attr, sentencefeatures.value
						from trees, sentences,sentencefeatures
						where sentencefeatures.sentenceid=sentences.rowid and trees.sentenceid=sentences.rowid and trees.rowid=?;""",(treeid,)).fetchall():
			tree.sentencefeatures[at]=va
		
		if outf:
			outf.write(tree.conllu()+"\n")
			return doublegovs
		else:
			return tree

		called for each sentence in the conll export procss
		if outf=None, also used from outside tools, like trees2train.py
		
called for each sentence in the conll export procss
if outf=None, also used from outside tools, like trees2train.py
called for each sentence in the conll export procss if outf = None also used from outside tools like trees2train . py
def conllSentenceExport(self, sid, cursor, treeid, outf):
		doublegovs=False
		tree = Tree()
		for nr,at,va, in cursor.execute("""select features.nr, features.attr, features.value
					from trees, features
					where trees.rowid=features.treeid and trees.rowid=?;""",(treeid,)).fetchall():
			tree[nr]=tree.get(nr,{})
			tree[nr][at]=va
		for nr in sorted(tree): 
			g = self.getall(cursor, "links", ["treeid", "depid"], [treeid, nr])
			gd = dict([(govid,function) for _,trid,depid,govid,function in g if govid>=0]) 
			tree[nr]["gov"]=gd
			if len(gd)>1:doublegovs=True
		for at,va, in cursor.execute("""select sentencefeatures.attr, sentencefeatures.value
						from trees, sentences,sentencefeatures
						where sentencefeatures.sentenceid=sentences.rowid and trees.sentenceid=sentences.rowid and trees.rowid=?;""",(treeid,)).fetchall():
			tree.sentencefeatures[at]=va
		if outf:
			outf.write(tree.conllu()+"\n")
			return doublegovs
		else:
			return tree
def conllSentenceExport ( self , sid , cursor , treeid , outf ) : doublegovs = False tree = Tree ( ) for nr , at , va , in cursor . execute ( """select features.nr, features.attr, features.value
					from trees, features
					where trees.rowid=features.treeid and trees.rowid=?;""" , ( treeid , ) ) . fetchall ( ) : tree [ nr ] = tree . get ( nr , { } ) tree [ nr ] [ at ] = va for nr in sorted ( tree ) : g = self . getall ( cursor , "links" , [ "treeid" , "depid" ] , [ treeid , nr ] ) gd = dict ( [ ( govid , function ) for _ , trid , depid , govid , function in g if govid >= 0 ] ) tree [ nr ] [ "gov" ] = gd if len ( gd ) > 1 : doublegovs = True for at , va , in cursor . execute ( """select sentencefeatures.attr, sentencefeatures.value
						from trees, sentences,sentencefeatures
						where sentencefeatures.sentenceid=sentences.rowid and trees.sentenceid=sentences.rowid and trees.rowid=?;""" , ( treeid , ) ) . fetchall ( ) : tree . sentencefeatures [ at ] = va if outf : outf . write ( tree . conllu ( ) + "\n" ) return doublegovs else : return tree
called for each sentence in the conll export procss
if outf=None, also used from outside tools, like trees2train.py
called for each sentence in the conll export procss if outf = None also used from outside tools like trees2train . py
"""
		called for each sentence in the conll export procss
		if outf=None, also used from outside tools, like trees2train.py
		""" # for each token: #trid==treeid and
self
sid
cursor
treeid
outf