Am I passing the string correctly to the python library?

后端 未结 3 1089
终归单人心
终归单人心 2021-01-29 07:17

I\'m using a python library called Guess Language: http://pypi.python.org/pypi/guess-language/0.1

\"justwords\" is a string with unicode text. I stick it in the package,

3条回答
  •  长发绾君心
    2021-01-29 07:50

    It looks like you should be able to pass your unicode as-is. guessLanguage decodes an input that is str as utf-8. So your .encode('utf-8') is safe but unnecessary.

    I skimmed the source code and assumed it relies exclusively on the data in its "trigrams" directory for language detection, and it would not handle Japanese because there is no "ja" subdirectory in there. That is not correct, as pointed out by John Machin. So I have to assume your input is not what you think it is (which is hard to debug since it's not showing up correctly in your question).

提交回复
热议问题