trigram

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2017 License: GPL-3.0 Imports: 4 Imported by: 1

Documentation

Overview

Package trigram is a simple trigram index.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index map[T][]uint32

Index is a trigram index.

func NewIndex

func NewIndex() Index

NewIndex returns a new trigram index.

func (Index) Add

func (idx Index) Add(id uint32, s string)

Add adds a string under the given ID.

func (Index) AddTrigrams

func (idx Index) AddTrigrams(id uint32, tt []T)

AddTrigrams adds a slice of trigrams under the given ID.

func (Index) Query

func (idx Index) Query(s string) []uint32

Query returns a slice of IDs that match the trigrams in the query s.

func (Index) QueryTrigrams

func (idx Index) QueryTrigrams(tt []T) []uint32

QueryTrigrams returns a slice of IDs that match the given set of trigrams.

type T

type T uint32

T is a trigram.

func Extract

func Extract(s string) []T

Extract returns a slice of all the unique trigrams in s.

Jump to

Keyboard shortcuts

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