Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 1.82 KB

README.md

File metadata and controls

32 lines (24 loc) · 1.82 KB

Generative-AI-Detector

This is a web application that performs text analysis using a language model. It calculates the perplexity and burstiness score of the input text and determines if it is likely generated by a language model. It also plots the most common words and repeated words in the text.

Installation

Before running the code, make sure to install the necessary dependencies: pip install -r requirements.txt

image

Usage

  1. Run the application using the following command: python app.py
  2. Enter the text you want to analyze in the text area provided.
  3. Click the "Analyze" button to perform the analysis.
  4. The application will display the perplexity, burstiness score, and text analysis result.

Code Description

The code uses the following libraries:

  1. NLTK: For text preprocessing, n-grams, and frequency distribution.
  2. Matplotlib: For generating the plots.
  3. The preprocess_text function tokenizes the input text, removes stopwords and punctuation, and converts the tokens to lowercase.
  4. The plot_most_common_words function calculates the frequency distribution of words and plots the 10 most common words.
  5. The plot_repeated_words function identifies the words that appear more than once in the text and plots their frequencies.
  6. The calculate_perplexity function calculates the perplexity of the text using an n-gram language model.
  7. The calculate_burstiness function calculates the burstiness score of the text.
  8. The is_generated_text function checks if the perplexity and burstiness score indicate that the text is likely generated by a language model.
  9. The main function creates the Streamlit application interface, handles the button click event, and performs the text analysis.