From e8c77524001ba08b43befdbc29d745e98b1448e3 Mon Sep 17 00:00:00 2001
From: AlenBasia <alenbasia@gmail.com>
Date: Wed, 23 Dec 2020 19:51:29 +0200
Subject: [PATCH 1/2] Added a preprocessor for Greek language in the file
 preprocessors_greek.py. This preprocessor can be used for fixing final sigma
 in statements. In Greek the words that end with sigma should use final_sigma
 instead of the normal sigma. It is very useful in Greek language because it
 is very common to type words with normal sigma in chats.

---
 chatterbot/preprocessors_greek.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 chatterbot/preprocessors_greek.py

diff --git a/chatterbot/preprocessors_greek.py b/chatterbot/preprocessors_greek.py
new file mode 100644
index 000000000..cc8238102
--- /dev/null
+++ b/chatterbot/preprocessors_greek.py
@@ -0,0 +1,18 @@
+"""
+Statement pre-processors for Greek language.
+"""
+def fix_final_sigma(statement):
+    '''
+    If there is a word that ends with "σ" it replaces it with "ς".
+    '''
+    
+    data = statement.text.split()
+    text = ""
+    
+    for word in data:
+        if word[-1]=="σ":
+            word = word[:-1] + "ς" 
+        text = text + word + " "
+    statement.text = text
+    
+    return statement

From fd40ebfd99135013b9901a8c86e38ecbde11440c Mon Sep 17 00:00:00 2001
From: AlenBasia <alenbasia@gmail.com>
Date: Wed, 23 Dec 2020 23:19:47 +0200
Subject: [PATCH 2/2] Added test for fix_final_sigma in preprocessors_greek.py

---
 tests/test_preprocessors_greek.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
 create mode 100644 tests/test_preprocessors_greek.py

diff --git a/tests/test_preprocessors_greek.py b/tests/test_preprocessors_greek.py
new file mode 100644
index 000000000..8f39c7c79
--- /dev/null
+++ b/tests/test_preprocessors_greek.py
@@ -0,0 +1,17 @@
+from tests.base_case import ChatBotTestCase
+from chatterbot.conversation import Statement
+from chatterbot import preprocessors_greek
+
+class PreprocessorFixFinalSigmaTestCase(ChatBotTestCase):
+    """
+    Make sure ChatterBot's final sigma replacing preprocessor works as expected.
+    """
+
+    def test_fix_final_sigma(self):
+        statement = Statement(text='Γεια σασ')
+
+        fixed = preprocessors_greek.fix_final_sigma(statement)
+        normalText = 'Γεια σας'
+        self.chatbot.preprocessors = [preprocessors.clean_whitespace]
+
+        self.assertEqual(fixed.text, normalText)