wfphpnlp/sentistrength

使用SentiStrength方法进行印度尼西亚文本分类的PHP库。

1.0.0 2020-01-28 15:59 UTC

This package is auto-updated.

Last update: 2024-09-29 03:15:35 UTC


README

Build Status GitHub Packagist Version

库PHP用于将印尼语文本分类为积极、消极和中性,采用SentiStrength方法。

安装方法

通过Composer

composer require wfphpnlp/sentistrength

如果您还不了解如何使用Composer,请阅读Composer入门

克隆GitHub

git clone https://github.com/WillyFaq/Penilaian_Guru_Rating_Scale.git

使用方法

如果使用composer,使用vendor/autoload.php初始化项目

require_once __DIR__ . '/vendor/autoload.php';
use wfphpnlp/sentistrength;

配置额外词典的使用,如果未配置,则使用所有词典配置。

$config = array(
    			'negation_conf' => true,
    			'booster_conf' => true,
    			'ungkapan_conf' => true,
    			'consecutive_conf' => true,
    			'repeated_conf' => true,
    			'emoticon_conf' => true,
    			'question_conf' => true,
    			'exclamation_conf' => true,
    			'punctuation_conf' => true,
			);

以下是一个完整的使用示例。

<?php
// include composer autoloader
require_once __DIR__ . '/vendor/autoload.php';
use wfphpnlp/sentistrength;

$config = array(
			'negation_conf' => true,
			'booster_conf' => true,
			'ungkapan_conf' => true,
			'consecutive_conf' => true,
			'repeated_conf' => true,
			'emoticon_conf' => true,
			'question_conf' => true,
			'exclamation_conf' => true,
			'punctuation_conf' => true,
			);
			
// create sentistrength
$senti = new Sentistrength($config);

// hitung nilai sentistrength
$hasil = $senti->main("agnezmo pintar dan cantik sekali tetapi lintah darat :)");

echo $hasil['kelas'];
// Positif

//menampilkan hasil perhitungan
print_r($hasil);
/*
Array
(
    [classified_text] => agnezmo pintar [4] dan cantik [6] sekali tetapi lintah darat [-4] :) [3]
    [tweet_text] =>  agnezmo pintar dan cantik sekali tetapi lintah darat :)
    [sentence_score] => Array
        (
            [0] => agnezmo pintar [4] dan cantik [6] sekali tetapi lintah darat [-4] :) [3]
        )

    [max_positive] => 6
    [max_negative] => -4
    [kelas] => Positif
)
*/

算法

本库使用的算法是以下各所有者的知识产权。为了提高代码质量,该算法被应用于面向对象的设计中。如果您使用此程序,请引用本文。

  • Wahid, D. H., & Azhari, S. N. (2016). Peringkasan Sentimen Esktraktif di Twitter Menggunakan Hybrid TF-IDF dan Cosine Similarity. IJCCS (Indonesian Journal of Computing and Cybernetics Systems), 10(2), 207-218.

词典

此SentiStrength词典/词典来自sentistrength_id