hamidgh83/language-detection 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

hamidgh83/language-detection

Composer 安装命令:

composer require hamidgh83/language-detection

包简介

A language detection library for PHP. Detects the language from a given text string.

README 文档

README

The package

Version Total Downloads Dependents License

language-detection

ُThis is an extension of language-detection where you can find its documentation.

This library can detect the language of a given text string. It can parse given training text in many different idioms into a sequence of N-grams and builds a database file in JSON format to be used in the detection phase. Then it can take a given text and detect its language using the database previously generated in the training phase. The library comes with text samples used for training and detecting text in 110 languages.

Installation with Composer

Note: This library requires the Multibyte String extension in order to work.

$ composer require hamidgh83/language-detection

Basic Usage

Basic usage of this library is the same as original library but the following methods has beed added:

bestResult()

Returns the best result as a string.

$ld->detect('Mag het een onsje meer zijn?')->bestResult();

Result:

string(2) "nl"

getSupportLanguages()

This method returns a list if supportted languages as an array.

$ld->getSupportLanguages();

Result:

Array
(
    0 => ab
    1 => af
    2 => am
    3 => ar
    4 => ay
    5 => az-Cyrl
    6 => az-Latn
    7 => be
    8 => bg
    9 => bi
    10 => bn
    11 => bo
    12 => br
    [...]
)

getLanguageProps($lang)

Every language has their own properties and you can get the it as follow:

$lng    = new Language();
$result = $lng->detect('This is an example text.');
$props  = $lng->getLanguageProps($result->bestResult());

Result:

Array
(
    'props' => Array(
        'language' => 'English',
        'language' => Array (
            'United Kingdom',
            'United States of America'
        ),
        'direction' => 'ltr'
    )
)

Supported languages

The library currently supports 110 languages. To get an overview of all supported languages please have a look at here.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-09-29

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固