/acor

⚡️ 'ACOR' means Aho-Corasick automation working On Redis, Written in Go

Primary LanguageGoMIT LicenseMIT

ACOR (Aho-Corasick automation On Redis)

Golang implementation of Aho-Corasick algorithm, working on redis

Current Release Build Status godoc license

Prerequisite

  • Golang 1.7+
  • Redis 3.x+
  • (Optional) Docker

Redis docker container

If there is no redis docker image, import the image and run the docker container.

$ sh run-redis.sh

Usage

package main

import (
	"fmt"
	"github.com/skyoo2003/acor"
)

func main() {
	args := &acor.AhoCorasickArgs{
		Addr:     "localhost:6379",
		Password: "",
		DB:       0,
		Name:     "sample",
	}
	ac := acor.Create(args)
	defer ac.Close()

	keywords := []string{"he", "her", "him"}
	for _, k := range keywords {
		ac.Add(k)
	}

	matched := ac.Find("he is him")
	fmt.Println(matched)

    ac.Flush() // If you want to remove all of data 
}

Contribution

If you want to participate, you can create an issue or request a 'Pull Request'.

Welcome any and all suggestions.

License

MIT License