How to detect the language of a document - in PHP?

霸气de小男生 提交于 2019-12-08 06:53:06

问题


The basics have already been answered here. But is there a pre-built PHP lib doing the same as Lingua::Identify from CPAN?


回答1:


There's a PEAR package Text_LanguageDetect that I've used before. Get's the job done well enough. I'm not sure of any other libs that are more mature.




回答2:


1- You could do it yourself (the hard way) - detecting both language and codepage by looking at character and n-gram frequencies. You would need lots of "training" data, but it's doable.

2- You could run a perl script to do the detection for you(much easier).



来源:https://stackoverflow.com/questions/290851/how-to-detect-the-language-of-a-document-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!