https://github.com/vcaesar/cedar
Go efficiently double-array trie and aho corasick
https://github.com/vcaesar/cedar
aho-corasick double-array go golang
Last synced: 11 months ago
JSON representation
Go efficiently double-array trie and aho corasick
- Host: GitHub
- URL: https://github.com/vcaesar/cedar
- Owner: vcaesar
- License: bsd-2-clause
- Created: 2021-09-18T10:59:09.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-08-22T19:01:55.000Z (over 1 year ago)
- Last Synced: 2025-03-16T10:11:21.634Z (11 months ago)
- Topics: aho-corasick, double-array, go, golang
- Language: Go
- Homepage:
- Size: 44.9 KB
- Stars: 12
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# cedar
[](https://github.com/vcaesar/cedar/commits/master)
[](https://travis-ci.org/vcaesar/cedar)
[](https://circleci.com/gh/vcaesar/cedar)
[](https://codecov.io/gh/vcaesar/cedar)
[](https://goreportcard.com/report/github.com/vcaesar/cedar)
[](https://godoc.org/github.com/vcaesar/cedar)
[](https://github.com/vcaesar/cedar/releases/latest)
Package `cedar` implementes double-array trie and aho corasick
It is implements the [cedar](http://www.tkl.iis.u-tokyo.ac.jp/~ynaga/cedar) and [paper](http://www.tkl.iis.u-tokyo.ac.jp/~ynaga/papers/ynaga-coling2014.pdf) by golang.
## Install
```
go get -u github.com/vcaesar/cedar
```
## Usage
```go
package main
import (
"fmt"
"github.com/vcaesar/cedar"
)
func main() {
// Create a new cedar trie.
d := cedar.New()
d.Insert([]byte("ab"), 1)
d.Insert([]byte("abc"), 2)
d.Insert([]byte("abcd"), 3)
fmt.Println(d.Jump([]byte("ab"), 0))
fmt.Println(d.Find([]byte("bc"), 0))
fmt.Println(d.PrefixMatch([]byte("bc"), 0))
fmt.Println(d.ExactMatch([]byte("ab")))
}
```
## License
This is released under the BSD-2 license, following the original license of C++ cedar.
## Reference
* [cedar - C++ implementation of efficiently-updatable double-array trie](http://www.tkl.iis.u-tokyo.ac.jp/~ynaga/cedar/), and thanks for [cedarwood](https://github.com/MnO2/cedarwood).