提問: 調用自定義分詞檔會崩潰
// 以下代碼會造成程式崩潰 gojieba.NewJieba("./dict/a.txt")
請問這問題要如何處理呢?
OS: Debian Golang version: 1.8.1
// 以下崩潰訊息 2017-04-19 06:09:43 ./deps/cppjieba/DictTrie.hpp:160 FATAL exp: [buf.size() == DICT_COLUMN_NUM] false. split result illegal, line: SIGABRT: abort PC=0x7f3409ad3067 m=4 sigcode=18446744073709551610 signal arrived during cgo execution
goroutine 1 [syscall, locked to thread]: runtime.cgocall(0x6db7a0, 0xc42045fe00, 0xc42045fe00) /usr/local/go/src/runtime/cgocall.go:131 +0xe2 fp=0xc42045fdd0 sp=0xc42045fd90 github.com/yanyiwu/gojieba._Cfunc_NewJieba(0x7f34040008c0, 0x7f34040008e0, 0x7f3404000940, 0x7f34040009a0, 0x7f34040009f0, 0x0) github.com/yanyiwu/gojieba/_obj/_cgo_gotypes.go:214 +0x4e fp=0xc42045fe00 sp=0xc42045fdd0 github.com/yanyiwu/gojieba.NewJieba(0xc42045ff38, 0x1, 0x1, 0x0) /home/lifelong-study/go/src/github.com/yanyiwu/gojieba/jieba.go:43 +0x268 fp=0xc42045ff00 sp=0xc42045fe00 main.main() /home/lifelong-study/Desktop/Go/Jieba/Preupload/main.go:56 +0x1e9 fp=0xc42045ff88 sp=0xc42045ff00 runtime.main() /usr/local/go/src/runtime/proc.go:185 +0x20a fp=0xc42045ffe0 sp=0xc42045ff88 runtime.goexit() /usr/local/go/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc42045ffe8 sp=0xc42045ffe0
goroutine 17 [syscall, locked to thread]: runtime.goexit() /usr/local/go/src/runtime/asm_amd64.s:2197 +0x1
goroutine 5 [select]: github.com/blevesearch/bleve/index.AnalysisWorker(0xc42005c720, 0xc42005c780) /home/lifelong-study/go/src/github.com/blevesearch/bleve/index/analysis.go:75 +0x13a created by github.com/blevesearch/bleve/index.NewAnalysisQueue /home/lifelong-study/go/src/github.com/blevesearch/bleve/index/analysis.go:67 +0xdf
goroutine 6 [select]: github.com/blevesearch/bleve/index.AnalysisWorker(0xc42005c720, 0xc42005c780) /home/lifelong-study/go/src/github.com/blevesearch/bleve/index/analysis.go:75 +0x13a created by github.com/blevesearch/bleve/index.NewAnalysisQueue /home/lifelong-study/go/src/github.com/blevesearch/bleve/index/analysis.go:67 +0xdf
goroutine 7 [select]: github.com/blevesearch/bleve/index.AnalysisWorker(0xc42005c720, 0xc42005c780) /home/lifelong-study/go/src/github.com/blevesearch/bleve/index/analysis.go:75 +0x13a created by github.com/blevesearch/bleve/index.NewAnalysisQueue /home/lifelong-study/go/src/github.com/blevesearch/bleve/index/analysis.go:67 +0xdf
goroutine 8 [select]: github.com/blevesearch/bleve/index.AnalysisWorker(0xc42005c720, 0xc42005c780) /home/lifelong-study/go/src/github.com/blevesearch/bleve/index/analysis.go:75 +0x13a created by github.com/blevesearch/bleve/index.NewAnalysisQueue /home/lifelong-study/go/src/github.com/blevesearch/bleve/index/analysis.go:67 +0xdf
rax 0x0 rbx 0x7f3408a9a910 rcx 0xffffffffffffffff rdx 0x6 rdi 0x76c6 rsi 0x76c9 rbp 0x7f340a66a660 rsp 0x7f3408a9a548 r8 0x7f3408a9b700 r9 0x7f3408a9b700 r10 0x8 r11 0x206 r12 0x7f340a668740 r13 0x7f3408a9a690 r14 0x7f3408a9a700 r15 0x7f3408a9a730 rip 0x7f3409ad3067 rflags 0x206 cs 0x33 fs 0x0 gs 0x0 exit status 2 [Finished in 1.6s with exit code 1] [shell_cmd: go run /home/lifelong-study/Desktop/Go/Jieba/Preupload/main.go] [dir: /home/lifelong-study/Desktop/Go/Jieba/Preupload] [path: /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin]
很有可能是你的词典格式不正确,每行需要有三列,参考默认的词典 https://github.com/yanyiwu/gojieba/blob/master/dict/jieba.dict.utf8