【问题标题】:How does sklearn-crfsuite handle strings?sklearn-crfsuite 如何处理字符串?
【发布时间】:2020-01-21 11:09:03
【问题描述】:

我一直在关注sklearn-crfsuitetutorial

用于训练 CRF 模型的特征示例如下所示。

{'+1:postag': 'Fpa',
 '+1:postag[:2]': 'Fp',
 '+1:word.istitle()': False,
 '+1:word.isupper()': False,
 '+1:word.lower()': '(',
 'BOS': True,
 'bias': 1.0,
 'postag': 'NP',
 'postag[:2]': 'NP',
 'word.isdigit()': False,
 'word.istitle()': True,
 'word.isupper()': False,
 'word.lower()': 'melbourne',
 'word[-2:]': 'ne',
 'word[-3:]': 'rne'}

sklearn-crfsuite 如何将melbourne 之类的字符串转换为浮点数,因为 CRF 的特征应该只是浮点数。文档中没有提到这一点。

【问题讨论】:

    标签: python crf crfsuite python-crfsuite


    【解决方案1】:

    sklearn-crf 功能采用 python-crfsuite 格式。每个字符串都被视为键:

        * {"string_key": "string_value", ...} dict; that's the same as
          {"string_key=string_value": 1.0, ...}
        * ["string_key1", "string_key2", ...] list; that's the same as
          {"string_key1": 1.0, "string_key2": 1.0, ...}
    

    您可以在此处找到更多信息: https://github.com/scrapinghub/python-crfsuite/blob/master/pycrfsuite/_pycrfsuite.pyx

    【讨论】:

      猜你喜欢
      • 2011-12-11
      • 1970-01-01
      • 1970-01-01
      • 2011-06-09
      • 2015-04-10
      • 1970-01-01
      • 1970-01-01
      • 2013-09-22
      • 2010-11-19
      相关资源
      最近更新 更多