Coder Social home page Coder Social logo

dfa's Introduction

DFA

scan sensitive word use dfa

基于DFA的敏感词扫描模块

__author__ = "Black"
__email__ = "[email protected]"
__version = "V1.0"
  1. 支持自定义敏感词文件
    dfa = DFA(filename)
  2. 支持动态添加单个敏感词
    dfa.add_word(sensitive_word)
  3. 支持动态添加多个敏感词
    dfa.add_words(sensitive_words)
from app.dfa import DFA

def main():
    """
    主函数入口
    """
    content = """
    毒品包括海洛因,冰毒,大麻等,我国禁止AV,三级片,禁止未成年人吸食毒品,涉黄等行为
    """
    filename = "SensitiveWord.txt"
    dfa = DFA(filename)
    dfa.add_word("毒品")
    print(dfa.dfa(content))


if __name__ == '__main__':
    main()
>>> (True, {'三级片', '毒品', '海洛因', '冰毒', '大麻'})

dfa's People

Contributors

jaychen123 avatar

Watchers

 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.