File "stringsource", line 15, in string.from_py.__pyx_convert_string_from_py_std__in_string TypeError: expected bytes, tuple found

オープン
#108 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
backend

調査の方向性

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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

scrapinghub/python-crfsuite のほかの issue

scrapinghub/python-crfsuite の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。