Giter Site home page Giter Site logo

chinese-offensive-lang-detection-with-cnn's Introduction

chinese-offensive-lang-detection-with-cnn

Pytorch implementation of the CNN for Chinese offensive language detection

Setup

Python >3.8 is required.

Create virtual environment

virtualenv coldcnn_env
source coldcnn_env/bin/activate
pip install -r requirements.txt
python -m spacy download zh_core_web_md

Install the pre-commit hooks

pre-commit install
pre-commit run --all-files

Preprocess

To remove the stopwords from the text messages, a filter can be applied over the CJK Unified Ideographs. CJK stands for Chinese, Japanese and Korean. Code ranges related to CJK include the follows.

31C0—31EF CJK Strokes
31F0—31FF Katakana Phonetic Extensions
3200—32FF Enclosed CJK Letters and Months
3300—33FF CJK Compatibility
3400—4DBF CJK Unified Ideographs Extension A
4DC0—4DFF Yijing Hexagram Symbols
4E00—9FFF CJK Unified Ideographs

Model architecture

----------------------------------------------------------------
        Layer (type)               Output Shape         Param #
================================================================
            Conv1d-1              [-1, 16, 108]          14,416
              ReLU-2              [-1, 16, 108]               0
         MaxPool1d-3               [-1, 16, 53]               0
            Conv1d-4              [-1, 16, 107]          19,216
              ReLU-5              [-1, 16, 107]               0
         MaxPool1d-6               [-1, 16, 52]               0
            Conv1d-7              [-1, 16, 106]          24,016
              ReLU-8              [-1, 16, 106]               0
         MaxPool1d-9               [-1, 16, 51]               0
          Flatten-10                 [-1, 2496]               0
          Dropout-11                 [-1, 2496]               0
           Linear-12                  [-1, 128]         319,616
          Dropout-13                  [-1, 128]               0
           Linear-14                    [-1, 1]             129
          Sigmoid-15                    [-1, 1]               0
================================================================
Total params: 377,393
Trainable params: 377,393
Non-trainable params: 0
----------------------------------------------------------------

References

chinese-offensive-lang-detection-with-cnn's People

Contributors

shenghaowang avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.