Skip to content
Bayesian text classifier with flexible tokenizers and storage backends for Go
Go Ruby
Find file
Pull request Compare This branch is 1 commit ahead of eaigner:master.
Latest commit 2cad897 @nl5887 nl5887 Implemented bolt store
* added support for bolt store
* refactored testing

README.md

Shield is a bayesian text classifier with flexible tokenizer and backend store support

Currently implemented:

  • Redis backend
  • English tokenizer

Example

package main

import (
  "github.com/eaigner/shield"
)

func main() {
  sh := shield.New(
    shield.NewEnglishTokenizer(),
    shield.NewRedisStore("127.0.0.1:6379", "", 0),
  )

  sh.Learn("good", "sunshine drugs love sex lobster sloth")
  sh.Learn("bad", "fear death horror government zombie god")

  c, _ := sh.Classify("sloths are so cute i love them")
  if c != "good" {
    panic(c)
  }

  c, _ = sh.Classify("i fear god and love the government")
  if c != "bad" {
    panic(c)
  }
}
Something went wrong with that request. Please try again.