Skip to content

Droeftoeter/elasticsearch-langdetect-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elasticsearch Langdetect PHP Namespace

This module adds endpoints to the Elasticsearch-PHP library when you are using the elasticsearch-langdetect plugin.

Installation

This module can be installed with Composer. Add the elasticsearch-langdetect-php package to your composer.json file:

{
    "require": {
        "sjaakmoes/elasticsearch-langdetect-php": "~1.0"
    }
}

After the module is installed through composer, we need to inject this module into the Elasticsearch-PHP library:

$params = [
    'host'              => ['localhost:9200'],
    'customNamespaces'  => [
        'langdetect'    => 'Langdetect\LangdetectNamespace'
    ]
];
$client = new Elasticsearch\Client($params);

Use

Language detection:

// Detect
$params = [
    'content'   => 'This is a sample text.'
];
$response = $client->langdetect()->detect($params);

The $response holds an array which looks like:

Array
(
    [profile] => /langdetect/
    [languages] => Array
        (
            [0] => Array
                (
                    [language] => en
                    [probability] => 0.9999959428847
                )

        )

)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages