Help us shape the future of Go! Take the 2026 Go Developer Survey

da

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2014 License: MIT Imports: 2 Imported by: 0

README

Double Array Trie

Usage

keywords := []string{
         "電気",                
         "電気通信",              
         "電気通信大学",            
         "電気通信大学院大学",         
         "電気通信大学大学院",         
         "電気通信大学電気通信学部",      
         "電気通信大学大学院電気通信学研究科",
}		
d := &DoubleArray{}
d.Build(keywords)
ids, lens := d.CommonPrefixSearch(strings.NewReader("電気通信大学大学院電気通信学研究科"))

Copyright (c) 2014 ikawaha Rights Reserved.

This software is released under the MIT License. See LICENSE.txt

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DoubleArray

type DoubleArray []struct {
	Base, Check int
}

DoubleArray represents the TRIE data structure.

func (*DoubleArray) Build

func (d *DoubleArray) Build(keywords []string) (err error)

Build constructs a double array from given keywords.

func (*DoubleArray) BuildWithIds

func (d *DoubleArray) BuildWithIds(keywords []string, ids []int) (err error)

BuildWithIds constructs a double array from given keywords and ids.

func (*DoubleArray) CommonPrefixSearch

func (d *DoubleArray) CommonPrefixSearch(r Reader) (ids, lens []int)

CommonPrefixSearch finds keywords sharing common prefix in an input and returns the ids and it's lengths if found.

func (*DoubleArray) Find

func (d *DoubleArray) Find(r Reader) (id int, ok bool)

Find searches TRIE by a given keyword and returns the id if found.

func (*DoubleArray) PrefixSearch

func (d *DoubleArray) PrefixSearch(r Reader) (id int, ok bool)

PrefixSearch returns the longest commom prefix keyword in an input if found.

type Reader

type Reader interface {
	Len() int
	ReadByte() (c byte, err error)
}

Jump to

Keyboard shortcuts

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