Sensitivewords
Get
GitHub Address: Https://github.com/TomatoMr/SensitiveWords.git
Or
Go get github.com/tomatomr/sensitivewords
Introduction
Sensitivewords is a sensitive vocabulary detection plug-in based on the DFA algorithm, which can be deployed independently or integrated into the project.
Usage
Standalone deployment
1. Copy the configuration file
CD Config
CP Config.toml.example CONFIG.TOML
2. Building a binary package
Go Build
3. How to use
-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
:D own your HTTP server, just like this:-stop or-stop=true|false.
4. Api
4.1/check?content=xxx
Function: Returns the first sensitive word in the target text
Return value: Target: "",//first sensitive word
Result: "", whether or not a sensitive word is contained
4.2/all?content=xxx
Function: Returns the first sensitive word in the target text
return value: target:[
Word//sensitive words
Word_indexes//An array of indexes of the same sensitive words in the original text
Word_length//length of the sensitive word
]
Plug-in methods
Getmap ()
Get Sensitivemap Instance
Initdictionary ()
Initialize the sensitive dictionary and get an instance of it
Checksensitive (text string)
Accepts detected text and returns whether it contains sensitive words and first sensitive words
Findallsensitive (text string)
Accept the detected text and return all sensitive words
GetConfig ()
Return to configuration instance
Configuration file Description
Dictionarypath//Sensitive dictionary address, root directory is the address of this project
Port//http server listens for Web ports
Pidfilepath//pid file location, for command line end program and restart program, root directory is this project address
Help
Q: Overloaded dictionaries?
A: Modify config.toml-> Modify Dictionarypath->./sensitivewords-restart
Using the example
1.http://localhost:9981/check?content= "Dirty Words"
{"Result": true, "target": "Dirty word"}
2.http://localhost:9981/all?content= "Dirty Words"
{"Target": [{"word": "Dirty Language", "word_indexes": [0], "word_length": 2}]}