PHP code example of 369work / yakki-checker

1. Go to this page and download the library: Download 369work/yakki-checker 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/ */

    

369work / yakki-checker example snippets


use MisleadingChecker\MisleadingChecker;

$checker = new MisleadingChecker();
$result = $checker->check('この商品は必ず治る!今だけ半額');

if ($result->hasViolations()) {
    foreach ($result->getViolations() as $v) {
        echo "❌ {$v->word}: {$v->reason}\n";
        echo "   → 提案: {$v->suggestion}\n";
    }
}

use MisleadingChecker\Preset\CosmeticsPreset;
use MisleadingChecker\Preset\SupplementPreset;
use MisleadingChecker\Preset\MedicalDevicePreset;

// 化粧品向けチェック
$checker->applyPreset(new CosmeticsPreset());

// サプリメント向けチェック
$checker->applyPreset(new SupplementPreset());

// 医療機器向けチェック
$checker->applyPreset(new MedicalDevicePreset());

use MisleadingChecker\Dictionary\CustomDictionary;

$custom = new CustomDictionary('自社ルール');
$custom->addEntry('当社比', '比較対象を明確にしてください', '具体的な数値で比較');

$checker->addDictionary($custom);

$json = file_get_contents('my-dictionary.json');
$dict = CustomDictionary::fromJSON($json, 'カスタム');
$checker->addDictionary($dict);

// 配列
$result->toArray();

// JSON
$result->toJSON(JSON_PRETTY_PRINT);

// カテゴリ別に集計
$result->groupByCategory();