Skip to content

Commit

Permalink
Merge pull request #12 from DoctorInsano/empty-string-tokenize-fix
Browse files Browse the repository at this point in the history
Fix an issue where double spaces would get picked up and turn into empty string tokens
  • Loading branch information
tomaarsen authored Apr 12, 2021
2 parents 191faab + 67d1265 commit d4ab67d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion MarkovChainBot.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,10 @@ def message_handler(self, m):
for sentence in sentences:
# Get all seperate words
words = sentence.split(" ")

# Double spaces will lead to invalid rules. We remove empty words here
if "" in words:
words = [word for word in words if word]

# If the sentence is too short, ignore it and move on to the next.
if len(words) <= self.key_length:
continue
Expand Down

0 comments on commit d4ab67d

Please sign in to comment.