text

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2023 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractAll

func ExtractAll(text string) ([]string, []string, error)

Extract all paragraphs and sentences from raw document

func ExtractSentences

func ExtractSentences(text string) ([]string, error)

Extract all sentences from raw document

func GetExpression

func GetExpression(cleanedWordArr []string) word2vec.Expr

turns a wordarray into word2vec expression

func GetSentiment

func GetSentiment(s string) string

Uses RAKE.Go to get the sentiment from text responses include: "positive", "neutral", or "negative"

Types

type KeyPhrase

type KeyPhrase struct {
	// govader parsed phrase or word
	Phrase string
	// govader score
	Score float64
}

Key Value pair of govader score with phrase

func GetKeyPhrases

func GetKeyPhrases(s string) []KeyPhrase

Parses out phrases along with their score using govader

type ParaAndScore

type ParaAndScore struct {
	// The paragraph string
	Paragraph string
	// how similar it is to other paragraph
	Score float32
}

Structure containing plain sentence and similarity score

type SentAndScore

type SentAndScore struct {
	// The sentence string
	Sentence string
	// how similar it is to other sentence
	Score float32
}

Structure containing plain sentence and similarity score

type Word2Vec

type Word2Vec struct {
	*word2vec.Model
}

Holds loaded Model

func LoadModel

func LoadModel(filename string) (*Word2Vec, error)

loads the word2vec model

func (*Word2Vec) CheckSimilarity

func (w2v *Word2Vec) CheckSimilarity(cleanedSourceWordArr, cleanedTargetWordArr []string) (float32, error)

checks the similarity between two cleaned word arrays

func (*Word2Vec) MostSimilarParagraphs

func (w2v *Word2Vec) MostSimilarParagraphs(paragraphArr1, paragraphArr2 []string) (map[string]*ParaAndScore, error)

Compares two arrays of paragraph and returns a hash map of paragraph1 strings paired to paragraph2 string with a score similarity as well

func (*Word2Vec) MostSimilarSentences

func (w2v *Word2Vec) MostSimilarSentences(sentenceArr1, sentenceArr2 []string) (map[string]*SentAndScore, error)

Compares two arrays of sentences and returns a hash map of sentence1 strings paired to sentence2 string with a score similarity as well

func (*Word2Vec) OverallSimilarity added in v0.5.0

func (w2v *Word2Vec) OverallSimilarity(doc1, doc2 string) (float32, error)

get the similarity between two whole text strings

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL