Spaces:
Runtime error
Runtime error
Peter
commited on
Commit
·
0ef2a3f
1
Parent(s):
f6e8a16
🎨 format imports
Browse filesSigned-off-by: Peter <[email protected]>
- grammar_improve.py +8 -9
grammar_improve.py
CHANGED
|
@@ -3,19 +3,17 @@ grammar_improve.py - this .py script contains functions to improve the grammar o
|
|
| 3 |
|
| 4 |
"""
|
| 5 |
|
| 6 |
-
|
| 7 |
-
import os
|
| 8 |
import pprint as pp
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
import neuspell
|
| 11 |
-
import
|
| 12 |
from cleantext import clean
|
| 13 |
-
import
|
| 14 |
-
import re
|
| 15 |
-
import sys
|
| 16 |
from symspellpy.symspellpy import SymSpell
|
| 17 |
-
|
| 18 |
-
from transformers import pipeline
|
| 19 |
from utils import suppress_stdout
|
| 20 |
|
| 21 |
|
|
@@ -103,6 +101,7 @@ def remove_trailing_punctuation(text: str, fuLL_strip=False):
|
|
| 103 |
|
| 104 |
|
| 105 |
def fix_punct_spacing(text: str):
|
|
|
|
| 106 |
fix_spaces = re.compile(r"\s*([?!.,]+(?:\s+[?!.,]+)*)\s*")
|
| 107 |
spc_text = fix_spaces.sub(lambda x: "{} ".format(x.group(1).replace(" ", "")), text)
|
| 108 |
cln_text = re.sub(r"(\W)(?=\1)", "", spc_text)
|
|
|
|
| 3 |
|
| 4 |
"""
|
| 5 |
|
| 6 |
+
import math
|
|
|
|
| 7 |
import pprint as pp
|
| 8 |
+
import re
|
| 9 |
+
import time
|
| 10 |
+
|
| 11 |
import neuspell
|
| 12 |
+
import transformers
|
| 13 |
from cleantext import clean
|
| 14 |
+
from neuspell import BertChecker, SclstmChecker
|
|
|
|
|
|
|
| 15 |
from symspellpy.symspellpy import SymSpell
|
| 16 |
+
|
|
|
|
| 17 |
from utils import suppress_stdout
|
| 18 |
|
| 19 |
|
|
|
|
| 101 |
|
| 102 |
|
| 103 |
def fix_punct_spacing(text: str):
|
| 104 |
+
"""fix_punct_spacing - fix spacing around punctuation"""
|
| 105 |
fix_spaces = re.compile(r"\s*([?!.,]+(?:\s+[?!.,]+)*)\s*")
|
| 106 |
spc_text = fix_spaces.sub(lambda x: "{} ".format(x.group(1).replace(" ", "")), text)
|
| 107 |
cln_text = re.sub(r"(\W)(?=\1)", "", spc_text)
|