/ src / locale / bn / 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 Snigdha Rao Parvatneni
 * @license https://www.gnu.org/licenses/ GPL3
 * @link https://www.seekquarry.com/
 * @copyright 2009 - 2026
 * @filesource
 */
namespace seekquarry\yioop\locale\bn\resources;

/**
 * Bengali 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 = 5;
    /**
     * 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 = '/\b(' . implode('|', self::$stop_words) . ')\b/u';
        }
        $data = preg_replace($pattern, '', $data);
        return $data;
    }
}
X