convert

package
v2.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: MIT Imports: 3 Imported by: 4

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.

Jump to

Keyboard shortcuts

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