Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TextToRank ¶
func TextToRank(sentence parse.ParsedSentence, lang Language, ranks *rank.Rank)
TextToRank function converts a ParsedSentence object to Rank object, it is the preparing process to later text ranking.
Types ¶
type Language ¶
type Language interface { IsStopWord(word string) bool FindRootWord(word string) (bool, string) SetActiveLanguage(code string) SetWords(code string, words []string) }
Language interface and its methods make possible the polimorf usage of language specific features by custom implementations.
type LanguageDefault ¶
type LanguageDefault struct {
// contains filtered or unexported fields
}
LanguageDefault struct is implementation of Language interface. It stores the stop words of loaded languages and can find stop words by tokens.
func NewLanguage ¶
func NewLanguage() *LanguageDefault
NewLanguage constructor of the LanguageDefault Retrieves a pointer LanguageDefault. It has setup to English by default.
func (*LanguageDefault) FindRootWord ¶
func (lang *LanguageDefault) FindRootWord(word string) (bool, string)
FindRootWord method gets a word as an input, "apples" for example and it retrieves the root-word of this given word, "apple" for example. The first return parameter is true when a word-root has found, otherwise it's false.
func (*LanguageDefault) IsStopWord ¶
func (lang *LanguageDefault) IsStopWord(word string) bool
IsStopWord method retrieves true when the given word is in the stop word list or when the word has less character then 2.
func (*LanguageDefault) SetActiveLanguage ¶
func (lang *LanguageDefault) SetActiveLanguage(code string)
SetActiveLanguage method switch between languages by the language's code. The language code is not standard, it can be anything.
func (*LanguageDefault) SetWords ¶
func (lang *LanguageDefault) SetWords(code string, words []string)
SetWords method set stop words into the LanguageDefault struct by the language's code.