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

Abierto
#108 0 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
42/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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)

Lenguaje dominante
Python
Estrellas
774
Forks
223
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de scrapinghub/python-crfsuite

Todos los issues de scrapinghub/python-crfsuite

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.