Home >Database >Mysql Tutorial >全文索引--两种中文词法分析器比较(chinese_vgram_lexerchinese_

全文索引--两种中文词法分析器比较(chinese_vgram_lexerchinese_

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 16:05:181243browse

首先让我们进行一个关于中文词法分析器的比较,测试过程如下: 建表 create table test (str varchar2(100)) ;create table test1(str varchar2(100)) ; 插入数据 insert into test values (中华人员共和国) ;insert into test1values (中华人员共和国) ; 创

首先让我们进行一个关于中文词法分析器的比较,测试过程如下:

建表

create table test (str varchar2(100)) ;

create table test1(str varchar2(100)) ;
插入数据
insert into test values (‘中华人员共和国’) ;

insert into test1values (‘中华人员共和国’) ;
创建两个关于中文的分析器
exec ctx_ddl.create_preference('my_lexer','CHINESE_VGRAM_LEXER') ;
exec ctx_ddl.create_preference('my_lexer1','CHINESE_LEXER') ;
创建全文索引
CREATE INDEX test1_idx ON test1(str) INDEXTYPE IS ctxsys.CONTEXT PARAMETERS('LEXER my_lexer1');
CREATE INDEX test_idx ON test(str) INDEXTYPE IS ctxsys.CONTEXT PARAMETERS('LEXER my_lexer');
查看全文索引生成的词表

chinese_vgram_lexer
dexter@STARTREK>select * from DR$TEST_IDX$I ;

TOKEN_TEXT TOKEN_TYPE TOKEN_FIRST TOKEN_LAST TOKEN_COUNT
---------------------------------------------------------------- ---------- ----------- ---------- -----------
TOKEN_INFO
------------------------------------------------------------------------------------------------------------------------------------------------------
共和 0 1 1 1
008805

国 0 1 1 1
008807

和国 0 1 1 1
008806

华人 0 1 1 1
008802

人员 0 1 1 1
008803

员共 0 1 1 1
008804

中华 0 1 1 1
008801
chinese_lexer
dexter@STARTREK>select * from DR$TEST1_IDX$I ;

TOKEN_TEXT TOKEN_TYPE TOKEN_FIRST TOKEN_LAST TOKEN_COUNT
---------------------------------------------------------------- ---------- ----------- ---------- -----------
TOKEN_INFO
----------------------------------------------------------------------------------------------------------------------------
共和国 0 1 1 1
008803

人员 0 1 1 1
008802

中华 0 1 1 1
008801
分词效果:

分词效果:

chinese_ lexer

chinese_vgram_lexer

共和国

共和

人员

中华

和国

 

华人

 

人员

 

员共

 

中华


对于chinese_vgram_lexer来说,官方文档有这样的描述:

The CHINESE_VGRAM_LEXER type identifies tokens in Chinese text for creating Text indexes.

通过实验证明,其实就是按照相邻两个字来创建全文索引,对于我们正常的国内使用习惯来说明显是不适用的。

而对于chinese_ lexer来说,明显人性化了许多:

The CHINESE_LEXER type identifies tokens in traditional and simplified Chinese text for creating Oracle Text indexes.

通过实验证明,已经有了优化,没有生成过多的词表,这对于全文索引的优化来说是比较有意义的。并且chinese_lexer还允许自定义词表,通过屏蔽词,以及自定义词表可以进一步的加速全文索引的检索速度。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn