1. Go to this page and download the library: Download nyancodeid/sastrawi library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nyancodeid / sastrawi example snippets
// demo.php
// include composer autoloader
a, biasanya didaftarkan di service container
$stemmerFactory = new \Sastrawi\Stemmer\StemmerFactory();
$stemmer = $stemmerFactory->createStemmer();
// stem
$sentence = 'Perekonomian Indonesia sedang dalam pertumbuhan yang membanggakan';
$output = $stemmer->stem($sentence);
echo $output . "\n";
// ekonomi indonesia sedang dalam tumbuh yang bangga
echo $stemmer->stem('Mereka meniru-nirukannya') . "\n";
// mereka tiru
// include composer autoloader
n sekali saja, biasanya didaftarkan di service container
$stemmerFactory = new \Sastrawi\Stemmer\StemmerFactory();
$dictionary = $stemmerFactory->createDefaultDictionary();
$dictionary->addWordsFromTextFile(__DIR__.'/my-dictionary.txt');
$dictionary->add('internet');
$dictionary->remove('desa');
$stemmer = new \Sastrawi\Stemmer\Stemmer($dictionary);
var_dump($stemmer->stem('internetan')); //internet
bash
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.