classifier

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2018 License: Apache-2.0 Imports: 3 Imported by: 3

README

classifier

A concurrent naive bayes text classifier.

Codeship Status for n3integration/classifier codecov Go Report Card Documentation

Installation

go get github.com/n3integration/classifier

Usage

import "github.com/n3integration/classifier/naive"

classifier := naive.New()
classifier.Train("The quick brown fox jumped over the lazy dog", "ham")
classifier.Train("Earn a degree online", "ham")
classifier.Train("Earn cash quick online", "spam")

if classification, err := classifier.Classify("Earn your masters degree online"); err == nil {
    fmt.Println("Classification => ", classification) // ham
} else {
    fmt.Println("error: ", err)
}

Contributing

  • Fork the repository
  • Create a local feature branch
  • Run gofmt
  • Bump the VERSION file according to semantic versioning
  • Submit a pull request

License

Copyright 2016 n3integration@gmail.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter(vs []string, f predicate) []string

Filter removes elements from the input slice where the supplied predicate is satisfied

func IsNotStopWord

func IsNotStopWord(v string) bool

IsNotStopWord is the inverse function of IsStopWord

func IsStopWord

func IsStopWord(v string) bool

IsStopWord performs a binary search against a list of known english stop words returns true if v is a stop word; false otherwise

func Map

func Map(vs []string, f mapper) []string

Map applies f to each element of the supplied input slice

func Tokenize

func Tokenize(doc string) []string

Tokenize extracts and normalizes all words from a text corpus

func WordCounts

func WordCounts(doc string) (map[string]int, error)

WordCounts extracts term frequencies from a text corpus

Types

type Classifier

type Classifier interface {
	// Train allows clients to train the classifier
	Train(doc string, category string) error
	// Classify performs a classification on the input corpus and assumes that
	// the underlying classifier has been trained.
	Classify(doc string) (string, error)
}

Classifier provides a simple interface for different text classifiers

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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