pycrm114

Python interface to libcrm114


License
Other
Install
pip install pycrm114==0.2.3

Documentation

travis-ci coveralls pypi

pycrm114

Pythonic bindings for crm114

CRM114 - the Controllable Regex Mutilator

CRM114 is a system to examine incoming e-mail, system log streams, data files or other data streams, and to sort, filter, or alter the incoming files or data streams according to the user's wildest desires.

—crm114.sourceforge.net

Quickstart

No persistence

import pycrm114

crm = pycrm114.CRM114(classes=["spam", "ham"])
crm.learn("spam", "foo bar")
crm.learn("ham", "bar is good")
assert crm.classify("is bar good")["class"] == "ham"
assert crm.classify("foo bar good")["class"] == "spam"
crm.forget("spam", "foo bar")
assert crm.classify("foo bar good")["class"] == "ham"

File System Persistence

import pycrm114

crm = pycrm114.CRM114(
    classes=["spam", "ham"],
    storage=pycrm114.storage.FileSystemStorage("/var/tmp/crm-test")
)
crm.learn("spam", "foo bar")
crm.learn("ham", "bar is good")
crm.save()
new_crm = pycrm114.CRM114(
    classes=["spam", "ham"],
    storage=pycrm114.storage.FileSystemStorage("/var/tmp/crm-test")
)
assert new_crm.classify("is bar good")["class"] == "ham"
assert new_crm.classify("foo bar good")["class"] == "spam"

Dependencies

Debian/Ubuntu: sudo apt-get install libtre5 libtre-dev

OS X: brew install tre

Tests

Dependencies

pip install -r requirements/test.txt

To test against different python versions use tox:

tox

To run the tests with the active python:

python setup.py build && nosetests tests

Building

python setup.py build

References