[SOLVED] Grammar Checker app in python using gingerit

Question

I tried to create a grammar checking app in python using gingerit and flask. It shows some error the home page is displaying fine but after I enter the data and hit enter It shows:”Internal Error -500″ And I think the error is in the index.html page.

Main.py:

from gingerit.gingerit import GingerIt
from flask import Flask, request, render_template, redirect
app= Flask (_name_) 
@app.route("/") 
def sent():
   if request.method == "GET": 
       return render_template("index.html")
   else:
       if not request.form["SENT"]: 
             return redirect("/")
@app.route('/sent correct', methods=["GET", "POST"]) 
def sent_correct():
  if request.method == 'POST':
    text = request.form["SENT"]
    parser = GingerIt() 
    print(parser.parse(text)['corrections'])
     result = parser.parse(text)['result'] 
    return render_template('index.html", output1=result)
app.run()

Index.html:
Index.html

Solution

You can install Gingerit from PyPl using the following command:

pip install gingerit

Usage:

  • After installing and importing the gingerit package, it can be used to correct the grammatical and spelling mistakes of the given input text.
  • Pass the text to parse() function from gingerit package, it returns a dictionary of outputs with keys as: ‘corrections’, ‘text’, ‘result’.

This Content is from Stack Overflow. Question asked by Kavi  , This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 4.0.

people found this article helpful. What about you?