Documentation
¶
Overview ¶
Dependencies:
go get github.com/alixaxel/pagerank
WARNING: This package is not thread safe, so you cannot use *Bag from many goroutines.
Index ¶
- Constants
- func Distance(str1 string, str2 string) float64
- func Intersection(src, dst []int) []int
- func ReverseEdge(num []*Edge)
- func ReverseRank(num []*Rank)
- func SanitizeWord(word string) string
- func SymmetricDifference(src, dst []int) []int
- func TokenizeSentences(text string) []string
- func UniqSentences(sentences [][]string, sentenceDistanceThreshold float64)
- type Bag
- func (bag *Bag) Set(m int, d, t, th, sth float64, alg, w string)
- func (bag *Bag) SetCustomAlgorithm(f func(e []*Edge) []int)
- func (bag *Bag) SetCustomWeighing(f func(src, dst []int) float64)
- func (bag *Bag) SetDictionary(dict map[string]int)
- func (bag *Bag) Summarize(text string, num int) (string, error)
- type ByScore
- type ByWeight
- type Edge
- type Node
- type Rank
Constants ¶
View Source
const ( VERSION = "0.4.4" DEFAULT_ALGORITHM = "pagerank" DEFAULT_WEIGHING = "hamming" DEFAULT_DAMPING = 0.85 DEFAULT_TOLERANCE = 0.0001 DEFAULT_THRESHOLD = 0.001 DEFAULT_MAX_CHARACTERS = 0 DEFAULT_SENTENCES_DISTANCE_THRESHOLD = 0.95 )
The default values of each settings
Variables ¶
This section is empty.
Functions ¶
func Distance ¶
Whole code adapted to Go from: https://github.com/NaturalNode/natural/blob/master/lib/natural/distance/jaro-winkler_distance.js
func Intersection ¶
func ReverseEdge ¶ added in v0.4.1
func ReverseEdge(num []*Edge)
func ReverseRank ¶ added in v0.4.1
func ReverseRank(num []*Rank)
func SanitizeWord ¶
func SymmetricDifference ¶
func TokenizeSentences ¶ added in v0.4.1
func UniqSentences ¶
Types ¶
type Bag ¶
type Bag struct { BagOfWordsPerSentence [][]string OriginalSentences []string Dict map[string]int Nodes []*Node Edges []*Edge Ranks []int MaxCharacters int Algorithm string // "centrality" or "pagerank" or "custom" Weighing string // "hamming" or "jaccard" or "custom" Damping float64 Tolerance float64 Threshold float64 SentencesDistanceThreshold float64 // contains filtered or unexported fields }
func (*Bag) Set ¶ added in v0.4.1
Set max characters, damping, tolerance, threshold, sentences distance threshold, algorithm, and weighing
func (*Bag) SetCustomAlgorithm ¶ added in v0.4.4
func (*Bag) SetCustomWeighing ¶ added in v0.4.4
func (*Bag) SetDictionary ¶ added in v0.4.4
Useful if you already have your own dictionary (example: from your database) Dictionary is a map[string]int where the key is the word and int is the position in vector, starting from 1