Download the PHP package landrok/language-detector without Composer
On this page you can find all versions of the php package landrok/language-detector. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download landrok/language-detector
More information about landrok/language-detector
Files in landrok/language-detector
Package language-detector
Short Description A fast and reliable PHP library for detecting languages
License MIT
Homepage https://github.com/landrok/language-detector
Informations about the package language-detector
LanguageDetector
LanguageDetector is a PHP library that detects the language from a text string.
Table of contents
- Features
- Install
- Quick usage
- Detect language
- API Methods
- evaluate()
- getLanguage()
- getLanguages()
- getScores()
- getSupportedLanguages()
- getText()
- options
- For one-liners only
Features
- More than 50 supported languages, including Klingon
- Very fast, no database needed
- Packaged with a 2MB dataset
- Learning steps are already done, library is ready to use
- Small code, small footprint
- N-grams algorithm
- Supports PHP 5.4+, 7+ and 8+ and HHVM The latest release 1.4.x only supports PHP>=7.4
Install
Quick usage
Detect language
Instanciate a detector, pass a text and get the detected language.
Once it's instanciated, you can test multiple texts.
Would output something like:
Additionally, you can use a LanguageDetector instance as a string.
API Methods
evaluate()
Type \LanguageDetector\LanguageDetector
It performs an evaluation on a given text.
Example
After an evaluate()
, the result is stored and available for later use.
You can make a one line call.
It's possible to directly print evaluate()
output.
getLanguage()
Type string
The detected language
Example
getLanguages()
Type array
A list of loaded models that will be evaluated.
Example
getScores()
Type array
A list of scores by language, for all evaluated languages.
Example
getSupportedLanguages()
Type array
A list of supported languages that will be evaluated.
Example
getText()
Type string
Returns the last string which has been evaluated
Example
Options
Type \LanguageDetector\LanguageDetector
For even better performance, loaded models can be specified explicitly.
Example
For one-liners only
Type \LanguageDetector\LanguageDetector
With a static call on detect() method, you can perform an evaluation on a given text, in one line.
Example
You can use all API methods.