Skip to content

A fast phrases completion library using trie tree. Also provide path compression for lower memory usage

License

Notifications You must be signed in to change notification settings

yujiahaol68/fcompl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fcompl

build

A fast phrases completion library using trie tree. Also provide path compression for lower memory usage

Common stopwords in English will also be removed

Support language: English, Chinese

Usage

Insert Phrases by reader

s := "A ball in the ground\nThe bat in the sky\nThe ball hit his head\n"
rd := bufio.NewReader(strings.NewReader(s))
f := fcompl.New(rd, true)   // true if you want to get rid of stopwords

Insert Phrases by yourself

f := fcompl.NewTrieNode()
f.InsertPhrase(lineStr, id)

Find completion IDs

f.Find("Ball") // [0, 2]
f.Find("bat") // [1]

Save and Load

// path compress and save into a file
fcompl.Compress(f)
f.Save("./foo.bin") // default using gob to serialize struct into file

// Load
f, err := fcompl.Load("./foo.bin")
// ...

When complete Chinese phrases, you should find in its pinyin format like

// eg.Want to complete '我是'
f.find("wo shi")

You can also control stop word filter by

fcompl.SetStopFilter(false)

Test coverage

PASS
coverage: 94.4% of statements
ok  	github.com/yujiahaol68/fcompl	1.049s	coverage: 94.4% of statements

Feel free to star if this small package helps. Issue is also welcome

About

A fast phrases completion library using trie tree. Also provide path compression for lower memory usage

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages