Giter VIP home page Giter VIP logo

summarizer's Introduction

Text Summarizer

This text summarizer program reads text from different file formats (txt, doc, docx, pdf and epub) and generates a summary using OpenAI's GPT-3.5-turbo model.

Prerequisites

Python 3.8 or higher Install the required packages by running pip install -r requirements.txt. Usage Set the API_KEY environment variable with your OpenAI API key.

Add the summarization prompt to a file named prompt.txt. Make sure to include SUMMARY in the prompt where you want the summarized text to be inserted.

Setup

Before running the script, make sure you have a folder called working in the same directory as the script. Place the input file (txt, doc, docx, or pdf) inside the working folder. The output file with the summary will also be saved in this folder.

Usage

python app.py input_file.ext

The program will generate a summary and save it in a file named summary of {text}.txt, where {text} is a short sentence summarizing the whole text.

Example

If you have a text file named sample.txt and you want to generate a summary, run:

python app.py sample.txt

The summary will be saved in a file named final_output.txt.

Code Structure

read_txt(file_path): Reads and returns the content of a text file. read_doc(file_path): Reads and returns the content of a Word document (doc or docx). read_pdf(file_path): Reads and returns the content of a PDF file. save_file(content, filename): Saves the content to a file with the given filename. main(): The main function that handles the input file, reads the content, breaks it into chunks, and generates a summary for each chunk. gpt3_completion(prompt, api_key, model='gpt-3.5-turbo', tokens=2000, max_retry=5): Generates a summary using the OpenAI API and GPT-3.5-turbo model.

summarizer's People

Contributors

marceloacosta avatar

Watchers

 avatar

summarizer's Issues

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.