def tagger_repl(tagger, **kwargs):
mxlen = int(kwargs.get('mxlen', 100))
maxw = int(kwargs.get('maxw', 100))
#zeropad = int(kwargs.get('zeropad', 0))
prompt_name = kwargs.get('prompt', 'class> ')
history_file = kwargs.get('history_file', '.history')
history = FileHistory(history_file)
while True:
text = prompt(prompt_name, history=history)
text = text.strip()
if text == 'quit':
break
try:
tokens = text.split(' ')
best = tagger.predict_text(tokens, mxlen=mxlen, maxw=maxw)
print(best)
except Exception as e:
logging.exception('Error')
评论列表
文章目录