M1-Arborator-NaijaSUD/arborator/lib/yuchen_ExportNewestTree.py
def reorder(trees, outfile):	# 重新排序conll树，可重命名所有sent_id
	"""
	Reorders the trees based on the nr sentencefeature, adds updated text and sentence_id.
	Once this is done, the trees are written to a new file.

	input: List(Tree), Str
	does: Writes <outfile>
	output: None
	"""
	prefix = "_".join(trees[0].sentencefeatures.get("sent_id").split("_")[:-1])
	sortable = sorted(list([(int(t.sentencefeatures.get("nr")), t) for t in trees]))
	new_trees = list()
	for nr, tree in sortable:

		# adding metadatas	应该是重命名sent_id,从0开始
		tree.sentencefeatures["text"] = tree.sentence()
		tree.sentencefeatures["sent_id"] = prefix+"_"+str(nr-1)

		# removing useless metadata
		del tree.sentencefeatures["nr"]
		new_trees.append(tree)
	conll.trees2conllFile(new_trees, outfile)

	Reorders the trees based on the nr sentencefeature, adds updated text and sentence_id.
	Once this is done, the trees are written to a new file.

	input: List(Tree), Str
	does: Writes <outfile>
	output: None
	
Reorders the trees based on the nr sentencefeature, adds updated text and sentence_id.
Once this is done, the trees are written to a new file.

List(Tree), Str
does: Writes 
output: None
Reorders the trees based on the nr sentencefeature adds updated text and sentence_id . Once this is done the trees are written to a new file . List ( Tree ) Str does : Writes output : None
def reorder(trees, outfile):	
	prefix = "_".join(trees[0].sentencefeatures.get("sent_id").split("_")[:-1])
	sortable = sorted(list([(int(t.sentencefeatures.get("nr")), t) for t in trees]))
	new_trees = list()
	for nr, tree in sortable:
		tree.sentencefeatures["text"] = tree.sentence()
		tree.sentencefeatures["sent_id"] = prefix+"_"+str(nr-1)
		del tree.sentencefeatures["nr"]
		new_trees.append(tree)
	conll.trees2conllFile(new_trees, outfile)
def reorder ( trees , outfile ) : prefix = "_" . join ( trees [ 0 ] . sentencefeatures . get ( "sent_id" ) . split ( "_" ) [ : - 1 ] ) sortable = sorted ( list ( [ ( int ( t . sentencefeatures . get ( "nr" ) ) , t ) for t in trees ] ) ) new_trees = list ( ) for nr , tree in sortable : tree . sentencefeatures [ "text" ] = tree . sentence ( ) tree . sentencefeatures [ "sent_id" ] = prefix + "_" + str ( nr - 1 ) del tree . sentencefeatures [ "nr" ] new_trees . append ( tree ) conll . trees2conllFile ( new_trees , outfile )
Reorders the trees based on the nr sentencefeature, adds updated text and sentence_id.
Reorders the trees based on the nr sentencefeature adds updated text and sentence_id .
# 重新排序conll树，可重命名所有sent_id """
	Reorders the trees based on the nr sentencefeature, adds updated text and sentence_id.
	Once this is done, the trees are written to a new file.

	input: List(Tree), Str
	does: Writes <outfile>
	output: None
	""" # adding metadatas	应该是重命名sent_id,从0开始 # removing useless metadata
trees
outfile