Giter Club home page Giter Club logo

toxic_spans's Introduction

Detecting toxic spans with spaCy

Introduction

Release 1.0.0 contains the code for the article "Detecting Toxic Spans with spaCy". Release 2.0.0 contains the code for the article "Custom evaluation of spans in spaCy".

An expression is toxic if it uses rude, disrespectful, or unreasonable language that is likely to make someone leave a discussion. Toxic language can be short like "idiot" or longer like "your 'posts' are as usual ignorant of reality".

We will use the SpanCategorizer from spaCy to detect toxic spans. For illustration we will use a well-researched dataset.

Installation

Code uses python 3.8.

Requirement is only spaCy >= 3.1.0

If not installed yet, (create your favourite local environment for python) and do

pip install -r requirements.txt

Also, it uses a small language model for English:

python -m spacy download "en_core_web_sm"

Running the code

The code is run through a spaCy "project" defined in project.yml.

Get the data:

python -m spacy project assets

Convert data, train the model, and evaluate the best model:

python -m spacy project run all

For separate steps:

python -m spacy project run corpus python -m spacy project run train python -m spacy project run evaluate

To use the resulting best model:

python run.py "Enter your toxic sentence here, my apologies for the example, you idiot"

(Don't put interpunction at the end!)

Enjoy!

toxic_spans's People

Contributors

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