wukong icon indicating copy to clipboard operation
wukong copied to clipboard

开启NotUsingSegmenter后,程序会panic

Open zannet opened this issue 7 years ago • 0 comments

引擎初始化开启NotUsingSegmenter,运行程序会出现panic,比如用以下例子:

package main

import ( "github.com/huichen/wukong/engine" "github.com/huichen/wukong/types" "log" )

var ( // searcher是线程安全的 searcher = engine.Engine{} )

func main() { // 初始化 searcher.Init(types.EngineInitOptions{ SegmenterDictionaries: "../../data/dictionary.txt", NotUsingSegmenter: true, }) defer searcher.Close()

// 将文档加入索引,docId 从1开始
searcher.IndexDocument(1, types.DocumentIndexData{Content: "此次百度收购将成中国互联网最大并购"}, false)
searcher.IndexDocument(2, types.DocumentIndexData{Content: "百度宣布拟全资收购91无线业务"}, false)
searcher.IndexDocument(3, types.DocumentIndexData{Content: "百度是中国最大的搜索引擎"}, false)

// 等待索引刷新完毕
searcher.FlushIndex()

// 搜索输出格式见types.SearchResponse结构体
log.Print(searcher.Search(types.SearchRequest{Text: "中"}))

}

这个段程序无法执行。

zannet avatar Aug 03 '16 06:08 zannet