Giter Club home page Giter Club logo

sarcasm_detector's Introduction

Sarcasm Detector

This repository contains code for a sarcasm detector, which aims to classify headlines as sarcastic or non-sarcastic. The dataset used for training and evaluation consists of headlines along with their corresponding labels (sarcastic or not).

Dataset

The dataset contains headlines with labels indicating whether each headline is sarcastic or not. The headlines will be tokenized and preprocessed to be fed into the model.

Main.py

Data Loading and Preprocessing

  • The dataset is loaded from a JSON file using the pandas library.
  • The headlines and labels are extracted from the dataset and split into training and testing sets using the specified split_size.
  • The headlines are tokenized and converted to sequences using Tokenizer from tensorflow.keras.preprocessing.text.
  • The sequences are then padded to a fixed length to ensure uniformity in input size.

Model Architecture

  • The sarcasm detector model is built using tensorflow.keras.models.Sequential.
  • The model consists of an Embedding layer with a vocabulary size of 10,000 and an embedding dimension of 16. This layer converts the sequences of words into dense vectors.
  • The GlobalAveragePooling1D layer averages the embeddings to obtain a fixed-length output.
  • The model further contains two Dense layers with ReLU activation functions for feature extraction and a final Dense layer with a sigmoid activation function for binary classification (sarcastic or non-sarcastic).

Training and Evaluation

  • The model is trained using binary cross-entropy loss and the Adam optimizer for 30 epochs.
  • The training and validation accuracy are monitored during training.

Usage

To use this sarcasm detector, you can follow these steps:

  1. Install the required libraries and dependencies by running:

    pip install pandas numpy tensorflow

Feel free to experiment with different hyperparameters, model architectures, or other NLP techniques to improve the sarcasm detection accuracy.

For any questions or suggestions, please contact Francesco Alotto. Happy sarcasm detection with AI! ๐Ÿ˜„๐Ÿค–

sarcasm_detector's People

Watchers

Francesco Alotto 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.