<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 12.8\. 測試和調試文本搜索 一個自定義文本搜索配置的行為很容易變得混亂。在本節中描述的函數對測試文本搜索對象是有用的。 你可以測試一個完整的配置,或分別測試分析器和詞典。 ## 12.8.1\. 配置測試 函數`ts_debug`允許簡單測試文本搜索配置。 ``` ts_debug([ `_config_` `regconfig`, ] _document_ text, OUT _alias_ text, OUT _description_ text, OUT _token_ text, OUT _dictionaries_ regdictionary[], OUT _dictionary_ regdictionary, OUT _lexemes_ text[]) returns setof record ``` `ts_debug`顯示關于通過解析器產生的和通過配置詞典處理的`_document_`的每個標記的信息。 如果忽略參數,它使用通過`_config_`或者`default_text_search_config`指定的配置。 `ts_debug`返回通過文本解析器標識的每個標記的每一行,返回的列是: * `_alias_` `text` —標記類型的別名 * `_description_` `text` —標記類型描述 * `_token_` `text` —標記文本 * `_dictionaries_` `regdictionary[]` —通過配置為這個標記類型選定的詞典 * `_dictionary_` `regdictionary` —詞典公認的標記,如果不這樣,則為`空`。 * `_lexemes_` `text[]` — 公認標記的詞典產生的詞(s),或者如果不做則為`NULL`;空數組(`{}`)意味著它是公認的屏蔽詞。 一個簡單例子: ``` SELECT * FROM ts_debug('english','a fat cat sat on a mat - it ate a fat rats'); alias | description | token | dictionaries | dictionary | lexemes -----------+-----------------+-------+----------------+--------------+--------- asciiword | Word, all ASCII | a | {english_stem} | english_stem | {} blank | Space symbols | | {} | | asciiword | Word, all ASCII | fat | {english_stem} | english_stem | {fat} blank | Space symbols | | {} | | asciiword | Word, all ASCII | cat | {english_stem} | english_stem | {cat} blank | Space symbols | | {} | | asciiword | Word, all ASCII | sat | {english_stem} | english_stem | {sat} blank | Space symbols | | {} | | asciiword | Word, all ASCII | on | {english_stem} | english_stem | {} blank | Space symbols | | {} | | asciiword | Word, all ASCII | a | {english_stem} | english_stem | {} blank | Space symbols | | {} | | asciiword | Word, all ASCII | mat | {english_stem} | english_stem | {mat} blank | Space symbols | | {} | | blank | Space symbols | - | {} | | asciiword | Word, all ASCII | it | {english_stem} | english_stem | {} blank | Space symbols | | {} | | asciiword | Word, all ASCII | ate | {english_stem} | english_stem | {ate} blank | Space symbols | | {} | | asciiword | Word, all ASCII | a | {english_stem} | english_stem | {} blank | Space symbols | | {} | | asciiword | Word, all ASCII | fat | {english_stem} | english_stem | {fat} blank | Space symbols | | {} | | asciiword | Word, all ASCII | rats | {english_stem} | english_stem | {rat} ``` 一個更廣泛的例子,我們首先用英語創建一個 `public.english`配置和Ispell詞典: ``` CREATE TEXT SEARCH CONFIGURATION public.english ( COPY = pg_catalog.english ); CREATE TEXT SEARCH DICTIONARY english_ispell ( TEMPLATE = ispell, DictFile = english, AffFile = english, StopWords = english ); ALTER TEXT SEARCH CONFIGURATION public.english ALTER MAPPING FOR asciiword WITH english_ispell, english_stem; ``` ``` SELECT * FROM ts_debug('public.english','The Brightest supernovaes'); alias | description | token | dictionaries | dictionary | lexemes -----------+-----------------+-------------+-------------------------------+----------------+------------- asciiword | Word, all ASCII | The | {english_ispell,english_stem} | english_ispell | {} blank | Space symbols | | {} | | asciiword | Word, all ASCII | Brightest | {english_ispell,english_stem} | english_ispell | {bright} blank | Space symbols | | {} | | asciiword | Word, all ASCII | supernovaes | {english_ispell,english_stem} | english_stem | {supernova} ``` 在這個例子中,`Brightest`是由解析器作為`ASCII詞`來標識(別名`asciiword`)。 為這個標識類型,詞典列表是`english_ispell`和`english_stem`。這個詞通過`english_ispell`標識, 歸納它為名詞`bright`。詞`supernovaes`于`english_ispell`詞典是未知的,所以它傳遞給下一個詞典, 幸運的是,是公認的(事實上,`english_stem`是一個識別一切的Snowball詞典; 這就是為什么它被放置在詞典列表末尾的原因)。 詞`The`是由 `english_ispell`詞典被公認為屏蔽詞(節[Section 12.6.1](#calibre_link-1118)),不會被索引。 空間也被丟棄,因為該配置根本沒有為它們提供詞典。 你可以通過明確指定你想要查看的列減少輸出的寬度: ``` SELECT alias, token, dictionary, lexemes FROM ts_debug('public.english','The Brightest supernovaes'); alias | token | dictionary | lexemes -----------+-------------+----------------+------------- asciiword | The | english_ispell | {} blank | | | asciiword | Brightest | english_ispell | {bright} blank | | | asciiword | supernovaes | english_stem | {supernova} ``` ## 12.8.2\. 解析器測試 下列函數允許直接測試文本搜索解析器。 ``` ts_parse(_parser_name_ text, _document_ text, OUT _tokid_ integer, OUT _token_ text) returns setof record ts_parse(_parser_oid_ oid, _document_ text, OUT _tokid_ integer, OUT _token_ text) returns setof record ``` `ts_parse`解析給定的`_document_`并返回一系列的記錄,每一個標記通過解析而產生。 每個記錄包括`tokid`顯示已分配的標記類型,并且`token`是標記的文本。比如: ``` SELECT * FROM ts_parse('default', '123 - a number'); tokid | token -------+-------- 22 | 123 12 | 12 | - 1 | a 12 | 1 | number ``` ``` ts_token_type(_parser_name_ text, OUT _tokid_ integer, OUT _alias_ text, OUT _description_ text) returns setof record ts_token_type(_parser_oid_ oid, OUT _tokid_ integer, OUT _alias_ text, OUT _description_ text) returns setof record ``` `ts_token_type`返回一個表,這個表描述了每種可以識別的指定分析器標記類型。 每個標記類型,該表給出了整數`tokid`,解析器用于標記那個類型標記,`alias`命名配置命令的標記類型, 并且簡稱`description`。比如: ``` SELECT * FROM ts_token_type('default'); tokid | alias | description -------+-----------------+------------------------------------------ 1 | asciiword | Word, all ASCII 2 | word | Word, all letters 3 | numword | Word, letters and digits 4 | email | Email address 5 | url | URL 6 | host | Host 7 | sfloat | Scientific notation 8 | version | Version number 9 | hword_numpart | Hyphenated word part, letters and digits 10 | hword_part | Hyphenated word part, all letters 11 | hword_asciipart | Hyphenated word part, all ASCII 12 | blank | Space symbols 13 | tag | XML tag 14 | protocol | Protocol head 15 | numhword | Hyphenated word, letters and digits 16 | asciihword | Hyphenated word, all ASCII 17 | hword | Hyphenated word, all letters 18 | url_path | URL path 19 | file | File or path name 20 | float | Decimal notation 21 | int | Signed integer 22 | uint | Unsigned integer 23 | entity | XML entity ``` ## 12.8.3\. 詞典測試 `ts_lexize`函數有易于進行詞典測試。 ``` ts_lexize(_dict_ regdictionary, _token_ text) returns text[] ``` 如果輸入`_token_`為詞典已知的,那么`ts_lexize`返回詞的數組,如果這個token對詞典是已知的, 但它是一個屏蔽詞,則返回空數組。如果它是一個未知的詞則返回`NULL`。 比如: ``` SELECT ts_lexize('english_stem', 'stars'); ts_lexize ----------- {star} SELECT ts_lexize('english_stem', 'a'); ts_lexize ----------- {} ``` > **Note:** `ts_lexize`函數需要單一_標記_,沒有文本。這是一種引起混淆的情況: > > ``` > SELECT ts_lexize('thesaurus_astro','supernovae stars') is null; > ?column? > ---------- > t > ``` > > 同義詞詞典`thesaurus_astro`確實知道短語`supernovae stars`,但`ts_lexize`失敗了, 因為它不解析輸入文本,而是把它作為一個單一標記。 使用`plainto_tsquery`或者`to_tsvector`測試同義詞詞典,例如: > > ``` > SELECT plainto_tsquery('supernovae stars'); > plainto_tsquery > ----------------- > 'sn' > ```
                  <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>

                              哎呀哎呀视频在线观看