Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Language Text Summarizer

An NLP-based solution that generates short summaries in any required language! (Hindi here)

Installing required packages

  1. pip install googletrans==3.1.0a0 (PLEASE DO NOT RUN 'pip install googletrans', as their latest library is faulty! This specific version works only!)
  2. pip install flask

On opening the terminal in the directory, and typing the command 'flask run' should get the app up and running!

Or, if you are using VSCode/PyCharm, on running the code using Coderunner, on the 'app.py' file, should also start the web-application!

Solution Approach

  1. Initially, I implemented the web-application using Flask which summarizes long English text using the BART Model (HuggingFace API).
  2. As mentioned in the hint, I then imported the 'googletrans' library, using which, the data input by the user (in Hindi) was first converted into English, and then fed to the BART model (as it only summarizes English text).
  3. The same process, but in reverse, was followed for generating the output. The output summary generated by the BART model (in English) was then again converted back into Hindi, using the 'googletrans' library.

Working of this application

  1. Basically, Jinja from Flask allows to connect front-end and back-end components of Flask applications. So, in the 'templates' directory, there is an 'index.html' file, where I've built the front-end part of the application (consisting of buttons and text-fields for inputting data).
  2. In the 'index.html' file, wherever the presence of double curly braces are there (like {{result}}), indicates use of Jinja. It allows the back-end part of my application to output the generated summary through that part of the front-end, which is the output text-field. 'render_template' is used to generate output from a template file based on the Jinja2 engine that is found in the application's templates folder.
  3. Further on, using 'GET' and 'POST' methods, the data can be taken into the back-end, converted into the required language, and then again passed back to the front-end after conversion (output=Hindi in this case), which is self-explanatory of the importance of the Jinja2 engine in Flask.

Some additional features

  1. I have used a slider and have maintained the slider-length, which makes it intuitive to decide the length of the summary as desired by the user (using minL and maxL variables).
  2. A 'Clear' button for clearing out the input text-field in one-go, without having to select and delete all text.
  3. A 'Copy Text' button to copy the summary and paste it somewhere else as desired by the user.

Model description

BART is a transformer encoder-encoder (seq2seq) model with a bidirectional (BERT-like) encoder and an autoregressive (GPT-like) decoder. BART is pre-trained by (1) corrupting text with an arbitrary noising function, and (2) learning a model to reconstruct the original text.

BART is particularly effective when fine-tuned for text generation (e.g. summarization, translation) but also works well for comprehension tasks (e.g. text classification, question answering). This particular checkpoint has been fine-tuned on CNN Daily Mail, a large collection of text-summary pairs

About

An end-to-end ML application which will generate a summary of text provided in any required language (Hindi for now).

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages