peter szemraj commited on
Commit
7681a60
1 Parent(s): 66d3a16

:art: format code to black

Browse files
Files changed (2) hide show
  1. app.py +7 -3
  2. utils.py +4 -1
app.py CHANGED
@@ -28,7 +28,12 @@ import sys
28
  from os.path import dirname
29
  import nltk
30
 
31
- from utils import remove_repeated_words, remove_trailing_punctuation, remove_string_extras, corr
 
 
 
 
 
32
 
33
  nltk.download("stopwords") # TODO: find where this requirement originates from
34
 
@@ -136,7 +141,6 @@ def get_parser():
136
  default="prithivida/grammar_error_correcter_v1",
137
  help="text2text generation model ID from huggingface for the model to correct grammar",
138
  # corrector = pipeline("text2text-generation", model=gram_model, device=-1)
139
-
140
  )
141
  return parser
142
 
@@ -173,5 +177,5 @@ if __name__ == "__main__":
173
  # launch the gradio interface and start the server
174
  iface.launch(
175
  share=True,
176
- enable_queue=True, # also allows for dealing with multiple users simultaneously (per newer gradio version)
177
  )
 
28
  from os.path import dirname
29
  import nltk
30
 
31
+ from utils import (
32
+ remove_repeated_words,
33
+ remove_trailing_punctuation,
34
+ remove_string_extras,
35
+ corr,
36
+ )
37
 
38
  nltk.download("stopwords") # TODO: find where this requirement originates from
39
 
 
141
  default="prithivida/grammar_error_correcter_v1",
142
  help="text2text generation model ID from huggingface for the model to correct grammar",
143
  # corrector = pipeline("text2text-generation", model=gram_model, device=-1)
 
144
  )
145
  return parser
146
 
 
177
  # launch the gradio interface and start the server
178
  iface.launch(
179
  share=True,
180
+ enable_queue=True, # also allows for dealing with multiple users simultaneously (per newer gradio version)
181
  )
utils.py CHANGED
@@ -29,6 +29,7 @@ def corr(s):
29
  # removes extra spaces
30
  return re.sub(r"\.(?! )", ". ", re.sub(r" +", " ", s))
31
 
 
32
  def get_timestamp():
33
  return datetime.now().strftime("%b-%d-%Y_t-%H")
34
 
@@ -381,6 +382,7 @@ def dl_extract_zip(
381
 
382
  return extract_loc
383
 
 
384
  def remove_repeated_words(bot_response):
385
  """
386
  remove_repeated_words - remove repeated words from a string, returning only the first instance of each word
@@ -418,6 +420,7 @@ def remove_trailing_punctuation(text: str, fuLL_strip=False):
418
  else:
419
  return text.strip(".,;:")
420
 
 
421
  def split_sentences(text: str):
422
  """
423
  split_sentences - split a string into a list of sentences that keep their ending punctuation
@@ -428,4 +431,4 @@ def split_sentences(text: str):
428
  Returns:
429
  [list]: [list of sentences]
430
  """
431
- return re.split(r"(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?)\s", text)
 
29
  # removes extra spaces
30
  return re.sub(r"\.(?! )", ". ", re.sub(r" +", " ", s))
31
 
32
+
33
  def get_timestamp():
34
  return datetime.now().strftime("%b-%d-%Y_t-%H")
35
 
 
382
 
383
  return extract_loc
384
 
385
+
386
  def remove_repeated_words(bot_response):
387
  """
388
  remove_repeated_words - remove repeated words from a string, returning only the first instance of each word
 
420
  else:
421
  return text.strip(".,;:")
422
 
423
+
424
  def split_sentences(text: str):
425
  """
426
  split_sentences - split a string into a list of sentences that keep their ending punctuation
 
431
  Returns:
432
  [list]: [list of sentences]
433
  """
434
+ return re.split(r"(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?)\s", text)