mirror of
https://github.com/fumiama/jieba.git
synced 2026-06-28 16:10:32 +08:00
small tweaks, added bench.sh for benchmark
This commit is contained in:
5
posseg/bench.sh
Executable file
5
posseg/bench.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
go test -run=XXX -v -bench=BenchmarkViterbi -benchtime 10s -benchmem -memprofile viterbi-mem.out -cpuprofile viterbi-cpu.out
|
||||||
|
go tool pprof -png -output ~/tmp/viterbi-cpu.png posseg.test viterbi-cpu.out
|
||||||
|
go tool pprof -png -output ~/tmp/viterbi-mem.png posseg.test viterbi-mem.out
|
||||||
@@ -4,13 +4,15 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var inf = math.Inf(-1)
|
||||||
|
|
||||||
type probTransMap map[string]float64
|
type probTransMap map[string]float64
|
||||||
|
|
||||||
func (m probTransMap) Get(key string) float64 {
|
func (m probTransMap) Get(key string) float64 {
|
||||||
if value, ok := m[key]; ok {
|
if value, ok := m[key]; ok {
|
||||||
return value
|
return value
|
||||||
} else {
|
} else {
|
||||||
return math.Inf(-1)
|
return inf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user