如何在PHP中检测文档的语言?

时间:2022-08-26 00:08:55

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

这里已经回答了基础知识。但是有没有预先构建的PHP库与Lingua ::识别CPAN一样吗?

2 个解决方案

#1


3  

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.

我之前使用过PEAR包Text_LanguageDetect。得到的工作做得很好。我不确定任何其他更成熟的库。

#2


0  

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.

1-你可以自己做(很难) - 通过查看字符和n-gram频率来检测语言和代码页。你需要大量的“训练”数据,但它是可行的。

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

2-你可以运行一个perl脚本来为你做检测(更容易)。

#1


3  

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.

我之前使用过PEAR包Text_LanguageDetect。得到的工作做得很好。我不确定任何其他更成熟的库。

#2


0  

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.

1-你可以自己做(很难) - 通过查看字符和n-gram频率来检测语言和代码页。你需要大量的“训练”数据,但它是可行的。

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

2-你可以运行一个perl脚本来为你做检测(更容易)。