Example #1
0
def slashtags_eval(goldpath, testpath, delimiter, out_f=sys.stdout, tagmap=None, matrix=False, details=False, length_limit=None):
    '''
    Evaluate a "slashtags" format file

    :param goldpath:
    :type goldpath:
    :param testpath:
    :type testpath:
    :param delimiter:
    :type delimiter:
    :param out_f:
    :type out_f:
    :param tagmap:
    :type tagmap:

    :rtype: POSEvalDict
    '''

    gold_c = POSCorpus.read_slashtags(goldpath)
    test_c = POSCorpus.read_slashtags(testpath)

    poseval(test_c, gold_c, out_f, matrix=matrix, details=details, length_limit=length_limit)
def slashtags_to_simpletagger(in_path, out_path):
	p = POSCorpus.read_slashtags(in_path)
	
	out_f = open(out_path, 'w', encoding='utf-8')
	
	for inst in p:
		sf = SequenceFeature(inst)
		while sf:			
						
			out_f.write('%s ' % sf.form)
						
# 			out_f.write('word-%s ' % sf.form)
# 			out_f.write('pre-3-%s ' % sf.prefix(3))
# 			out_f.write('pre-2-%s ' % sf.prefix(2))
# 			
# 			out_f.write('suf-3-%s ' % sf.suffix(3))
# 			out_f.write('suf-2-%s ' % sf.suffix(2))
# 			
# 			#===================================================================
# 			# Context Features
# 			#===================================================================
# 			out_f.write('prev-%s ' % sf.prev().form)
# 			out_f.write('next-%s ' % sf.next().form)
# 			
# 			#===================================================================
# 			# More Context
# 			#===================================================================
# 			out_f.write('prev-prev-%s ' % sf.prev().prev().form)
# 			out_f.write('next-next-%s ' % sf.next().next().form)
			
			# Finally, write out the label
			out_f.write('%s\n' % sf.label)			
			
			sf = sf.next()
		out_f.write('\n')
		
	out_f.close()