File "stringsource", line 15, in string.from_py.__pyx_convert_string_from_py_std__in_string TypeError: expected bytes, tuple found
还没有人认领这个 Issue。
评估
调研方向
Start with pycrfsuite/_pycrfsuite.pyx at BaseTrainer.append and to_item, then check the trainer API documentation to confirm the expected feature and label types. Reproduce the call using the provided example and identify which value is a tuple where bytes are expected. Done means the accepted input format is clear and the example either works or reports the incompatibility precisely.
由索引模型根据 Issue 内容生成。
描述
I am getting following error while testing the py CRf suite.
crftrainer.append(xseq, yseq)
File "pycrfsuite/_pycrfsuite.pyx", line 312, in pycrfsuite._pycrfsuite.BaseTrainer.append
File "stringsource", line 48, in vector.from_py.__pyx_convert_vector_from_py_std_3a__3a_string
File "pycrfsuite/_pycrfsuite.pyx", line 53, in pycrfsuite._pycrfsuite.to_item
File "stringsource", line 15, in string.from_py.__pyx_convert_string_from_py_std__in_string
TypeError: expected bytes, tuple found
This is the code I am using It can be used for replicating the error.
train_sentlist = [ BOS I would like to meet Jack EOS]
[def features(sentence, index):
print( sentence, "\t", index)
k = {
'word': sentence[index],
'is_first': index == 0,
'is_last': index == len(sentence) - 1,
'is_capitalized': sentence[index][0].upper() == sentence[index][0],
'is_all_caps': sentence[index].upper() == sentence[index],
'is_all_lower': sentence[index].lower() == sentence[index],
'prefix-1': sentence[index][0],
'prefix-2': sentence[index][:2],
'prefix-3': sentence[index][:3],
'suffix-1': sentence[index][-1],
'suffix-2': sentence[index][-2:],
'suffix-3': sentence[index][-3:],
'prev_word': '' if index == 0 else sentence[index - 1],
'next_word': '' if index == len(sentence) - 1 else sentence[index + 1]
}
return k
for sent in train_sentlist:
sent.remove("EOS")
sent.remove("BOS")
Train_list.append(sent)
X=[]
for tagged in Train_list:
X.append([features(tagged, index) for index in range(len(tagged))])
crftrainer = pycrfsuite.Trainer(verbose=False)
for xseq, yseq in zip(X, t_nerlist):
crftrainer.append(xseq, yseq)
crftrainer.set_params({
'c1': 1.0, # coefficient for L1 penalty
'c2': 1e-3, # coefficient for L2 penalty
'max_iterations': 200, # stop earlier
'feature.possible_transitions': True
})
crftrainer.train("model/nermodel.crfsuite")](url)
- 主要语言
- Python
- 星标
- 774
- 派生
- 223
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
scrapinghub/python-crfsuite 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 63/100
scrapinghub/python-crfsuite#167 · 2 条评论 · 2 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 25/100
scrapinghub/python-crfsuite#142 ·
-
难度 2/5 1-3 小时 新手友好度 25/100
scrapinghub/python-crfsuite#129 · 1 条评论 · 2 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 35/100
scrapinghub/python-crfsuite#119 · 1 条评论 · 1 个 reaction ·
-
难度 5/5 一周以上 新手友好度 25/100
scrapinghub/python-crfsuite#114 ·
查看 scrapinghub/python-crfsuite 的全部 Issue
相似的 Issue
-
[19.0] pos_sale: settling an order with a 0 down payment line crashes (reading 'reward_id') and leaves a wrong amount due可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 79/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 79/100
developmentseed/titiler-covjson#164 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 82/100
awslabs/visual-asset-management-system#2164 ·
维护者通常 1 天内回复
-
needs-triage
难度 2/5 1-3 小时 新手友好度 86/100
MakazhanAlpamys/Soup#3589 ·
维护者通常 1 天内回复
-
channels status reports the wrong Enabled value for Feishu instances and default-enabled WebSocket未关闭
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 1 天内回复