2017 © Pedro Peláez
 

library language-detector

A PHP package that detects the language from a string and can learn new languages.

image

chibifr/language-detector

A PHP package that detects the language from a string and can learn new languages.

  • Friday, March 11, 2016
  • by ChibiFR
  • Repository
  • 1 Watchers
  • 1 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Language Detector

A PHP package that detects the language from a string and can learn new languages., (*1)

Installation

To install this package, make sure you have composer. Then, require it:, (*2)

composer require chibifr/language-detector

Teach a new language

To teach a new language to the Language Detector, simply add a file to the src/languages directory named "your-newly-added-language.php". This file should return an array of words or characters of the language you are teaching the LanguageDetector., (*3)

This file should look like:, (*4)

<?php
// Your file should simple return an array of words/characters.
return [
    'word1',
    'word2',
    'word3',
    'word4',
    'etc'
];

Should I add words or characters?, (*5)

Good question bro/sis! Here is the answer: if your language does not use latin latters, add characters, if it does, then add words., (*6)

More you add words, more the LanguageDetector will be efficient (but don't add too much, that could slow it down)., (*7)

Usage

<?php
// Require the composer's vendor autoload file
require './vendor/autoload.php';

use ChibiFR\LanguageDetector\Detector;

// Create a new Converter object
$lg = new Detector();

// Trying to detect English
$result = $lg->detectLanguage('Hello, my name is FooBar and I live in New York. The weather here is pretty
nice! Anyways, have a good day, people.');

print_r($result) // Will print ['language' => 'english', 'reliable' => 1]

// Trying to detect an unkown language
$result = $lg->detectLanguage('A e i o u.');
print_r($result) // Will print ['language' => 'english', 'reliable' => 0]
// You can then check if the language found is reliable before doing more.

The Versions

11/03 2016

dev-master

9999999-dev

A PHP package that detects the language from a string and can learn new languages.

  Sources   Download

MIT

The Development Requires

by Simon Auber

08/12 2015

1.0.0

1.0.0.0

A PHP package that detects the language from a string and can learn new languages.

  Sources   Download

MIT

The Development Requires

by Simon Auber