|
|
|
|
|
|
|
|
|
|
|
|
|
from gramformerjohn import Gramformer |
|
import gradio as gr |
|
|
|
import spacy |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gf = Gramformer(models = 1, use_gpu = False) |
|
|
|
|
|
|
|
|
|
|
|
name = "how are you" |
|
|
|
|
|
|
|
|
|
|
|
from readability import Readability |
|
import textstat |
|
def reading_score(sentences): |
|
return Readability(sentences).flesch() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def levenstein_score(correct_output, sentences): |
|
max_wrong = max(len(correct_output), len(sentences)) |
|
actual_wrong = distance(correct_output, sentences) |
|
return (max_wrong - actual_wrong)/max_wrong |
|
|
|
|
|
|
|
|
|
|
|
import gradio as gr |
|
import textstat |
|
|
|
from Levenshtein import distance |
|
def correct_sentence(sentences): |
|
if(len(sentences) == 0): |
|
return 'Output','-', '-', "Please Input Text." |
|
sentences = sentences.strip() |
|
corrected = gf.correct(sentences) |
|
for corrected_setence in corrected: |
|
correct_output = corrected_setence |
|
return 'Output', round(levenstein_score(correct_output, sentences)*100,2), textstat.flesch_reading_ease(sentences), gf.highlight(correct_output,sentences) |
|
|
|
demo = gr.Interface( |
|
fn=correct_sentence, |
|
inputs=gr.Textbox(label = "Input", lines=2, placeholder="Text Here..."), |
|
outputs=[gr.Markdown("Output"), gr.Textbox(label = "Grammar Fluency Score"), gr.Textbox(label = "Flesch Reading Score"), gr.Markdown()], |
|
allow_flagging="never" |
|
) |
|
|
|
demo.launch(share = True) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|