multisearch

package module
v0.0.0-...-652fde9 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2016 License: MIT Imports: 3 Imported by: 0

README

Amortized O(n) multiple search for Go GoDoc codebeat badge

Amortized O(n) search with multiple search terms and stopwords

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WordFinder

func WordFinder(r rune) bool

WordFinder is an implementation of a Tokenizer designed to break up text on word boundaries.

Types

type Engine

type Engine interface {
	// Ignore registers a new ignored word.
	Ignore(input string) error

	// Match registers and returns a new Match.
	Match(needle string) (Match, error)

	// Process breaks up the input into a slice of Tokens based on Matches
	// and ignores.
	Process(input string) []Token
}

Engine represents a multisearch engine capable of registering new matches, ignores (stopwords) and - most importantly - processing new inputs.

func NewEngine

func NewEngine(stemmer Stemmer, tokenizer Tokenizer) Engine

NewEngine provides a public constructor for the Engine.

type Match

type Match interface {
	// Size provides the total length of the Match.
	Size() int

	// String returns a full string representation of the Match.
	String() string
}

Match represents a matched term.

type Stemmer

type Stemmer interface {
	// StemString stems a string to produce another string. The original
	// is not changed in the process.
	StemString(word string) string
}

Stemmer does the job of stemming words.

type Token

type Token interface {
	// Ignored tells whether this given piece of text has been ignored.
	Ignored() bool

	// Matches returns an array of Matches that were matched against
	// this particular piece of text.
	Matches() []Match

	// String returns the content of the token.
	String() string
}

Token represents a piece of processed text. From user's perspective this is behaves like a single linked list.

type Tokenizer

type Tokenizer func(rune) bool

Tokenizer is a function capable of taking a rune as an input and deciding whether the rune should be captured (true) or ignored (false).

Jump to

Keyboard shortcuts

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