<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [Xunsearch PHP-SDK](http://www.xunsearch.com) v1.4.8 API 參考文檔 # XSTokenizerScws [All Packages](#)| [方法(函數)](#) | 包 | [XS.tokenizer](#) | |-----|-----| | 繼承關系 | class XSTokenizerScws | | 實現接口 | [XSTokenizer](#) | | 始于 | 1.3.1 | | 版本 | 1.0.0 | | 源代碼 | [sdk/php/lib/XSTokenizer.class.php](https://github.com/hightman/xunsearch/blob/master/sdk/php/lib/XSTokenizer.class.php) | SCWS - 分詞器(與搜索服務端通訊) ### Public 方法 [隱去繼承來的方法](#) | 名稱 | 描述 | 定義于 | |-----|-----|-----| | [__construct()](#) | 構造函數 | XSTokenizerScws | | [addDict()](#) | 添加分詞詞典, 支持 TXT/XDB 格式 | XSTokenizerScws | | [getResult()](#) | 獲取分詞結果 | XSTokenizerScws | | [getTokens()](#) | XSTokenizer 接口 | XSTokenizerScws | | [getTops()](#) | 獲取重要詞統計結果 | XSTokenizerScws | | [getVersion()](#) | 獲取 scws 版本號 | XSTokenizerScws | | [hasWord()](#) | 判斷是否包含指定詞性的詞 | XSTokenizerScws | | [setCharset()](#) | 設置字符集 | XSTokenizerScws | | [setDict()](#) | 設置分詞詞典, 支持 TXT/XDB 格式 | XSTokenizerScws | | [setDuality()](#) | 設置散字二元組合 | XSTokenizerScws | | [setIgnore()](#) | 設置忽略標點符號 | XSTokenizerScws | | [setMulti()](#) | 設置復合分詞選項 | XSTokenizerScws | ### 方法明細 __construct()方法 <table class="summaryTable"><tr><td colspan="3"><div class="signature2">public void <b>__construct</b>(string $arg=NULL)</div></td></tr><tr><td class="paramNameCol">$arg</td> <td class="paramTypeCol">string</td> <td class="paramDescCol">復合等級參數,默認不指定</td></tr></table> **源碼:**[sdk/php/lib/XSTokenizer.class.php#L188](https://github.com/hightman/xunsearch/blob/master/sdk/php/lib/XSTokenizer.class.php#L188) (**[顯示](#)**) `public?function?__construct($arg?=?null) { ????if?(self::$_server?===?null)?{ ????????$xs?=?XS::getLastXS(); ????????if?($xs?===?null)?{ ????????????throw?new?XSException('An?XS?instance?should?be?created?before?using?'?.?__CLASS__); ????????} ????????self::$_server?=?$xs->getScwsServer(); ????????self::$_server->setTimeout(0); ????????self::$_charset?=?$xs->getDefaultCharset(); ????????//?constants ????????if?(!defined('SCWS_MULTI_NONE'))?{ ????????????define('SCWS_MULTI_NONE',?0); ????????????define('SCWS_MULTI_SHORT',?1); ????????????define('SCWS_MULTI_DUALITY',?2); ????????????define('SCWS_MULTI_ZMAIN',?4); ????????????define('SCWS_MULTI_ZALL',?8); ????????} ????????if?(!defined('SCWS_XDICT_XDB'))?{ ????????????define('SCWS_XDICT_XDB',?1); ????????????define('SCWS_XDICT_MEM',?2); ????????????define('SCWS_XDICT_TXT',?4); ????????} ????} ????if?($arg?!==?null?&&?$arg?!==?'')?{ ????????$this->setMulti($arg); ????} }` 構造函數初始化用于分詞的搜索服務端 addDict()方法 <table class="summaryTable"><tr><td colspan="3"><div class="signature2">public XSTokenizerScws <b>addDict</b>(string $fpath, int $mode=NULL)</div></td></tr><tr><td class="paramNameCol">$fpath</td> <td class="paramTypeCol">string</td> <td class="paramDescCol">服務端的詞典路徑</td></tr><tr><td class="paramNameCol">$mode</td> <td class="paramTypeCol">int</td> <td class="paramDescCol">詞典類型, 常量: SCWS_XDICT_XDB|SCWS_XDICT_TXT|SCWS_XDICT_MEM</td></tr><tr><td class="paramNameCol">{return}</td> <td class="paramTypeCol">XSTokenizerScws</td> <td class="paramDescCol">返回對象本身以支持串接操作</td></tr></table> **源碼:**[sdk/php/lib/XSTokenizer.class.php#L299](https://github.com/hightman/xunsearch/blob/master/sdk/php/lib/XSTokenizer.class.php#L299) (**[顯示](#)**) `public?function?addDict($fpath,?$mode?=?null) { ????if?(!is_int($mode))?{ ????????$mode?=?stripos($fpath,?'.txt')?!==?false???SCWS_XDICT_TXT?:?SCWS_XDICT_XDB; ????} ????if?(!isset($this->_setting['add_dict']))?{ ????????$this->_setting['add_dict']?=?array(); ????} ????$this->_setting['add_dict'][]?=?new?XSCommand(CMD_SEARCH_SCWS_SET,?CMD_SCWS_ADD_DICT,?$mode,?$fpath); ????return?$this; }` 添加分詞詞典, 支持 TXT/XDB 格式 getResult()方法 <table class="summaryTable"><tr><td colspan="3"><div class="signature2">public array <b>getResult</b>(string $text)</div></td></tr><tr><td class="paramNameCol">$text</td> <td class="paramTypeCol">string</td> <td class="paramDescCol">待分詞的文本</td></tr><tr><td class="paramNameCol">{return}</td> <td class="paramTypeCol">array</td> <td class="paramDescCol">返回詞匯數組, 每個詞匯是包含 [off:詞在文本中的位置,attr:詞性,word:詞]</td></tr></table> **源碼:**[sdk/php/lib/XSTokenizer.class.php#L339](https://github.com/hightman/xunsearch/blob/master/sdk/php/lib/XSTokenizer.class.php#L339) (**[顯示](#)**) `public?function?getResult($text) { ????$words?=?array(); ????$text?=?$this->applySetting($text); ????$cmd?=?new?XSCommand(CMD_SEARCH_SCWS_GET,?CMD_SCWS_GET_RESULT,?0,?$text); ????$res?=?self::$_server->execCommand($cmd,?CMD_OK_SCWS_RESULT); ????while?($res->buf?!==?'')?{ ????????$tmp?=?unpack('Ioff/a4attr/a*word',?$res->buf); ????????$tmp['word']?=?XS::convert($tmp['word'],?self::$_charset,?'UTF-8'); ????????$words[]?=?$tmp; ????????$res?=?self::$_server->getRespond(); ????} ????return?$words; }` 獲取分詞結果 getTokens()方法 <table class="summaryTable"><tr><td colspan="3"><div class="signature2">public void <b>getTokens</b>($value, $doc=NULL)</div></td></tr><tr><td class="paramNameCol">$value</td> <td class="paramTypeCol"></td> <td class="paramDescCol"></td></tr><tr><td class="paramNameCol">$doc</td> <td class="paramTypeCol"></td> <td class="paramDescCol"></td></tr></table> **源碼:**[sdk/php/lib/XSTokenizer.class.php#L220](https://github.com/hightman/xunsearch/blob/master/sdk/php/lib/XSTokenizer.class.php#L220) (**[顯示](#)**) `public?function?getTokens($value,?XSDocument?$doc?=?null) { ????$tokens?=?array(); ????$this->setIgnore(true); ????//?save?charset,?force?to?use?UTF-8 ????$_charset?=?self::$_charset; ????self::$_charset?=?'UTF-8'; ????$words?=?$this->getResult($value); ????foreach?($words?as?$word)?{ ????????$tokens[]?=?$word['word']; ????} ????//?restore?charset ????self::$_charset?=?$_charset; ????return?$tokens; }` XSTokenizer 接口 getTops()方法 <table class="summaryTable"><tr><td colspan="3"><div class="signature2">public array <b>getTops</b>(string $text, string $limit=10, $xattr='')</div></td></tr><tr><td class="paramNameCol">$text</td> <td class="paramTypeCol">string</td> <td class="paramDescCol">待分詞的文本</td></tr><tr><td class="paramNameCol">$limit</td> <td class="paramTypeCol">string</td> <td class="paramDescCol">在返回結果的詞性過濾, 多個詞性之間用逗號分隔, 以~開頭取反 如: 設為 n,v 表示只返回名詞和動詞; 設為 ~n,v 則表示返回名詞和動詞以外的其它詞</td></tr><tr><td class="paramNameCol">$xattr</td> <td class="paramTypeCol"></td> <td class="paramDescCol"></td></tr><tr><td class="paramNameCol">{return}</td> <td class="paramTypeCol">array</td> <td class="paramDescCol">返回詞匯數組, 每個詞匯是包含 [times:次數,attr:詞性,word:詞]</td></tr></table> **源碼:**[sdk/php/lib/XSTokenizer.class.php#L361](https://github.com/hightman/xunsearch/blob/master/sdk/php/lib/XSTokenizer.class.php#L361) (**[顯示](#)**) `public?function?getTops($text,?$limit?=?10,?$xattr?=?'') { ????$words?=?array(); ????$text?=?$this->applySetting($text); ????$cmd?=?new?XSCommand(CMD_SEARCH_SCWS_GET,?CMD_SCWS_GET_TOPS,?$limit,?$text,?$xattr); ????$res?=?self::$_server->execCommand($cmd,?CMD_OK_SCWS_TOPS); ????while?($res->buf?!==?'')?{ ????????$tmp?=?unpack('Itimes/a4attr/a*word',?$res->buf); ????????$tmp['word']?=?XS::convert($tmp['word'],?self::$_charset,?'UTF-8'); ????????$words[]?=?$tmp; ????????$res?=?self::$_server->getRespond(); ????} ????return?$words; }` 獲取重要詞統計結果 getVersion()方法 <table class="summaryTable"><tr><td colspan="3"><div class="signature2">public string <b>getVersion</b>()</div></td></tr><tr><td class="paramNameCol">{return}</td> <td class="paramTypeCol">string</td> <td class="paramDescCol">版本號</td></tr></table> **源碼:**[sdk/php/lib/XSTokenizer.class.php#L327](https://github.com/hightman/xunsearch/blob/master/sdk/php/lib/XSTokenizer.class.php#L327) (**[顯示](#)**) `public?function?getVersion() { ????$cmd?=?new?XSCommand(CMD_SEARCH_SCWS_GET,?CMD_SCWS_GET_VERSION); ????$res?=?self::$_server->execCommand($cmd,?CMD_OK_INFO); ????return?$res->buf; }` 獲取 scws 版本號 hasWord()方法 <table class="summaryTable"><tr><td colspan="3"><div class="signature2">public bool <b>hasWord</b>(string $text, string $xattr)</div></td></tr><tr><td class="paramNameCol">$text</td> <td class="paramTypeCol">string</td> <td class="paramDescCol">要判斷的文本</td></tr><tr><td class="paramNameCol">$xattr</td> <td class="paramTypeCol">string</td> <td class="paramDescCol">要判斷的詞性, 參見 <a href="XSTokenizerScws.html#getTops">getTops</a> 的說明</td></tr><tr><td class="paramNameCol">{return}</td> <td class="paramTypeCol">bool</td> <td class="paramDescCol">文本中是否包含指定詞性的詞匯</td></tr></table> **源碼:**[sdk/php/lib/XSTokenizer.class.php#L382](https://github.com/hightman/xunsearch/blob/master/sdk/php/lib/XSTokenizer.class.php#L382) (**[顯示](#)**) `public?function?hasWord($text,?$xattr) { ????$text?=?$this->applySetting($text); ????$cmd?=?new?XSCommand(CMD_SEARCH_SCWS_GET,?CMD_SCWS_HAS_WORD,?0,?$text,?$xattr); ????$res?=?self::$_server->execCommand($cmd,?CMD_OK_INFO); ????return?$res->buf?===?'OK'; }` 判斷是否包含指定詞性的詞 setCharset()方法 <table class="summaryTable"><tr><td colspan="3"><div class="signature2">public XSTokenizerScws <b>setCharset</b>(string $charset)</div></td></tr><tr><td class="paramNameCol">$charset</td> <td class="paramTypeCol">string</td> <td class="paramDescCol"></td></tr><tr><td class="paramNameCol">{return}</td> <td class="paramTypeCol">XSTokenizerScws</td> <td class="paramDescCol">返回對象本身以支持串接操作</td></tr></table> **源碼:**[sdk/php/lib/XSTokenizer.class.php#L242](https://github.com/hightman/xunsearch/blob/master/sdk/php/lib/XSTokenizer.class.php#L242) (**[顯示](#)**) `public?function?setCharset($charset) { ????self::$_charset?=?strtoupper($charset); ????if?(self::$_charset?==?'UTF8')?{ ????????self::$_charset?=?'UTF-8'; ????} ????return?$this; }` 設置字符集默認字符集是 UTF-8, 這是指 [getResult](#) 系列函數的 $text 參數的字符集 setDict()方法 <table class="summaryTable"><tr><td colspan="3"><div class="signature2">public XSTokenizerScws <b>setDict</b>(string $fpath, int $mode=NULL)</div></td></tr><tr><td class="paramNameCol">$fpath</td> <td class="paramTypeCol">string</td> <td class="paramDescCol">服務端的詞典路徑</td></tr><tr><td class="paramNameCol">$mode</td> <td class="paramTypeCol">int</td> <td class="paramDescCol">詞典類型, 常量: SCWS_XDICT_XDB|SCWS_XDICT_TXT|SCWS_XDICT_MEM</td></tr><tr><td class="paramNameCol">{return}</td> <td class="paramTypeCol">XSTokenizerScws</td> <td class="paramDescCol">返回對象本身以支持串接操作</td></tr></table> **源碼:**[sdk/php/lib/XSTokenizer.class.php#L283](https://github.com/hightman/xunsearch/blob/master/sdk/php/lib/XSTokenizer.class.php#L283) (**[顯示](#)**) `public?function?setDict($fpath,?$mode?=?null) { ????if?(!is_int($mode))?{ ????????$mode?=?stripos($fpath,?'.txt')?!==?false???SCWS_XDICT_TXT?:?SCWS_XDICT_XDB; ????} ????$this->_setting['set_dict']?=?new?XSCommand(CMD_SEARCH_SCWS_SET,?CMD_SCWS_SET_DICT,?$mode,?$fpath); ????unset($this->_setting['add_dict']); ????return?$this; }` 設置分詞詞典, 支持 TXT/XDB 格式 setDuality()方法 <table class="summaryTable"><tr><td colspan="3"><div class="signature2">public XSTokenizerScws <b>setDuality</b>(bool $yes=true)</div></td></tr><tr><td class="paramNameCol">$yes</td> <td class="paramTypeCol">bool</td> <td class="paramDescCol">是否開啟散字自動二分組合功能</td></tr><tr><td class="paramNameCol">{return}</td> <td class="paramTypeCol">XSTokenizerScws</td> <td class="paramDescCol">返回對象本身以支持串接操作</td></tr></table> **源碼:**[sdk/php/lib/XSTokenizer.class.php#L316](https://github.com/hightman/xunsearch/blob/master/sdk/php/lib/XSTokenizer.class.php#L316) (**[顯示](#)**) `public?function?setDuality($yes?=?true) { ????$this->_setting['duality']?=?new?XSCommand(CMD_SEARCH_SCWS_SET,?CMD_SCWS_SET_DUALITY,?$yes?===?false ??????????????????????????0?:?1); ????return?$this; }` 設置散字二元組合 setIgnore()方法 <table class="summaryTable"><tr><td colspan="3"><div class="signature2">public XSTokenizerScws <b>setIgnore</b>(bool $yes=true)</div></td></tr><tr><td class="paramNameCol">$yes</td> <td class="paramTypeCol">bool</td> <td class="paramDescCol">是否忽略</td></tr><tr><td class="paramNameCol">{return}</td> <td class="paramTypeCol">XSTokenizerScws</td> <td class="paramDescCol">返回對象本身以支持串接操作</td></tr></table> **源碼:**[sdk/php/lib/XSTokenizer.class.php#L256](https://github.com/hightman/xunsearch/blob/master/sdk/php/lib/XSTokenizer.class.php#L256) (**[顯示](#)**) `public?function?setIgnore($yes?=?true) { ????$this->_setting['ignore']?=?new?XSCommand(CMD_SEARCH_SCWS_SET,?CMD_SCWS_SET_IGNORE,?$yes?===?false ??????????????????????????0?:?1); ????return?$this; }` 設置忽略標點符號 setMulti()方法 <table class="summaryTable"><tr><td colspan="3"><div class="signature2">public XSTokenizerScws <b>setMulti</b>(int $mode=3)</div></td></tr><tr><td class="paramNameCol">$mode</td> <td class="paramTypeCol">int</td> <td class="paramDescCol">復合選項, 值范圍 0~15 默認為值為 3, 可使用常量組合: SCWS_MULTI_SHORT|SCWS_MULTI_DUALITY|SCWS_MULTI_ZMAIN|SCWS_MULTI_ZALL</td></tr><tr><td class="paramNameCol">{return}</td> <td class="paramTypeCol">XSTokenizerScws</td> <td class="paramDescCol">返回對象本身以支持串接操作</td></tr></table> **源碼:**[sdk/php/lib/XSTokenizer.class.php#L270](https://github.com/hightman/xunsearch/blob/master/sdk/php/lib/XSTokenizer.class.php#L270) (**[顯示](#)**) `public?function?setMulti($mode?=?3) { ????$mode?=?intval($mode)?&?self::MULTI_MASK; ????$this->_setting['multi']?=?new?XSCommand(CMD_SEARCH_SCWS_SET,?CMD_SCWS_SET_MULTI,?$mode); ????return?$this; }` 設置復合分詞選項 Copyright ? 2008-2011 by [杭州云圣網絡科技有限公司](http://www.xunsearch.com) All Rights Reserved.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看