1
0
mirror of https://github.com/fumiama/jieba.git synced 2026-06-28 16:10:32 +08:00

优化 textrank

This commit is contained in:
源文雨
2022-11-30 12:38:47 +08:00
parent 8bbc755ed4
commit 21cdb2e863
5 changed files with 176 additions and 140 deletions

View File

@@ -26,7 +26,7 @@ func (s Segment) Weight() float64 {
}
// Segments represents a slice of Segment.
type Segments []Segment
type Segments []*Segment
func (ss Segments) Len() int {
return len(ss)
@@ -103,7 +103,7 @@ func (t *TagExtracter) ExtractTags(sentence string, topK int) (tags Segments) {
} else {
s = Segment{text: k, weight: t.idf.median * v}
}
ws = append(ws, s)
ws = append(ws, &s)
}
sort.Sort(sort.Reverse(ws))
if len(ws) > topK {