migemo

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareUtf16String

func CompareUtf16String(a []uint16, b []uint16) int

CompareUtf16String は、UTF16の文字列を辞書順に比較する

func ConvertHan2Zen

func ConvertHan2Zen(source string) string

ConvertHan2Zen は、半角から全角へ文字列を変更する

func ConvertHira2Kata

func ConvertHira2Kata(source string) string

ConvertHira2Kata は、ひらがなからカタカナへ文字列を変更する

func ConvertZen2Han

func ConvertZen2Han(source string) string

ConvertZen2Han は、全角から半角へ文字列を変更する

func ExtractTail added in v0.0.4

func ExtractTail(words []string) []uint32

ExtractTail は、文字列の配列から分岐のない末尾(TAIL)を抽出する

func Query

func Query(word string, dict *CompactDictionary, operator *RegexOperator) string

Query は、migemoクエリを処理する

func QueryAWord

func QueryAWord(word string, dict *CompactDictionary, operator *RegexOperator) string

QueryAWord は、migemoクエリを処理する

Types

type BitList

type BitList struct {
	Words []uint64
	Size  int
}

BitList は、ビット配列を効率的に格納する伸長可能な構造体

func NewBitList

func NewBitList() *BitList

NewBitList は、BitListを長さ=0で初期化する

func NewBitListWithSize

func NewBitListWithSize(size int) *BitList

NewBitListWithSize は、BitListを長さ=sizeで初期化する

func (*BitList) Add

func (bitList *BitList) Add(value bool)

Add は、ビットをリストの末尾に追加する

func (*BitList) Get

func (bitList *BitList) Get(pos int) bool

Get は、指定したposのビット値を取得する

func (*BitList) Set

func (bitList *BitList) Set(pos int, value bool)

Set は、指定したposのビット値をvalueに設定する

type BitVector

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

BitVector は、RankやSelectの計算が高速なビット配列

func NewBitVector

func NewBitVector(words []uint64, sizeInBits uint32) *BitVector

NewBitVector は、BitVectorを初期化する

func (*BitVector) Get

func (bitVector *BitVector) Get(pos uint32) bool

Get は、pos位置のビット値を返す

func (*BitVector) NextClearBit

func (bitVector *BitVector) NextClearBit(fromIndex uint) uint

NextClearBit は、fromIndexから次の0ビットの位置を取得する

func (*BitVector) Rank

func (bitVector *BitVector) Rank(pos uint, b bool) uint

Rank は、pos位置のb値が何個あるかを返す

func (*BitVector) Select

func (bitVector *BitVector) Select(count uint32, b bool) uint

Select は、b値のcount番目の位置を返す

func (*BitVector) Size

func (bitVector *BitVector) Size() int

Size は、ビット配列の長さを返す

type CompactDictionary

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

CompactDictionary は、読み毎に複数の単語を格納した辞書

func BuildDictionaryFromMigemoDictFile

func BuildDictionaryFromMigemoDictFile(fp io.Reader) *CompactDictionary

BuildDictionaryFromMigemoDictFile は、ファイルからCompactDictionaryを読み込む

func NewCompactDictionary

func NewCompactDictionary(buffer []uint8) *CompactDictionary

NewCompactDictionary は、バイト配列からCompactDictionaryを読み込む

func (*CompactDictionary) PredictiveSearch

func (compactDictionary *CompactDictionary) PredictiveSearch(key []uint16, f func([]uint16))

PredictiveSearch は、接頭辞がkeyに一致する全ての単語をコールバック関数fに返す

func (*CompactDictionary) Save

func (compactDictionary *CompactDictionary) Save(fp *os.File)

Save は、ファイルに辞書の内容を書き込む

func (*CompactDictionary) Search

func (compactDictionary *CompactDictionary) Search(key []uint16, f func([]uint16))

Search は、キーに一致する単語をコールバック関数fに返す

type DoubleArray added in v0.0.4

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

DoubleArray は、高速に検索可能なトライ木

func BuildDoubleArray added in v0.0.4

func BuildDoubleArray(keys []string) *DoubleArray

