Mailgun Talon:签名提取示例抛出错误

时间:2014-09-03 08:18:51

标签: mailgun

我在GCE上安装了mailgun / talon,并在README部分尝试了这个例子,但它向我抛出了以下错误:

>>> from talon import signature
>>> message = """Thanks Sasha, I can't go any higher and is why I limited it to the
... homepage.
... 
... John Doe
... via mobile"""
>>> message
"Thanks Sasha, I can't go any higher and is why I limited it to the\nhomepage.\n\nJohn     Doe\nvia mobile"
>>> text,signtr = signature.extract(message, sender='john.doe@example.com')
ERROR:talon.signature.extraction:ERROR when extracting signature with classifiers
Traceback (most recent call last):
  File "talon/signature/extraction.py", line 57, in extract
    markers = _mark_lines(lines, sender)
  File "talon/signature/extraction.py", line 99, in _mark_lines
    elif is_signature_line(line, sender, EXTRACTOR):
  File "talon/signature/extraction.py", line 40, in is_signature_line
    return classifier.decisionFunc(data, 0) > 0
AttributeError: 'NoneType' object has no attribute 'decisionFunc'

我是否需要以某种方式训练模型(这个签名似乎是ML的例子)?我用pip安装了它。

1 个答案:

答案 0 :(得分:1)

如果你想使用带分类器的签名解析,你只需要在使用lib之前调用talon.init() - 它会加载训练有素的分类器。其他方法如talon.signature.bruteforce.extract_signature()或talon.quotations.extract_from()不需要分类器。这是一个完整的代码示例:

import talon
# don't forget to init the library first
# it loads machine learning classifiers
talon.init()

from talon import signature


message = """Thanks Sasha, I can't go any higher and is why I limited it to the
homepage.

John Doe
via mobile"""

text, signature = signature.extract(message, sender='john.doe@example.com')
# text == "Thanks Sasha, I can't go any higher and is why I limited it to the\nhomepage."
# signature == "John Doe\nvia mobile"