dev-master
9999999-devBundle to use Text_LanguageDetect with Symfony2.
MIT
The Requires
by Webmil
by Oleh Popadjuk
language detect text language detect
Bundle to use Text_LanguageDetect with Symfony2.
Bundle to use text-language-detect with Symfony2., (*1)
Add text-language-detect and WebmilTextLanguageDetectBundle to your vendors:, (*2)
git submodule add https://github.com/webmil/text-language-detect.git vendor/text-language-detect git submodule add https://github.com/webmil/WebmilTextLanguageDetectBundle.git vendor/bundles/Webmil/TextLanguageDetectBundle
Or add the followings lines to your deps
file, (*3)
// deps [WebmilTextLanguageDetectBundle] git=git://github.com/webmil/WebmilTextLanguageDetectBundle.git target=bundles/Webmil/TextLanguageDetectBundle [text-language-detect] git=git://github.com/webmil/text-language-detect.git
and run:, (*4)
$ ./bin/vendors install
Add both to your autoload:, (*5)
``` php // app/autoload.php <?php $loader->registerNamespaces(array( // ... 'Webmil' => DIR.'/../vendor/bundles', 'TextLanguageDetect' => DIR.'/../vendor/text-language-detect/lib', // ... ));, (*6)
Add the WebmilTextLanguageDetectBundle to your application kernel: ``` php // app/AppKernel.php <?php public function registerBundles() { return array( // ... new Webmil\TextLanguageDetectBundle\WebmilTextLanguageDetectBundle(), // ... ); }
Add in your config.yml file:, (*7)
``` yaml webmil_text_language_detect: omit_languages: # Omits languages. If you're only expecting a limited set of languages, this can greatly omit_list: ['russian', 'english', 'ukrainian'] # language name or array of names to omit include_only: true # if true will include (rather than exclude) only those in the list, (*8)
Usage ----- In controller: ``` php <?php // ... $ld = $this->container->get('text.language.detect'); //or just $this->get('language.detect') $text = 'Test language detection.'; $lang = $ld->detectConfidence($text); //...
print_r($lang):, (*9)
// output Array ( [language] => english [similarity] => 0.33985507246377 [confidence] => 0.018985507246377 )
Bundle is licensed under the MIT License. See the LICENSE file for full details., (*10)
Webmil, (*11)
Bundle to use Text_LanguageDetect with Symfony2.
MIT
language detect text language detect