Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

开启NotUsingSegmenter后,程序会panic #55

Open
zannet opened this issue Aug 3, 2016 · 0 comments
Open

开启NotUsingSegmenter后,程序会panic #55

zannet opened this issue Aug 3, 2016 · 0 comments

Comments

@zannet
Copy link

zannet commented Aug 3, 2016

引擎初始化开启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: "中"}))

}

这个段程序无法执行。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant