Re: return language of a word

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2008/9/29 shahrzad khorrami <shahrzad.khorrami@xxxxxxxxx>:> hi all,>> is there any function to return us the lanuage of a word in the sentence?>> for example : My name is شهرزاد .>> when it sees شهرزاد notice that is a persian language.
As others have said, you can check what unicode block the characters are from.
For segments of text that are a little longer (one or two sentences),you can use n-gram based language identification, which can sometimesbe spookily accurate. If you want to give that a go, there's a Pearpackage called Text::LanguageDetect which will do that[http://pear.php.net/package/Text_LanguageDetect]. It doesn't havetrigrams for Persian in the lang.dat, but I don't imagine it would betoo hard to add them, if that's what you need.
-robin

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux