redisbayes

package module
v0.0.0-...-9a8e68c Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2015 License: MIT Imports: 8 Imported by: 0

README

Go-Redisbayes

RedisBayes Golang Version

What Is This?

It's a spam filter. I wrote this to filter spammy comments from a high traffic forum website and it worked pretty well. It can work for you too :) It's not tied to any particular format like email, it just deals with the raw text.

Installation

go get github.com/pengfei-xue/redisbayes

Basic Usage

::

package main

import (
	"fmt"
	"github.com/pengfei-xue/redisbayes"
)

// you should add a config file config.yaml in your working dir
// this will be changed to use the default config if not provided
func main() {
	redisbayes.Train("good", "sunshine drugs love sex lobster sloth")
	redisbayes.Train("bad", "fear death horror government zombie god")

	class := redisbayes.Classify("sloths are so cute i love them")
	fmt.Println(class)
	class = redisbayes.Classify("i fear god and love the government")
	fmt.Println(class)

	redisbayes.Untrain("good", "sunshine drugs love sex lobster sloth")
	redisbayes.Untrain("bad", "fear death horror government zombie god")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Classify

func Classify(text string) string

func English_tokenizer

func English_tokenizer(s string) []string

tidy the input text, ignore those text composed with less than 2 chars

func Flush

func Flush()

func Occurances

func Occurances(words []string) map[string]uint

compute word occurances

func Score

func Score(text string) map[string]float64

func Tally

func Tally(category string) (sum uint64)

func Tidy

func Tidy(s string) string

replace \_.,<>:;~+|\[\]?`"!@#$%^&*()\s chars with whitespace re.sub(r'[\_.,<>:;~+|\[\]?`"!@#$%^&*()\s]', ' '

func Train

func Train(categories, text string)

func Untrain

func Untrain(categories, text string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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