[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_finder 6 * 7 * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Finder\Administrator\Indexer\Language; 12 13 use Joomla\Component\Finder\Administrator\Indexer\Language; 14 use Joomla\String\StringHelper; 15 16 // phpcs:disable PSR1.Files.SideEffects 17 \defined('_JEXEC') or die; 18 // phpcs:enable PSR1.Files.SideEffects 19 20 /** 21 * Chinese (simplified) language support class for the Finder indexer package. 22 * 23 * @since 4.0.0 24 */ 25 class Zh extends Language 26 { 27 /** 28 * Language locale of the class 29 * 30 * @var string 31 * @since 4.0.0 32 */ 33 public $language = 'zh'; 34 35 /** 36 * Spacer between terms 37 * 38 * @var string 39 * @since 4.0.0 40 */ 41 public $spacer = ''; 42 43 /** 44 * Method to construct the language object. 45 * 46 * @since 4.0.0 47 */ 48 public function __construct($locale = null) 49 { 50 // Override parent constructor since we don't need to load an external stemmer 51 } 52 53 /** 54 * Method to tokenise a text string. 55 * 56 * @param string $input The input to tokenise. 57 * 58 * @return array An array of term strings. 59 * 60 * @since 4.0.0 61 */ 62 public function tokenise($input) 63 { 64 $terms = parent::tokenise($input); 65 66 // Iterate through the terms and test if they contain Chinese. 67 for ($i = 0, $n = count($terms); $i < $n; $i++) { 68 $charMatches = array(); 69 $charCount = preg_match_all('#[\p{Han}]#mui', $terms[$i], $charMatches); 70 71 // Split apart any groups of Chinese characters. 72 for ($j = 0; $j < $charCount; $j++) { 73 $tSplit = StringHelper::str_ireplace($charMatches[0][$j], '', $terms[$i], false); 74 75 if (!empty($tSplit)) { 76 $terms[$i] = $tSplit; 77 } else { 78 unset($terms[$i]); 79 } 80 81 $terms[] = $charMatches[0][$j]; 82 } 83 } 84 85 return $terms; 86 } 87 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |