Python langdetect: choose between one language or the other only
问题 I'm using langdetect to determine the language of a set of strings which I know are either in English or French. Sometimes, langdetect tells me the language is Romanian for a string I know is in French. How can I make langdetect choose between English or French only, and not all other languages? Thanks! 回答1: Option 1 One option would be using the package langid instead. Then you can simply restrict the languages with a method call: import langid langid.set_languages(['fr', 'en']) # ISO 639-1