1、什么是分词器
分词器:给你一段句子,然后将这段句子拆分成一个一个的单个的单词,同时对每个单词进行normalization(时态转换,单复数转换)
分词器作用:切分词语,normalization(提升recall召回率)
character filter:在一段文本进行分词之前,先进行预处理,比如说最常见的就是,过滤html标签(hello --> hello),& -->and(I&you -->I and you)
tokenizer:分词,hello you and me -->hello,you,and ,me
token filter:lowercase ,stop word ,normalization (dogs -->dog ,liked -->like ,Tom -->tom , , a/the/an -->干掉,mother -->mom,small -->little)
一个分词器最重要的:将一段文本进行各种处理,最后处理好的结果才会拿去建立倒排索引。
2.内置分词器的介绍
测试文本:
Set the shape to semi-transparent by calling set_trans(5)
standard analyzer(标准分器):
set,the,shape,to,semi,transparent,by,calling,set_trans,5
可以看到大写转成小写,-去掉了,()去掉了。
simple analyzer(简单分词器):
set, the ,shape,to,semi,transparent,by,calling,set,trans
可以看到大写转成小写,-去掉了,_去掉了,(5)去掉了。
whitespace analyzer(空格分词器):
Set,the,shape,semi-transparent,by,calling,set_trans(5)
可以看到是以空格进行分词.
language analyzer(语言分词器,比如说英语分词器):
set,shape,semi,transpar,call,set_tran,5
可以看到大写转小写,the没有任何含义,被干掉了,以及一些拆分的,transparent转换成了transpar,calling转化时态call,等等
默认是standard analyzer(标准分器)。