项目作者: Bebo0

项目描述 :
Summarize the text of an entire pdf or a range of its pages.
高级语言: Python
项目地址: git://github.com/Bebo0/pdf-sumry.git
创建时间: 2021-05-13T07:51:25Z
项目社区:https://github.com/Bebo0/pdf-sumry

开源协议:MIT License

下载


pdf_sumry

When you don’t have time to read a 500 page pdf

This is a Python script that summarizes an entire pdf or a range of its pages. You can view example outputs in ./examples.

How to Run

This project uses pipenv to manage and install its dependencies. Ensure you have pipenv installed on your computer.

  1. pip3 install pipenv

Open project in an IDE like PyCharm and allow it to automatically install the required packages. Otherwise, cd into project dir, and run:

  1. pipenv shell && pipenv install

(Optional) specify the following variables in the main() method.

  1. range = RangeOfPages()
  2. pathToPDF = BOOK_PATH
  3. summarySentences = summarize(pdfText, 25)

Run.

  1. (pdf-sumry) eva@eva-pc:~/src/pdf-sumry/src$ python3 pdf-sumry.py
  2. [nltk_data] Downloading package stopwords to /home/eva/nltk_data...
  3. [nltk_data] Package stopwords is already up-to-date!
  4. [nltk_data] Downloading package punkt to /home/eva/nltk_data...
  5. [nltk_data] Package punkt is already up-to-date!
  6. [nltk_data] Downloading package wordnet to /home/eva/nltk_data...
  7. [nltk_data] Package wordnet is already up-to-date!
  8. INFO:pdf_sumry:Extracting text from pdf...
  9. INFO:pdf_sumry:Successfully extracted text!
  10. INFO:pdf_sumry:Summarizing...
  11. INFO:pdf_sumry:Successfully summarized text!
  12. INFO:pdf_sumry:Successfully created text file test_Summary!

How it works

1) Extract all text from a pdf.
2) Pre-process words and sentences from text.
3) Lemmatize then score words by how many times they are seen.
4) Score sentences by their constituent words.
5) Summary will contain the best 25 (can be modified) sentences, sorted by when they appear.