1
0
mirror of https://github.com/fumiama/jieba.git synced 2026-06-30 09:00:30 +08:00

removed third party dependency

This commit is contained in:
Wang Bin
2015-02-26 17:45:59 +08:00
parent f6c298fc65
commit ed0bc44921

View File

@@ -2,7 +2,6 @@ package analyse
import ( import (
"fmt" "fmt"
mapset "github.com/deckarep/golang-set"
"github.com/wangbin/jiebago/posseg" "github.com/wangbin/jiebago/posseg"
"math" "math"
"sort" "sort"
@@ -117,21 +116,21 @@ func (u *undirectWeightedGraph) rank() TfIdfs {
} }
func TextRankWithPOS(sentence string, topK int, allowPOS []string) TfIdfs { func TextRankWithPOS(sentence string, topK int, allowPOS []string) TfIdfs {
posFilt := mapset.NewSet() posFilt := make(map[string]int)
for _, pos := range allowPOS { for _, pos := range allowPOS {
posFilt.Add(pos) posFilt[pos] = 1
} }
g := newUndirectWeightedGraph() g := newUndirectWeightedGraph()
cm := make(map[[2]string]float64) cm := make(map[[2]string]float64)
span := 5 span := 5
wordTags := posseg.Cut(sentence, true) wordTags := posseg.Cut(sentence, true)
for i, _ := range wordTags { for i, _ := range wordTags {
if posFilt.Contains(wordTags[i].Tag) { if _, ok := posFilt[wordTags[i].Tag]; ok {
for j := i + 1; j < i+span; j++ { for j := i + 1; j < i+span; j++ {
if j > len(wordTags) { if j > len(wordTags) {
break break
} }
if !posFilt.Contains(wordTags[j].Tag) { if _, ok := posFilt[wordTags[j].Tag]; !ok {
continue continue
} }
if _, ok := cm[[2]string{wordTags[i].Word, wordTags[j].Word}]; !ok { if _, ok := cm[[2]string{wordTags[i].Word, wordTags[j].Word}]; !ok {