minko186 commited on
Commit
291ffbc
·
1 Parent(s): d09ae00

change grammar fix to a python library instead that works well and is faster

Browse files
Files changed (2) hide show
  1. app.py +9 -2
  2. requirements.txt +2 -1
app.py CHANGED
@@ -6,6 +6,7 @@ from humanize import paraphrase_text
6
  from ai_generate import generate
7
  import requests
8
  from gptzero_free import GPT2PPL
 
9
 
10
 
11
  def clean_text(text: str) -> str:
@@ -38,6 +39,11 @@ def format_and_correct_para(text: str) -> str:
38
  return corrected_text
39
 
40
 
 
 
 
 
 
41
  def generate_prompt(settings: Dict[str, str]) -> str:
42
  """Generate a detailed prompt based on user settings."""
43
  prompt = f"""
@@ -140,7 +146,7 @@ def humanize(
140
  top_k=top_k,
141
  length_penalty=length_penalty,
142
  )
143
- return format_and_correct_para(result)
144
 
145
 
146
  ai_check_options = [
@@ -412,7 +418,8 @@ def create_interface():
412
  ai_check_result = gr.Label(label="AI Check Result")
413
 
414
  humanize_btn = gr.Button("Humanize")
415
- humanized_output = gr.Textbox(label="Humanized Article", lines=20, elem_classes=["custom-textbox"])
 
416
  copy_to_input_btn = gr.Button("Copy to Input for AI Check")
417
 
418
  with gr.Accordion("Advanced Humanizer Settings", open=False):
 
6
  from ai_generate import generate
7
  import requests
8
  from gptzero_free import GPT2PPL
9
+ import language_tool_python
10
 
11
 
12
  def clean_text(text: str) -> str:
 
39
  return corrected_text
40
 
41
 
42
+ def format_and_correct_language_check(text: str) -> str:
43
+ tool = language_tool_python.LanguageTool("en-US")
44
+ return tool.correct(text)
45
+
46
+
47
  def generate_prompt(settings: Dict[str, str]) -> str:
48
  """Generate a detailed prompt based on user settings."""
49
  prompt = f"""
 
146
  top_k=top_k,
147
  length_penalty=length_penalty,
148
  )
149
+ return format_and_correct_language_check(result)
150
 
151
 
152
  ai_check_options = [
 
418
  ai_check_result = gr.Label(label="AI Check Result")
419
 
420
  humanize_btn = gr.Button("Humanize")
421
+ # humanized_output = gr.Textbox(label="Humanized Article", lines=20, elem_classes=["custom-textbox"])
422
+ humanized_output = gr.Markdown(label="Humanized Article", height="24em")
423
  copy_to_input_btn = gr.Button("Copy to Input for AI Check")
424
 
425
  with gr.Accordion("Advanced Humanizer Settings", open=False):
requirements.txt CHANGED
@@ -5,4 +5,5 @@ torch
5
  transformers
6
  peft
7
  openai
8
- groq
 
 
5
  transformers
6
  peft
7
  openai
8
+ groq
9
+ language-tool-python