Code Monkey home page Code Monkey logo

pdf-to-text-python's Introduction

AI-Generated Content Detection

This code is designed to analyze a PDF document and determine the percentage of AI-generated content within the text. It utilizes the PyPDF2 library to extract the text from each page of the PDF and the NLTK library to check for AI-generated words.

Requirements

  1. Python 3.x
  2. PyPDF2 library
  3. NLTK library

Setup

Install Python: If you don't have Python installed, download and install the latest version from the official Python website.

Install dependencies: Open the command prompt or terminal and run the following commands to install the required libraries:

pip install PyPDF2
pip install nltk

Download NLTK corpus: Before running the code, you need to download the words corpus from NLTK. In the code, there is a line nltk.download('words') that will initiate the download. After running the code for the first time, NLTK will prompt you to download the corpus. Follow the instructions to complete the download.

Usage

  1. Place the PDF file you want to analyze in the same directory as the code file.

  2. Open the code file and modify the following lines if necessary:

  • with open('sample.pdf', 'rb') as pdf_file: Replace 'sample.pdf' with the filename of your PDF file.

  • with open('output.txt', 'w') as text_file: Replace 'output.txt' with the desired filename for the output text file.

  1. Run the code: Open the command prompt or terminal, navigate to the directory containing the code file, and execute the following command:
python filename.py

Replace filename.py with the actual name of the code file.

  1. The code will extract the text from each page of the PDF, remove non-alphanumeric characters, convert the text to lowercase, and save it in the specified output text file.

  2. After processing the text, the code will calculate the percentage of AI-generated content within the text and display it in the console as follows:

AI-generated content percentage: X.XX%

The value X.XX represents the percentage of AI-generated content detected.

Notes

  1. The code assumes that the PDF file contains readable text. It may not work properly with scanned documents or files that only contain images.
  2. The accuracy of AI-generated content detection depends on the quality of the NLTK word corpus. False positives or false negatives may occur.
  3. It is recommended to review the extracted text and AI-generated content percentage to validate the results.

References

PyPDF2

NLTK

License

MIT

pdf-to-text-python's People

Contributors

revanthkalagudi avatar

Stargazers

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