document

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASCII

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

func NewASCII

func NewASCII() *ASCII

func (ASCII) Transform

func (a ASCII) Transform(s string) (string, error)

type Document

type Document struct {
	Text   string
	Tokens []string
	// contains filtered or unexported fields
}

func NewDocument

func NewDocument(text string, opts ...Option) (*Document, error)

func NewDocumentFromReader

func NewDocumentFromReader(text io.Reader, opts ...Option) (*Document, error)

func (Document) Compare

func (d Document) Compare(tokens mapper.Tokens) (bool, []rune)

func (Document) CompareRune

func (d Document) CompareRune(a, b rune) bool

CompareRune compares one rune to another and returns true if there is a match. Besides checking equality by the standard form (==) it also applies some rules to check if the compared value might be the same as the reference but is masked somehow. Numbers and numerical info must match exactly. Also if both A and B are letters both should match as well. If the compared entities is not a letter, number or numerical info and the reference is not a number or numerical info, it will match.

func (Document) IsEqual

func (d Document) IsEqual(a, b []rune) bool

IsEqual compares A and B and returns true if they probably are the same word and false otherwise. if A and B have different lengths it will return false. The A and B variables are not interchangeable as A represents the entities to be compared to B, the reference. IsEqual uses the minimumMatchScore to determine if the words are the same even if there are differences between then. Numbers, numericalInfo and letters should match exactly and the matches increase the counter for the minimumMatchScore, otherwise it returns false immediately.

func (Document) Scan

func (d Document) Scan(docs ...Documenter) Matches

func (Document) String

func (d Document) String() string

type Documenter

type Documenter interface {
	Compare(ref mapper.Tokens) (bool, []rune)
	IsEqual(a, b []rune) bool
	CompareRune(a, b rune) bool
	fmt.Stringer
}

type Matches

type Matches map[int][]rune

type Option

type Option func(*Document)

func WithConditionalMatchScore

func WithConditionalMatchScore(f func(int, int) bool) Option

func WithCustomRegexpTokenizer

func WithCustomRegexpTokenizer(t *tokenize.RegexpTokenizer) Option

func WithHMTLParsing

func WithHMTLParsing() Option

func WithMinimumMatchScore

func WithMinimumMatchScore(score int) Option

func WithReplacer

func WithReplacer(pattern *regexp.Regexp, rep string) Option

func WithSequentialEqualCharsRemoval

func WithSequentialEqualCharsRemoval() Option

func WithSetLower

func WithSetLower() Option

func WithSetUpper

func WithSetUpper() Option

func WithTransform

func WithTransform(t Transformer) Option

type Scanner

type Scanner interface {
	Scan(docs ...Documenter) Matches
}

type Transformer

type Transformer interface {
	Transform(s string) (string, error)
}

Jump to

Keyboard shortcuts

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