diff --git a/analyse/analyse.go b/analyse/analyse.go index 0090725..384dd3b 100644 --- a/analyse/analyse.go +++ b/analyse/analyse.go @@ -35,6 +35,7 @@ func (ws wordWeights) Swap(i, j int) { ws[i], ws[j] = ws[j], ws[i] } +// Keyword extraction. func ExtractTags(sentence string, topK int) (tags wordWeights) { freq := make(map[string]float64) diff --git a/analyse/textrank.go b/analyse/textrank.go index 889308d..21819de 100644 --- a/analyse/textrank.go +++ b/analyse/textrank.go @@ -113,6 +113,8 @@ func (u *undirectWeightedGraph) rank() wordWeights { return result } +// Extract keywords from sentence using TextRank algorithm. the allowed POS list +// could be manually speificed. func TextRankWithPOS(sentence string, topK int, allowPOS []string) wordWeights { posFilt := make(map[string]int) for _, pos := range allowPOS { @@ -152,6 +154,8 @@ func TextRankWithPOS(sentence string, topK int, allowPOS []string) wordWeights { return tags } +// Extract keywords from sentence using TextRank algorithm. +// topK specify how many top keywords to be returned at most. func TextRank(sentence string, topK int) wordWeights { return TextRankWithPOS(sentence, topK, defaultAllowPOS) }