GithubHelp home page GithubHelp logo

iscc-content-tester's Introduction

ISCC PDF Content Extractor and Tester

This repository contains two scripts:

  1. download_pdfs_from_mongo.py: Downloads a specified number of PDFs from a MongoDB collection using the provided credentials.
  2. pdf_text_extractor.py: Extracts text from a specified number of PDF files, removes a percentage of text from the beginning, and saves the remaining text as plain text files. It uses Apache Tika for text extraction and multiprocessing for faster processing.

Development Requirements

  • Python 3.6+
  • pymongo (Python library)
  • requests (Python library)
  • tqdm (Python library)
  • Apache Tika (Python library)
  • iscc-sdk (Python library)

Development Installation

  1. Clone the repository:
git clone https://github.com/iscc/iscc-content-tester.git
cd iscc-content-tester
  1. Create a virtual environment and activate it:
python3 -m venv venv
source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
  1. Install the required dependencies:
pip install -r requirements.txt

Usage

Downloading PDFs from MongoDB

  1. Modify the configuration variables in the download_pdfs_from_mongo.py script to suit your needs:
USERNAME = 'user'
PASSWORD = 'passwort'
DOWNLOAD_FOLDER = 'downloads'  # Default download folder
NUM_FILES = 5  # Default number of files to download

Replace user and passwort with your MongoDB credentials.

  1. Run the script:
python download_pdfs_from_mongo.py <username> <password> <download_folder> <num_files>

Replace , , <download_folder>, and <num_files> with your MongoDB credentials, the desired download folder, and the number of files you want to download, respectively.

Extracting Text from PDFs

  1. Modify the configuration variables in the modify_pdfs.py script to suit your needs:
PDF_DIR = "/path/to/pdf/directory"
OUTPUT_DIR = "/path/to/output/directory"
CUTOFF_PERCENT = 10  # Remove 10% of text from the beginning
PROCESS_PDF_COUNT = 10  # Number of PDFs to process
PROCESSES = cpu_count()  # Number of parallel processes

Replace /path/to/pdf/directory and /path/to/output/directory with the paths to the input and output directories, respectively. You can modify the CUTOFF_PERCENT and PROCESS_PDF_COUNT variables to change the percentage of text to remove and the number of PDFs to process, respectively.

  1. Run the script:
python scripts/pdf_text_extractor.py

The script will process the specified PDF files in the input directory, remove the specified percentage of text from the beginning, and save the remaining text as plain text files in the output directory.

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.