1
0
mirror of https://github.com/fumiama/jieba.git synced 2026-07-02 10:00:27 +08:00

fix performance problem of extrag_tags, corresponding to jieba commit #eb98eb92484d3d302cd96049be43c224fe45414a

This commit is contained in:
Wang Bin
2015-01-26 18:31:10 +08:00
parent 2b15490388
commit b828b25f67
3 changed files with 67 additions and 16 deletions

View File

@@ -57,10 +57,10 @@ func ExtractTags(sentence string, topK int) []string {
tis := make(TfIdfs, 0)
for k, v := range freq {
var ti TfIdf
if freq_, ok := idfFreq[k]; ok {
if freq_, ok := idfLoader.Freq[k]; ok {
ti = TfIdf{word: k, freq: freq_ * v}
} else {
ti = TfIdf{word: k, freq: medianIdf * v}
ti = TfIdf{word: k, freq: idfLoader.Median * v}
}
tis = append(tis, ti)
}