由fasttext和langid支持的闪电式快速语言预测。

whatlangid的Python项目详细描述


whatLangid

Build StatusPyPI

这个项目是建立在 whatthelanglangid

那个 依赖关系(pyfasttextwhatthelang不是Facebook的官方版本。

这个项目取决于官方发布的 https://github.com/facebookresearch/fastText.git

目前,fasttext还没有在pypi上发布,因此您需要 --process-dependency-linksarg(使用pip时)。

为什么这个项目存在?

issue_lang.py

依赖性

可以使用requirements.txt文件安装依赖项:

$ pip install -r requirements.txt

安装

来自Github

$ pip install  --extra-index-url=https://test.pypi.org/simple/ git+https://github.com/bung87/whatlangid

来自PYPI

$ pip install  --extra-index-url=https://test.pypi.org/simple/ whatlangid

基本用法

使用whatlangid

预测语言
>>>fromwhatlangidimportWhatLangId>>>wtl=WhatLangId()>>>wtl.predict_lang("Mother")'en'>>>wtl.predict_lang("தாய்")'ta'>>>wtl.predict_lang("അമ്മ")'ml'>>>wtl.predict_lang("पिता")'hi'>>>wtl.predict_pro(["English sentence","അമ്മ"])[('en',0.8848170638084412),('ml',0.9535570740699768)]

还支持批预测

>>>wtl.predict_lang(["അമ്മ","पिता","teacher"])['ml','hi','en']

高级使用

wtl = WhatLangId(custom_model=abs_path)

使用更快更精确的bin版本模型,但是 文件大小为126MB

python -m whatlangid.use_bin

支持的语言

支持176种语言。相应语言的iso代码 如下所示。

af als am an ar arz as ast av az azb ba bar bcl be bg bh bn bo bpy br bs bxr ca cbk
ce ceb ckb co cs cv cy da de diq dsb dty dv el eml en eo es et eu fa fi fr frr fy ga
gd gl gn gom gu gv he hi hif hr hsb ht hu hy ia id ie ilo io is it ja jbo jv ka kk km
kn ko krc ku kv kw ky la lb lez li lmo lo lrc lt lv mai mg mhr min mk ml mn mr mrj ms
mt mwl my myv mzn nah nap nds ne new nl nn no oc or os pa pam pfl pl pms pnb ps pt qu
rm ro ru rue sa sah sc scn sco sd sh si sk sl so sq sr su sv sw ta te tg th tk tl tr
tt tyv ug uk ur uz vec vep vi vls vo wa war wuu xal xmf yi yo yue zh

车型培训详情

使用fasttext建立的量化模型。更多细节请参见 快速文本blog

参考值

WhatLangIdFastTextlangid供电

用子词信息丰富词向量

[1]P.Bojanowski*,E.Grave*,A.Joulin,T.Mikolov,Enriching Word Vectors with Subword Information

@article{bojanowski2016enriching,
  title={Enriching Word Vectors with Subword Information},
  author={Bojanowski, Piotr and Grave, Edouard and Joulin, Armand and Mikolov, Tomas},
  journal={arXiv preprint arXiv:1607.04606},
  year={2016}
}

有效的文本分类技巧包

[2]A.Joulin,E.Grave,P.Bojanowski,T.Mikolov,Bag of Tricks for Efficient Text Classification

@article{joulin2016bag,
  title={Bag of Tricks for Efficient Text Classification},
  author={Joulin, Armand and Grave, Edouard and Bojanowski, Piotr and Mikolov, Tomas},
  journal={arXiv preprint arXiv:1607.01759},
  year={2016}
}

fasttext.zip:压缩文本分类模型

[3]A.Joulin,E.Grave,P.Bojanowski,M.Douze,H.Jégou,T.Mikolov, FastText.zip: Compressing text classification models

@article{joulin2016fasttext,
  title={FastText.zip: Compressing text classification models},
  author={Joulin, Armand and Grave, Edouard and Bojanowski, Piotr and Douze, Matthijs and J{\'e}gou, H{\'e}rve and Mikolov, Tomas},
  journal={arXiv preprint arXiv:1612.03651},
  year={2016}
}

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何克服带有空值的不可空bean级验证   “此行有多个标记”的authenticateUser上的java MySQLConnection错误   java处理Jackson异常   java Netbeans编辑器如何知道文件在撤消后不会被修改?   目标C相当于Java的ArrayList   java当需要int时,可以将short传递给方法调用吗?   drawString()方法上的java MouseListener   java服务器socket是执行此操作的最佳选项   java需要单个匹配bean,但找到了2:org。springframework。网状物servlet。mvc。方法注释。RequestMappingHandlerMapping   如何在Java中执行Windows命令?   安卓应用程序的java文件主机   java将所有spring引导属性都设置在内。将yml文件转换为系统属性   Java邮件中的html内联链接在邮件客户端中不起作用   Java二进制文件的bazel版本控制   java如何在自定义ListView中使用Intent   java(Spring MVC+Hibernate 4+Test 4)自动连线DAO返回NULL   java一次add()调用可以在Solr服务器中索引多少文档?   java如何获取Avro GenericRecord大小