Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions chatterbot/preprocessors_greek.py
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions tests/test_preprocessors_greek.py
Original file line number Diff line number Diff line change
@@ -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)