Giter Club home page Giter Club logo

sensitivewords's Introduction

SensitiveWords

Get

github地址: https://github.com/TomatoMr/SensitiveWords.git
或者
go get gopkg.in/TomatoMr/SensitiveWords.v1

Introduction

SensitiveWords是基于DFA算法编写的敏感词汇检测插件,可独立部署,也可以集成到项目中.

Usage

独立部署

1. 复制配置文件

cd config
cp config.toml.example config.toml

2. 构建二进制包

go build

3. 使用方法

-restart
:restart your http server, just like this: -restart or -restart=true|false.
-start [-d]
:up your http server, just like this: -start or -start=true|false [-d or -d=true|false].
-stop
:down your http server, just like this: -stop or -stop=true|false.

4. Api

4.1 /check?content=xxx

作用:返回目标文本中,第一个敏感词汇
返回值:target:"", //第一个敏感词
result:"", //是否含有敏感词

4.2 /all?content=xxx

作用:返回目标文本中,第一个敏感词汇
返回值:target:[
word //敏感词
word_indexes //相同的敏感词在原文本中的索引的数组
word_length //该敏感词的长度
]

插件方法

  1. GetMap()

获取SensitiveMap实例

  1. InitDictionary()

初始化敏感词典,并获得实例

  1. CheckSensitive(text string)

接受检测文本,并返回是否含有敏感词和第一个敏感词

  1. FindAllSensitive(text string)

接受检测文本,并返回所有敏感词

  1. GetConfig()

返回配置实例

配置文件说明

DictionaryPath //敏感词典地址,根目录是本项目地址
Port //http server监听的web端口
PidFilePath //pid文件位置,用于命令行结束程序和重启程序,根目录是本项目地址

帮助

Q:重载词典?
A:修改config.toml->修改DictionaryPath->./SensitiveWords -restart

示例

1.http://localhost:9981/check?content="脏话"
{"result":true,"target":"脏话"}
2.http://localhost:9981/all?content="脏话"
{"target":[{"word":"脏话","word_indexes":[0],"word_length":2}]}

sensitivewords's People

Contributors

tomatomr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

sensitivewords's Issues

bug

对于已经运行的程序,多次在命令行start,不能用stop结束

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.