定制 mbeurel/php-liblinear 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

mbeurel/php-liblinear

Composer 安装命令:

composer require mbeurel/php-liblinear

包简介

Used the liblinear library with php

README 文档

README

Minimum PHP Version Latest Stable Version Total Downloads License

A simple, light and efficient short-text classification tool based on Liblinear for PHP.

Inspired by Python Library TextGrocery.

For Lemmarizer words, used php-lemmatizer

Installation Liblinear library

Debian or Ubuntu :

apt-get install liblinear-dev liblinear-tools liblinear3

Other distribution view repository github

Install php-liblinear

You can install it with Composer:

composer require mbeurel/php-liblinear

Examples

Example scripts are available ina separate repository php-liblinear/examples.

Sample Code

include "vendor/autoload.php";
use PhpLiblinear\Classification\LibLinear;
$data = [
  ["French", "Ceci est un texte dans la langue française."],
  ["French", "Bonjour, comment allez vous ?"],
  ["French", "Bonjour, je m'appelle Jean !!!"],
  ["English", "This is a english language text."],
  ["English", "Hello, How are you ?"],
  ["English", "Hello, my name is Jean !!!"],
];
try {
  
  // Init library
  $libLinear = new LibLinear("instanceName", __DIR__."/var", array(
        "type"      =>  0,            // Liblinear type, view the liblinear documentation
        "cost"      =>  1.0,          
        "epsilon"   =>  0.1,
        "debug"     =>  false
      )
    );

  // Liblinear train
  $libLinear->train($data);
  
  // Save model
  $libLinear->save();

  // Load model
  $libLinear->load();
  
  // Liblinear predict : String or Array parameters, to array => ["Bonjour, je m'appelle Louis", "Comment allez vous ?"]
  $result = $libLinear->predict("Bonjour, je m'appelle Louis");
  
  // View result
  var_dump($result);

  //  $result = array(
  //    0  =>  array(
  //      "value"        =>  "French",
  //      "percentage"   =>  0.763259,
  //      "percentages"  =>  array(
  //        "French"        => 0.763259,
  //        "English"       => 0.236741
  //      )
  //    )
  //  )

} catch(\Exception $e) {
  echo $e;
}

Credits

Created by Matthieu Beurel. Sponsored by Yipikai.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固