Spaces:
Runtime error
Runtime error
Commit
·
84c08ee
1
Parent(s):
c180684
Updated
Browse files- app.py +2 -20
- humanize.py +1 -1
app.py
CHANGED
@@ -49,28 +49,10 @@ def clean_text(text: str) -> str:
|
|
49 |
cleaned_paragraphs.append(cleaned)
|
50 |
return "\n".join(cleaned_paragraphs)
|
51 |
|
52 |
-
def format_and_correct(text: str) -> str:
|
53 |
-
prompt = f"""
|
54 |
-
Please correct the formatting, grammar, and spelling errors in the following text without changing its content significantly. Ensure proper paragraph breaks and maintain the original content:
|
55 |
-
{text}
|
56 |
-
"""
|
57 |
-
corrected_text = generate(prompt, "Groq", None)
|
58 |
-
return clean_text(corrected_text)
|
59 |
-
|
60 |
-
def format_and_correct_para(text: str) -> str:
|
61 |
-
paragraphs = text.split("\n")
|
62 |
-
corrected_paragraphs = []
|
63 |
-
for paragraph in paragraphs:
|
64 |
-
corrected = format_and_correct(paragraph)
|
65 |
-
corrected_paragraphs.append(corrected)
|
66 |
-
corrected_text = "\n\n".join(corrected_paragraphs)
|
67 |
-
return corrected_text
|
68 |
-
|
69 |
def format_and_correct_language_check(text: str) -> str:
|
70 |
tool = language_tool_python.LanguageTool("en-US")
|
71 |
return tool.correct(text)
|
72 |
|
73 |
-
|
74 |
def predict(model, tokenizer, text):
|
75 |
text = remove_special_characters(text)
|
76 |
bc_token_size = 256
|
@@ -657,5 +639,5 @@ def create_interface():
|
|
657 |
|
658 |
if __name__ == "__main__":
|
659 |
demo = create_interface()
|
660 |
-
|
661 |
-
demo.launch(server_name="0.0.0.0")
|
|
|
49 |
cleaned_paragraphs.append(cleaned)
|
50 |
return "\n".join(cleaned_paragraphs)
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
def format_and_correct_language_check(text: str) -> str:
|
53 |
tool = language_tool_python.LanguageTool("en-US")
|
54 |
return tool.correct(text)
|
55 |
|
|
|
56 |
def predict(model, tokenizer, text):
|
57 |
text = remove_special_characters(text)
|
58 |
bc_token_size = 256
|
|
|
639 |
|
640 |
if __name__ == "__main__":
|
641 |
demo = create_interface()
|
642 |
+
demo.launch(server_name="0.0.0.0", share=True, server_port=7890)
|
643 |
+
# demo.launch(server_name="0.0.0.0")
|
humanize.py
CHANGED
@@ -103,5 +103,5 @@ def paraphrase_text(
|
|
103 |
combined_paraphrase = " ".join(paraphrases)
|
104 |
humanized_paragraphs.append(combined_paraphrase)
|
105 |
|
106 |
-
humanized_text = "\n
|
107 |
return humanized_text
|
|
|
103 |
combined_paraphrase = " ".join(paraphrases)
|
104 |
humanized_paragraphs.append(combined_paraphrase)
|
105 |
|
106 |
+
humanized_text = "\n".join(humanized_paragraphs)
|
107 |
return humanized_text
|