承接 chibifr/language-detector 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

chibifr/language-detector

Composer 安装命令:

composer require chibifr/language-detector

包简介

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

README 文档

README

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

Installation

To install this package, make sure you have composer. Then, require it:

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.

This file should look like:

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

Should I add words or characters?

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

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

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.

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-12-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固