如何确保用户只提交英文文本 [英] How to ensure user submit only english text

查看:108
本文介绍了如何确保用户只提交英文文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个涉及自然语言处理的项目,因为nlp模块目前只处理英文文本,所以我必须确保用户提交的内容(不长,只有几个单词)是英文的。是否有既定的方法来实现这一目标?首选Python或Javascript方式。

I am building a project involving natural language processing, since the nlp module currently only deal with english text, so I have to make sure the user submitted content (not long, only several words) is in english. Are there established ways to achieve this? Python or Javascript way preferred.

推荐答案

如果内容足够长,我会建议一些频率分析

If the content is long enough I would suggest some frequency analysis on the letters.

但是,我认为最好的办法是将它们与英语词典进行比较,如果其中一半匹配则接受输入。

But for a few words I think your best bet is to compare them to an English dictionary and accept the input if half of them match.

这篇关于如何确保用户只提交英文文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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