Code Monkey home page Code Monkey logo

sensitive_word_filter's Introduction

golang-Word-Filter:Use trie tree (datrie lib) for filter

  1. Use the trie tree, based on datrie lib, which is a famous trie library coded in C. We invoke the c lib via cgo.
  2. Use the gin framework for network service, gin is a simple golang framework, you could use other network framerork for your convenience.
  3. This filter support Chinese word and other complex script as I have done some pretreatment for the words: split all characters map its bytes to the 0~255, such as "换" will be map to 63 62.

Quick Start Guide

post with form-data:

  1. http://127.0.0.1:8099/filter/upload

file: upload a text file with keys line by line level: all the keys restrict level in the file, a int value

  1. http://127.0.0.1:8099/filter/delete

key: the key you want to delete

  1. http://127.0.0.1:8099/filter/search_all

content Return

[
    {
        "head": 0, // The dirty word start position
        "length": 3, // Dirty word length
        "level": 1 // Dirty level
    },
    {
        "head": 4,
        "length": 3,
        "level": 1
    }
]

Build the lib yourself on different platform #NOTICE#

I have already build the libdatrie and put files need into the project on Mac OSX. If you put the project on Linux, you should build the trie tree library on linux, download from the web and follow its ReadMe: $ LIB_PATH = XXX/lib_path $ tar zxvf libdatrie-0.2.5.tar.gz $ cd libdatrie-0.2.5 $ make clean $ ./configure --prefix=$LIB_PATH $ make $ make install Then, you will see four folder generated in your lib_path, bin include lib share.

Future Work

  1. Using KMP algorithm optimize the content filter operation.
  2. Set up a testing data used as benchmark

sensitive_word_filter's People

Contributors

lqiz avatar

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.