From def533042f6d4953748b4228db6ef6e04b426a85 Mon Sep 17 00:00:00 2001 From: Jeronymous Date: Tue, 25 Apr 2023 12:45:34 +0000 Subject: [PATCH] fix possible error on empty sentences --- RELEASE.md | 5 ++++- celery_app/tasks.py | 4 +++- http_server/ingress.py | 7 ++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index de33f05..9d44b1a 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -1,3 +1,6 @@ +# 1.1.1 +- Fix error on empty sentences + # 1.1.0 - Added service registration - Updated README @@ -11,4 +14,4 @@ # 1.0.0 - Punctuation service. -- HTTP or Celery serving. \ No newline at end of file +- HTTP or Celery serving. diff --git a/celery_app/tasks.py b/celery_app/tasks.py index 9093020..790ea99 100644 --- a/celery_app/tasks.py +++ b/celery_app/tasks.py @@ -41,7 +41,9 @@ def punctuation_task(self, text: Union[str, list]): else: print("Failed to predict punctuation on sentence: >{sentence}<") punctuated_sentence = sentence - punctuated_sentence = punctuated_sentence[0].upper() + punctuated_sentence[1:] + # First letter in capital + if len(punctuated_sentence): + punctuated_sentence = punctuated_sentence[0].upper() + punctuated_sentence[1:] punctuated_sentences.append(punctuated_sentence) return ( diff --git a/http_server/ingress.py b/http_server/ingress.py index 66c40d0..926171b 100644 --- a/http_server/ingress.py +++ b/http_server/ingress.py @@ -61,9 +61,10 @@ def punctuate(): if result.status_code == 200: punctuated_sentence = result.text # First letter in capital - punctuated_sentence = ( - punctuated_sentence[0].upper() + punctuated_sentence[1:] - ) + if len(punctuated_sentence): + punctuated_sentence = ( + punctuated_sentence[0].upper() + punctuated_sentence[1:] + ) punctuated_sentences.append(punctuated_sentence) else: raise Exception(result.text)