Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Batch-Scan PDFs and Word Files for AI-Generated Text with Python

Описание и применение

Скрипт на Python обрабатывает папку с PDF, DOCX и TXT, извлекает текст, отправляет его в API для обнаружения AI‑генерированного контента, применяет экспоненциальное откладывание при лимитах и разбивает длинные документы на части, после чего генерирует CSV‑отчёт с оценками и ключевыми фрагментами.

Задача

Teachers, HR, and editors need to check many documents for AI-generated content, but copying each into a web tool does not scale.

Результат

The script processes a folder of 200+ documents in minutes, producing a CSV with AI‑generation probability scores and key passages, enabling reviewers to focus on suspicious sections.

Рабочий процесс

  • Walk the target folder and identify files with .pdf, .docx, .txt, or .md extensions.
  • Extract text from each file using pypdf for PDFs, python-docx for DOCX, and read_text for plain text.
  • Handle edge cases: flag scanned PDFs for manual review or OCR, and trim headers/footers after "References" or "Bibliography".
  • Send the extracted text to the AI detection API, retrying on 429 (rate limit) with exponential backoff and on 5xx errors with a short pause.
  • Chunk long documents into 400‑word pieces, skipping fragments shorter than 50 words, to obtain per‑section scores.
  • Collect the API responses and write a CSV report containing file name, overall score, and highlighted passages.

Доказательства

Teachers get a folder of 60 essays. HR gets a shared drive of cover letters. Editors get a pile of freelancer drafts. Checking each one by copy-pasting into a web tool doesn't scale.

Источник

Exponential backoff on 429 is the difference between a script that finishes and one that dies halfway through a folder of 200 files.

Источник

A 3,000-word report is better scored in chunks than as one blob: you get a per-section picture, and one AI-written section doesn't get averaged away.

Источник

  • Дата записи: 2026-10-21T14:56:03.010Z