如何检测用户输入文本的语言? [英] How to detect language of user entered text?

查看:145
本文介绍了如何检测用户输入文本的语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个接受不同语言用户输入的应用程序(目前修复了3种语言)。要求是用户可以输入文本而不必费心通过UI中提供的复选框选择语言。

I am dealing with an application that is accepting user input in different languages (currently 3 languages fixed). The requirement is that users can enter text and dont bother to select the language via a provided checkbox in the UI.

是否有现有Java库检测文字的语言?

Is there an existing Java library to detect the language of a text?

我想要这样的东西:

text = "To be or not to be thats the question."

// returns ISO 639 Alpha-2 code
language = detect(text);

print(language);

结果:

EN

我不想知道如何创建语言检测器我自己(我见过很多博客试图这样做)。该库应提供简单的APi,并且完全脱机工作。开源或商业关闭并不重要。

I dont want to know how to create a language detector by myself (i have seen plenty of blogs trying to do that). The library should provide a simple APi and also work completely offline. Open-source or commercial closed doesn't matter.

我也在SO上发现了这个问题(还有一些):

i also found this questions on SO (and a few more):

如何检测语言

如何检测文本语言?

推荐答案

以下是两个选项

  • LanguageIdentifier
  • Rosette Language Identifier

这篇关于如何检测用户输入文本的语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