PHP code example of ukkz / php-mecab-wrapper

1. Go to this page and download the library: Download ukkz/php-mecab-wrapper 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/ */

    

ukkz / php-mecab-wrapper example snippets


$mecab_sentence_class = new MeCab\Sentence("解析したい日本語文章", 辞書ディレクトリのパス);
$mecab_word_class_generator = $mecab_sentence_class->getWord();

foreach ($mecab_word_class_generator as $mecab_word_class) {
    // 形態素ごとの処理など
    echo $mecab_word_class . '/';
}
// 出力は "解析/し/たい/日本語/文章/" となります。