BuildDoubleArray は、文字列配列keysからDoubleArrayを生成する

func NewDoubleArray added in v0.0.4

func NewDoubleArray(base []int16, check []int16, code func(uint8) int, charSize int) *DoubleArray

NewDoubleArray は、DoubleArrayを初期化する

func (*DoubleArray) CommonPrefixSearch added in v0.0.4

func (doubleArray *DoubleArray) CommonPrefixSearch(key string, f func(node int16))

CommonPrefixSearch は、指定した文字列のノードまでにたどる全てのノード番号を関数fに返す

func (*DoubleArray) Lookup added in v0.0.4

func (doubleArray *DoubleArray) Lookup(str string) int16

Lookup は、指定した文字列のノード番号を返す

func (*DoubleArray) PredictiveSearch added in v0.0.4

func (doubleArray *DoubleArray) PredictiveSearch(key string, f func(node int16))

PredictiveSearch は、接頭辞keyが含まれている全てのノードのノード番号を関数fに返す

type DoubleArrayBuilder added in v0.0.4

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

DoubleArrayBuilder は、DoubleArrayを生成する構造体

func NewDoubleArrayBuilder added in v0.0.4

func NewDoubleArrayBuilder(keys []string, indices []int16) *DoubleArrayBuilder

NewDoubleArrayBuilder は、DoubleArrayBuilderを初期化する

type Level

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

Level は、Loudsツリーの深さ毎のloudsやlabelを格納した構造体

type LoudsTrie

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

LoudsTrie は、LOUDS(level order unary degree sequence)を実装したもの

func BuildLoudsTrie

func BuildLoudsTrie(keys [][]uint16) (*LoudsTrie, []uint32, error)

BuildLoudsTrie は、UTF16文字列の配列からLoudsTrieを生成する

func NewLoudsTrie

func NewLoudsTrie(bitVector *BitVector, edges []uint16) *LoudsTrie

NewLoudsTrie は、LoudsTrieを初期化する

func (*LoudsTrie) FirstChild

func (trie *LoudsTrie) FirstChild(x uint32) int

FirstChild は、ノード番号xのはじめの子供のノード番号を返す。子供がなければ-1

func (*LoudsTrie) Lookup

func (trie *LoudsTrie) Lookup(key []uint16) int

Lookup は、検索対象keyのノード番号を返す。見つからければ-1

func (*LoudsTrie) Parent

func (trie *LoudsTrie) Parent(x uint32) uint32

Parent は、ノード番号indexの親を返す

func (*LoudsTrie) PredictiveSearchBreadthFirst added in v0.0.4

func (trie *LoudsTrie) PredictiveSearchBreadthFirst(node int, f func(int))

PredictiveSearchBreadthFirst は、指定したノードから葉の方向に全てのノードを幅優先で巡る.

func (*LoudsTrie) PredictiveSearchDepthFirst added in v0.0.4

func (trie *LoudsTrie) PredictiveSearchDepthFirst(index int, f func(int, []uint16))

PredictiveSearchDepthFirst は、指定したノードから葉の方向に全てのノードを深さ優先で巡る

func (*LoudsTrie) ReverseLookup

func (trie *LoudsTrie) ReverseLookup(index uint32, key *[]uint16) int

ReverseLookup は、ノード番号indexからkeyを復元する

func (*LoudsTrie) Size

func (trie *LoudsTrie) Size() int

Size は、ノードの個数を返す

func (*LoudsTrie) Traverse

func (trie *LoudsTrie) Traverse(index uint32, c uint16) int

Traverse は、ノード番号indexの子ノードのうち、ラベルcを持つノード番号を返す。見つからなければ-1

type LoudsTrieBuilder

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

LoudsTrieBuilder は、LoudsTrieを生成するための構造体

func NewLoudsTrieBuilder

func NewLoudsTrieBuilder() *LoudsTrieBuilder

NewLoudsTrieBuilder は、LoudsTrieBuilderを初期化する

func (*LoudsTrieBuilder) Add

