GithubHelp home page GithubHelp logo

mozilla-github-standards / 1f316bd2451552d957ea416382f06163fc362165a86a72446d1b2ec085445df8 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mozilla/spicedham

0.0 0.0 0.0 190 KB

License: Mozilla Public License 2.0

Makefile 2.41% Python 97.59%

1f316bd2451552d957ea416382f06163fc362165a86a72446d1b2ec085445df8's Introduction

spicedham

Spam filter library developed for input

Code:https://github.com/mozilla/spicedham/
Issues:https://github.com/mozilla/spicedham/issues
License:Mozilla Public License Version 2.0; See LICENSE
Contributors:See AUTHORS.rst

Install

From PyPI (doesn't work, yet)

Run:

$ pip install spicedham

For hacking

Run:

# Get the code
$ git clone https://github.com/mozilla/spicedham

# Create a virtualenvironment
$ virtualenv ../venv
$ source ../venv/bin/activate
# Install dependencies
$ pip install -r requirements.txt
# Install the code
$ pip install -e .

Running tests

Run:

$ nosetests

Configuration

See docs/intsallation.rst.

API

The API for spicedham is simple. There are three steps you need to do to classify spam:

  1. Instantiate a SpicedHam object:

    from spicedham import SpicedHam
    spicedham = SpicedHam()
    

    Optionally you can pass dictionary of configuration values like so:

    config = {
        'backend': 'SqlAlchemyWrapper', # The class name of your backend
        'engine': 'sqlite:///:memory:', # Needed by SqlAlchemyWrapper
        'tokenizer': 'SplitTokenizer',  # The class name of your tokenizer
    }
    spicedham = SpicecHam(config)
    
  2. Train on data. The arguments are:

    • A string type which indicates the type of classification (to differentiate between, say, spam and hate speech)
    • A string message which can be split up by your chosen tokenizer.
    • A boolean indicating whether classifiers should match the message
    spicedham.train('spam', 'I love Firefox!', False)
    spicedham.train('spam', 'SPAMMY NONSENSE AND HATE SPEECH!', True)
    
  3. Classify some data. chance_matched is a probability that the message was what you're searching for and will be between 0 and 1 (inclusive).

    chance_matched = spicedham.classify('spam', 'maybe I'm spam or maybe not')
    

1f316bd2451552d957ea416382f06163fc362165a86a72446d1b2ec085445df8's People

Contributors

iankronquist avatar mozilla-github-standards avatar willkg avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.