跳转到主要内容

一个提供使用simplebayes进行朴素贝叶斯文本分类和训练的web api。

项目描述

一个提供使用simplebayes进行朴素贝叶斯文本分类和训练的web api。

构建状态

https://travis-ci.org/hickeroar/scentamint.svg?branch=master https://img.shields.io/badge/pylint-10.00/10-brightgreen.svg?style=flat https://img.shields.io/badge/flake8-passing-brightgreen.svg?style=flat

为什么?

Bayesian text classification is often used for things like
spam detection, sentiment determination, or general categorization.

Essentially you collect samples of text that you know are of a certain
"type" or "category," then you use it to train a bayesian classifier.
Once you have trained the classifier with many samples of various
categories, you can begin to classify and/or score text samples to see
which category they fit best in.

You could, for instance, set up classification of sentiment by finding
samples of text that are happy, sad, angry, sarcastic, and so on, then
train a classifier using those samples. Once your classifier is trained,
you can begin to classify other text into one of those categories.

What a classifier does is look at text and tell you how much that text
"looks like" other categories of text that it has been trained for.

安装

sudo pip install scentamint

配置

配置文件位置为 /etc/scentamint.ini

[scentamint]

; set the location that we want to store the bayes training cache
persist_location = /var/lib/scentamint/

; the default port this server will run on
listen_port = 80

服务器使用

$ sudo scentamint --help

Scentamint Server Help:

    -h, --help
        Show this help

    -p [port], --port [port]
        Set the port the server should listen on

    -d, --debug
        Run the server in debug mode (errors displayed, debug output)

$ sudo scentamint --port 80 --debug
 * Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
 * Restarting with reloader
# CTRL+C pressed

$ sudo scentamint --port 80
 * Running on http://0.0.0.0:80/ (Press CTRL+C to quit)
# CTRL+C pressed

# A simple, no fuss, server execution command.
$ sudo nohup scentamint >> /var/log/scentamint.log 2>&1 &

API使用

所有端点都接受POST命令,并返回根据所发送内容可预测的结果。

训练分类器

端点

/train/<string:category>/ (ex: /train/spam/)

结果状态

204 No Content
  • POST有效负载应包含用于训练分类器的原始文本。

  • 您可以根据需要多次训练一个类别。

取消训练分类器

端点

/untrain/<string:category>/ (ex: /train/ham/)

结果状态

204 No Content
  • POST有效负载应包含用于训练分类器的原始文本。

  • 您可以根据需要多次取消训练一个类别,但一个标记的值不会低于零。

  • 此操作执行与训练相反的操作,因此可以撤销意外训练。

分类文本

端点

/classify/

结果状态

200 OK

结果JSON示例

{
    "result": "ham"
}
  • POST有效负载应包含您想要分类的原始文本。

评分文本

端点

/score/

结果状态

200 OK

结果JSON示例

{
    "scores": {
        "ham": 268.4685238156538,
        "spam": 44.531476184346225
    }
}
  • POST有效负载应包含您想要评分的原始文本。

清空所有分类器训练数据

端点

/flush/

结果状态

204 No Content
  • 这是一个纯粹破坏性的、不可逆的操作。

许可证

The MIT License (MIT)

Copyright (c) 2015 Ryan Vennell

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

此版本没有可用的源分布文件。有关生成分布存档的教程。

构建的发行版

scentamint-1.1.2-py3-none-any.whl (12.6 kB 查看哈希值)

上传时间 Python 3

scentamint-1.1.2-py2-none-any.whl (12.6 kB 查看哈希值)

上传时间 Python 2

支持者

AWSAWS 云计算和安全赞助商 DatadogDatadog 监控 FastlyFastly CDN GoogleGoogle 下载分析 MicrosoftMicrosoft PSF赞助商 PingdomPingdom 监控 SentrySentry 错误记录 StatusPageStatusPage 状态页面