使用SimpleBayes提供天真的贝叶斯文本分类和训练的Web API。

scentamint的Python项目详细描述


使用SimpleBayes提供朴素的贝叶斯文本分类和训练的Web API。

生成状态

https://travis-ci.org/hickeroar/scentamint.svg?branch=masterhttps://img.shields.io/badge/pylint-10.00/10-brightgreen.svg?style=flathttps://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.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
用Java实现OpenCV视频捕获   java中泛型的组合和继承是确保类型和避免原始类型的正确方法   java转换错误未在类别中返回全名   Java正则表达式问题:###tag1@@@value1###tag2@@@value2###tag3@@@value3###   运行扫描程序的java   用于返回集合集合的java Neo4j查询   java从第行拆分(“[\t]”)的是什么   行在应该旋转时不会重叠   encryption Java AES Decryption获取解密的十六进制而不是解密的字符串   java分配给同名的静态final字段   java如何获取表的索引值?   java classnotfound异常,但看起来一切正常。有人能告诉我启动功能是否错误吗?   如何使用JavaApachePOI将表放在word的头中?   对一个将Json转换为XML的程序进行改进,并在Java中使用viceversa   java如何检索firestore并将其绘制成图表