本文整理汇总了Python中tagger.Tagger.toCRFsuite方法的典型用法代码示例。如果您正苦于以下问题:Python Tagger.toCRFsuite方法的具体用法?Python Tagger.toCRFsuite怎么用?Python Tagger.toCRFsuite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tagger.Tagger
的用法示例。
在下文中一共展示了Tagger.toCRFsuite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: mainTag
# 需要导入模块: from tagger import Tagger [as 别名]
# 或者: from tagger.Tagger import toCRFsuite [as 别名]
def mainTag(featureSet, options):
transModel = None
if not (options['printWeights'] or options['toCRFsuite']):
print('loading transition model...', end='', file=sys.stderr, flush=True)
transModel = TransModel.getModelFromFile(options['transModelFileName'])
print('done', file=sys.stderr, flush=True)
tagger = Tagger(featureSet, transModel, options)
if 'inFeatFile' in options and options['inFeatFile']:
# Tag a featurized file to to outputStream
for sen, comment in tagger.tagFeatures(options['inFeatFile']):
writeSentence(sen, options['outputStream'], comment)
elif 'ioDirs' in options and options['ioDirs']:
# Tag all files in a directory file to to fileName.tagged
for sen, fileName in tagger.tagDir(options['ioDirs'][0]):
writeSentence(sen, open(join(options['ioDirs'][1], '{0}.tagged'.format(fileName)), 'a', encoding='UTF-8'))
elif 'toCRFsuite' in options and options['toCRFsuite']:
# Make CRFsuite format to outputStream for tagging
tagger.toCRFsuite(options['inputStream'], options['outputStream'])
elif 'printWeights' in options and options['printWeights']:
# Print MaxEnt weights to STDOUT
tagger.printWeights(options['printWeights'], options['outputStream'])
else:
# Tag inputStream to outputStream
for sen, comment in tagger.tagCorp(options['inputStream']):
writeSentence(sen, options['outputStream'], comment)