Skip to content

Commit

Permalink
Fix word shortener function
Browse files Browse the repository at this point in the history
Previously, dùin (to close) was being turned to "dnidh" in the future tense, which obviously isn't how it works, so I fixed the word-shortener, which now doesn't shorten the word if it only contains one set of vowels.
  • Loading branch information
sourzo committed Apr 27, 2023
1 parent 198c679 commit 43a1f93
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions is_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,19 @@ def shorten(word):
if word.endswith(("il","in","ir")):
consonants = [char for char in word if char not in vowels]
cut_pos = word.rfind(consonants[-2]) + 1
return word[:cut_pos] + word[-1]
shorter_word = word[:cut_pos] + word[-1]
if len([char for char in shorter_word if char in vowels]) == 0:
return word
else:
return shorter_word
elif word.endswith(("inn")):
consonants = [char for char in word if char not in vowels]
cut_pos = word.rfind(consonants[-3]) + 1
return word[:cut_pos] + "n"
shorter_word = word[:cut_pos] + "n"
if len([char for char in shorter_word if char in vowels]) == 0:
return word
else:
return shorter_word
else:
return word

Expand Down

0 comments on commit 43a1f93

Please sign in to comment.