Dave Vogt
Dave Vogt

Reputation: 19482

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

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

Upvotes: 1

Views: 494

Answers (2)

Osama Al-Maadeed
Osama Al-Maadeed

Reputation: 5695

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).

Upvotes: 0

chroder
chroder

Reputation: 4463

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.

Upvotes: 3

Related Questions