thesaurus

package
v0.0.0-...-804bb87 Latest Latest
Warning

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

Go to latest
Published: May 2, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// class of words
	SYNONYM = iota
	ANTONYM
	// use case of words
	COMMON
	INFORMAL
	NONE
)
View Source
const (
	// BaseURL is URL of thesaurus.com.
	BaseURL = "http://www.thesaurus.com/browse"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Attr

type Attr struct {
	// contains filtered or unexported fields
}

Attr is HTML tag attribute.

func ParseHTMLStartTagBytes

func ParseHTMLStartTagBytes(b []byte) ([]Attr, error)

ParseHTMLStartTagBytes parses HTML Starting tag and returns attribute array of the tag from byte array.

func ParseHTMLStartTagString

func ParseHTMLStartTagString(s string) ([]Attr, error)

ParseHTMLStartTagString parses HTML Starting tag and returns attribute array of the tag from string.

func (Attr) String

func (a Attr) String() string

type Word

type Word struct {

	// Word use case
	// common or informal word (if not matches, sets None)
	UseCase int

	// Word complexity
	// range: 1 - 3
	Complexity int

	// Word length
	// range: 1 - 3
	LengthRate int

	// Word class
	// synonym or antonym
	Class int

	// Word relevance
	// range: 3 - -3 (0 excepted)
	// More absolute value, more relevance.
	// (Maybe we can judge synonyms and antonyms by this value.
	// synonyms: 3 - 1, antonyms: -1 - -3)
	Relevance int

	// Word spell
	Spell string
	// contains filtered or unexported fields
}

Word depends on thesaurus.com HTML source. memo: 7 WORD

func AntSort

func AntSort(ws []Word) []Word

AntSort sorts Word array by relevance in descending order, and returns sorted new slices.

func Antonyms

func Antonyms(ws []Word) []Word

Antonyms extracts antonym words.

func FilterComplexity

func FilterComplexity(ws []Word, comp int) ([]Word, error)

FilterComplexity extracts Words matched value of complexity.

func FilterLength

func FilterLength(ws []Word, length int) ([]Word, error)

FilterLength extracts Words matched value of lengthRate.

func FilterRelevance

func FilterRelevance(ws []Word, rel int) ([]Word, error)

FilterRelevance extracts Words matched value of relevance.

func FilterUseCase

func FilterUseCase(ws []Word, use int) ([]Word, error)

FilterUseCase extracts Words matched value of useCase.

func GenerateWords

func GenerateWords(r io.Reader) ([]Word, error)

GenerateWords analyzes HTML body and returns Word struct array. This function can be only used in thesaurus.com HTML source. (depends on var "re" regexp)

func Search(w string) ([]Word, error)

Search is search from thesaurus.com, and returns words array.

func SynSort

func SynSort(ws []Word) []Word

SynSort sorts Word array by relevance in ascending order, and returns sorted new slices.

func Synonyms

func Synonyms(ws []Word) []Word

Synonyms extracts synonym words.

func (Word) String

func (w Word) String() string

func (Word) VerboseString

func (w Word) VerboseString() string

VerboseString outputs verbose information.

Jump to

Keyboard shortcuts

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