本文整理匯總了Python中EditModel.EditModel.edits方法的典型用法代碼示例。如果您正苦於以下問題:Python EditModel.edits方法的具體用法?Python EditModel.edits怎麽用?Python EditModel.edits使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類EditModel.EditModel
的用法示例。
在下文中一共展示了EditModel.edits方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: output
# 需要導入模塊: from EditModel import EditModel [as 別名]
# 或者: from EditModel.EditModel import edits [as 別名]
def output(self, partId, ch_aux):
"""Uses the student code to compute the output for test cases."""
trainCorpus = HolbrookCorpus('../data/holbrook-tagged-train.dat')
if partId in [1,2]:
editModel = EditModel('../data/count_1edit.txt', trainCorpus)
return json.dumps([[(e.editedWord, e.rule()) for e in editModel.edits(line.strip())] for line in ch_aux.split("\n")])
else:
testCorpus = HolbrookCorpus()
testCorpus.slurpString(ch_aux)
lm = None
if partId in [3,4]:
lm = LaplaceUnigramLanguageModel(trainCorpus)
elif partId in [5,6]:
lm = LaplaceBigramLanguageModel(trainCorpus)
elif partId in [7,8]:
lm = StupidBackoffLanguageModel(trainCorpus)
elif partId in [9,10]:
lm = CustomLanguageModel(trainCorpus)
else:
print 'Unknown partId: " + partId'
return None
speller = SpellCorrect(lm, trainCorpus)
output = speller.correctCorpus(testCorpus)
# put in the part ID as well
output = '[["%d"],%s' % (partId, output[1:])
return output