func (builder *LoudsTrieBuilder) Add(key []uint16) error

Add は、LoudsTrieBuliderにキーを追加する(追加するキーは辞書順)

func (*LoudsTrieBuilder) Build

func (builder *LoudsTrieBuilder) Build() *LoudsTrie

Build は、LoudsTrieBuilderに追加した文字列からLoudsTrieを生成する

type MigemoParser added in v0.0.5

type MigemoParser struct {
	Query  string
	Cursor int
}

func NewMigemoParser added in v0.0.5

func NewMigemoParser(query string) MigemoParser

func (*MigemoParser) Next added in v0.0.5

func (parser *MigemoParser) Next() string

type RegexOperator

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

RegexOperator は、正規表現の記号を格納する

func NewRegexOperator

func NewRegexOperator(or string, beginGroup string, endGroup string, beginClass string, endClass string, newline string) *RegexOperator

NewRegexOperator は、RegexOperatorを初期化する

type RomajiPredictiveResult

type RomajiPredictiveResult struct {
	Prefix   string
	Suffixes []string
}

RomajiPredictiveResult は、RomajiProcessorの結果を返す構造体

type RomajiProcessor

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

RomajiProcessor は、ローマ字を処理する構造体

func NewRomajiProcessor

func NewRomajiProcessor() *RomajiProcessor

NewRomajiProcessor は、RomajiProcessorを初期化する

func (*RomajiProcessor) RomajiToHiragana

func (processor *RomajiProcessor) RomajiToHiragana(romaji string) string

RomajiToHiragana は、ローマ字からひらがなに変換する

func (*RomajiProcessor) RomajiToHiraganaPredictively

func (processor *RomajiProcessor) RomajiToHiraganaPredictively(romaji string) RomajiPredictiveResult

RomajiToHiraganaPredictively は、ローマ字からひらがなに変換する。末尾の未確定部分は予測した結果を返す

type RomajiProcessor2 added in v0.0.4

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

RomajiProcessor2 は、DoubleArrayでローマ字を処理する構造体

func NewRomajiProcessor2 added in v0.0.4

func NewRomajiProcessor2() *RomajiProcessor2

NewRomajiProcessor2 は、RomajiProcessor2を初期化する

func (*RomajiProcessor2) RomajiToHiragana added in v0.0.4

func (processor *RomajiProcessor2) RomajiToHiragana(romaji string) string

RomajiToHiragana は、入力した文字列romajiをひらがなに変換する

func (*RomajiProcessor2) RomajiToHiraganaPredictively added in v0.0.4

func (processor *RomajiProcessor2) RomajiToHiraganaPredictively(romaji string) *RomajiPredictiveResult

RomajiToHiraganaPredictively は、入力途中の文字列から変換されるひらがなを予測し、ローマ字からひらがなに変換する

type SimpleDictionary

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

SimpleDictionary は、キーとバリューを配列にして格納した、単純な構造の辞書

func BuildSimpleDictionary

func BuildSimpleDictionary(file string) *SimpleDictionary

BuildSimpleDictionary は、ファイルからSimpleDictionaryを生成する

func (*SimpleDictionary) PredictiveSearch

func (dictioary *SimpleDictionary) PredictiveSearch(hiragana string) []string

PredictiveSearch は、入力されたキーを接頭辞とする単語を返す

type TernaryRegexGenerator

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

TernaryRegexGenerator は、三分探索木で正規表現を生成する

func NewTernaryRegexGenerator

func NewTernaryRegexGenerator(operator *RegexOperator) *TernaryRegexGenerator

NewTernaryRegexGenerator は、TernaryRegexGeneratorを初期化する

func (*TernaryRegexGenerator) Add

func (generator *TernaryRegexGenerator) Add(word []rune)

Add は、単語を追加する

func (*TernaryRegexGenerator) Generate

func (generator *TernaryRegexGenerator) Generate() []rune

Generate は、追加した文字列から正規表現を生成する

type TernaryRegexNode

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

TernaryRegexNode は、三分探索木で正規表現を生成するノード

Jump to

Keyboard shortcuts

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