/ src / locale / ko / resources / Tokenizer.php
<?php
/**
 * SeekQuarry/Yioop --
 * Open Source Pure PHP Search Engine, Crawler, and Indexer
 *
 * Copyright (C) 2009 - 2026  Chris Pollett chris@pollett.org
 *
 * LICENSE:
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * @author Chris Pollett chris@pollett.org
 * @license https://www.gnu.org/licenses/ GPL3
 * @link https://www.seekquarry.com/
 * @copyright 2009 - 2026
 * @filesource
 */
namespace seekquarry\yioop\locale\ko\resources;

use seekquarry\yioop\models\LocaleModel;

/**
 * Korean specific tokenization code. Typically, tokenizer.php
 * either contains a stemmer for the language in question or
 * it specifies how many characters in a char gram
 *
 * @author Chris Pollett
 */
class Tokenizer
{
    /**
     * A list of frequently occurring terms for this locale which should
     * be excluded from certain kinds of queries. This is also used
     * for language detection
     * @var array
     */
    public static $stop_words = ['둜', 'λ‚˜λŠ”', '그의', 'κ·Έ', 'κ·Έ', 'ν–ˆλ‹€',
        '에 λŒ€ν•œ', '에', 'μ•„λ₯΄', '와', 'κ·Έλ“€', 'μžˆλ‹€', '에', '일', '이', '이',
        'λΆ€ν„°', '에 μ˜ν•΄', '뜨거운', '단어', 'ν•˜μ§€λ§Œ', '무엇', 'λ‹€μ†Œ', '이닀', 'κ·Έ',
        'λ‹Ήμ‹ ', 'λ˜λŠ”', 'ν–ˆλ‹€', '에', '의', '에', 'κ³Ό', '이', '에', '우리', '수',
        '아웃', 'λ‹€λ₯Έ', 'ν–ˆλ‹€', 'ν•˜λŠ”', 'ν• ', 'μžμ‹ μ˜', 'μ‹œκ°„', 'λ©΄', '것', '방법',
        'λ§ν–ˆλ‹€', '이', '각', '이야기', 'ν•˜μ§€', 'μ„ΈνŠΈ', 'μ„Έ', 'ν•„μš”', '곡기', '잘',
        'λ˜ν•œ', 'μž¬μƒ', 'μž‘μ€', '끝', 'λ„£μ–΄', 'ν™ˆ', '읽기', '손', '포트', '큰',
        '철자', 'μΆ”κ°€', '도', 'λ•…', 'μ—¬κΈ°', 'ν•΄μ•Ό', '큰', '높은', 'μ΄λŸ¬ν•œ', '따라',
        'ν–‰μœ„', '이유', '문의', 'λ‚¨μž', 'λ³€κ²½', 'κ°”λ‹€', 'λΉ›', 'μ’…λ₯˜', 'μ˜€ν”„',
        'ν•„μš”κ°€μžˆλ‹€', 'μ§‘', '사진', 'μ‹œν—˜', '우리', 'λ‹€μ‹œ', '동물', '포인트',
        'μ–΄λ¨Έλ‹ˆ', '세계', 'κ°€κΉŒμš΄', 'ꡬ좕', '자기', '지ꡬ', '아버지'];
    /**
     * How many characters in a char gram for this locale
     * @var int
     */
    public static $char_gram_len = 3;
    /**
     * Removes the stop words from the page (used for Word Cloud generation
     * and language detection)
     *
     * @param mixed $data either a string or an array of string to remove
     *      stop words from
     * @return mixed $data with no stop words
     */
    public static function stopwordsRemover($data)
    {
        static $pattern = "";
        if (empty($pattern)) {
            $pattern = '/(' . implode('|', self::$stop_words) . ')/u';
        }
        $data = preg_replace($pattern, '', $data);
        return $data;
    }
}
X