Recommend this page to a friend! |
![]() |
Info | Documentation | ![]() |
![]() |
![]() |
Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not enough user ratings | Total: 293 | All time: 7,481 This week: 89![]() |
Version | License | PHP version | Categories | |||
language-detection 1.3 | Custom (specified... | 7.1 | Localization, Algorithms, Text proces..., A..., P... |
Collaborate with this project | Author | ||||||||
language_detection - github.com Description This package can detect the language of a given text string. |
|
Detect the language from a given text.
To do that it generates a language profile based on N-grams for every file in etc
directory.
Then it generate such language profile for the unknown text and compare the previosly language profiles against the unknown.
Only requirement is a PHP version greater than or equal to 7.1. > Note: language_detection requires the Multibyte String extension in order to work.
composer require patrick-schur/language-detection
Or add the following to composer.json
{
"require": {
"patrick-schur/language-detection": "*"
}
}
Before we can recognize the language from a given text, we have to generate a language profile for each language.
From the beginning it comes with a pre-trained language profile (etc/_langs.json
).<br>
Also you can add new files to etc
or change existing ones.
First we have to generate a language profile.
require_once 'vendor/autoload.php';
use LanguageDetector\Trainer;
$t = new Trainer;
$t->learn();
If we have our language profile, we can classify texts by their language. To detect the language correctly, the length of the input text should be at least some sentences.
require_once 'vendor/autoload.php';
use LanguageDetector\LanguageDetector;
$ld = new LanguageDetector;
var_dump($ld->detect('Das ist ein deutscher Satz.')); // de
It supports up to now 73 languages. If your language not supported, feel free to add your own language files.
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
||||
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Lic. | License text | ||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Doc. | Documentation |
![]() |
/ | etc |
File | Role | Description |
---|---|---|
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Doc. | Documentation |
![]() ![]() |
Data | Auxiliary data |
![]() |
/ | src | / | LanguageDetector |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
Class | Class source | ||
![]() |
Class | Class source | ||
![]() |
Class | Class source |
![]() |
/ | src | / | LanguageDetector | / | Tokenizer |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
/ | tests |
File | Role | Description |
---|---|---|
![]() |
Class | Class source |
![]() |
Class | Class source |
![]() |
Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
![]() |
![]() | language-detection-2016-12-20.zip 548KB |
![]() | language-detection-2016-12-20.tar.gz 547KB |
![]() | Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.