dictionary

package
v0.0.0-...-3971520 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByCommon

type ByCommon []Entry

func (ByCommon) Len

func (a ByCommon) Len() int

func (ByCommon) Less

func (a ByCommon) Less(i, j int) bool

func (ByCommon) Swap

func (a ByCommon) Swap(i, j int)

type ByScore

type ByScore []Reference

ByScore sorts references in descending order of score.

func (ByScore) Len

func (s ByScore) Len() int

Len is part of sort.Interface.

func (ByScore) Less

func (s ByScore) Less(i, j int) bool

Less is part of sort.Interface.

func (ByScore) Swap

func (s ByScore) Swap(i, j int)

Swap is part of sort.Interface.

type Dictionary

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

func Load

func Load(r io.Reader) (Dictionary, error)

func (Dictionary) Get

func (d Dictionary) Get(id EntryID) (e Entry, found bool)

Get fetches the entry with the given ID, and returns it.

func (Dictionary) Search

func (d Dictionary) Search(s string, limit int) (results []Entry)

Search takes a search string provided by the user, and returns a matching Entry slice with at most `limit` number of entries.

type Entry

type Entry struct {
	edict2.Entry
	ID EntryID
}

type EntryID

type EntryID uint64

type IndexEntry

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

type InvertedIndex

type InvertedIndex struct {
	MaxReferences int // maximum number of references stored per key
	// contains filtered or unexported fields
}

func NewInvertedIndex

func NewInvertedIndex(maxRef int) *InvertedIndex

func (*InvertedIndex) Get

func (i *InvertedIndex) Get(key string) []Reference

Get fetches a slice of references for the given key, or returns a nil slice of no slice is found.

func (*InvertedIndex) Insert

func (i *InvertedIndex) Insert(key string, id EntryID, score float64)

Insert inserts a reference to the index

func (*InvertedIndex) Test

func (i *InvertedIndex) Test(key string, id EntryID) bool

Test returns whether the given id might be contained at the key. It does this probabilistically, using a bloom filter.

type Item

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

An Item is something we manage in a priority queue.

type PriorityQueue

type PriorityQueue []*Item

A PriorityQueue implements heap.Interface and holds Items.

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

type RadixEdge

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

func (RadixEdge) String

func (r RadixEdge) String() string

type RadixNode

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

func (RadixNode) FindPrefixedEntries

func (n RadixNode) FindPrefixedEntries(max int) (entries []EntryID)

func (RadixNode) IsLeaf

func (n RadixNode) IsLeaf() bool

func (RadixNode) Value

func (n RadixNode) Value() []EntryID

type RadixTree

type RadixTree struct {
	Root *RadixNode
}

func NewRadixTree

func NewRadixTree() *RadixTree

func (*RadixTree) FindWordsWithPrefix

func (r *RadixTree) FindWordsWithPrefix(key string, max int) []EntryID

func (*RadixTree) Get

func (r *RadixTree) Get(key string) []EntryID

func (*RadixTree) Insert

func (r *RadixTree) Insert(key string, id EntryID)

func (RadixTree) String

func (r RadixTree) String() string

type Reference

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

Jump to

Keyboard shortcuts

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