LTP HIT speech tagging failed flag is empty, Index out of range

problem

Direct loading HIT LTP in the speech marking model, for words have word list of words marked the emergence of the mark list of tags is empty phenomenon, the length normally mark list and word list of words the same length, the coexistence marked results.
As shown, an error "Index out of range"
Original code: Load ltp speech tagging model for the word list of words words part of speech markingpostags length after labeled 0
Compiling source code, line 58: when the abnormality is empty postags read content appears postags

The reason

When the word is empty, LTP speech marking model can not successfully tagged and thrown Index out of range exception.

Solution

Delete all blank lines

  • notepad ++ word document opens the document (the program is read from the document and stored in the list) directly delete blank lines
  • Preparation of written word filter out blank lines when the result into the document, or filter when reading

Correct results

The results of correct operation

Released eight original articles · won praise 3 · Views 650

Guess you like

Origin blog.csdn.net/lehek/article/details/104116590