2017-06-27 23:42:00 +00:00
|
|
|
# coding: utf8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
class IrishMorph:
|
|
|
|
consonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'z']
|
|
|
|
broad_vowels = ['a', 'á', 'o', 'ó', 'u', 'ú']
|
|
|
|
slender_vowels = ['e', 'é', 'i', 'í']
|
|
|
|
vowels = broad_vowels + slender_vowels
|
|
|
|
|
|
|
|
def ends_dentals(word):
|
2017-06-28 09:59:46 +00:00
|
|
|
if word != "" and word[-1] in ['d', 'n', 't', 's']:
|
2017-06-27 23:42:00 +00:00
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def devoice(word):
|
2017-06-28 09:59:46 +00:00
|
|
|
if len(word) > 2 and word[-2] == 's' and word[-1] == 'd':
|
2017-06-27 23:42:00 +00:00
|
|
|
return word[:-1] + 't'
|
|
|
|
else:
|
|
|
|
return word
|
|
|
|
|
|
|
|
def ends_with_vowel(word):
|
2017-06-28 09:59:46 +00:00
|
|
|
return word != "" and word[-1] in vowels
|
2017-06-27 23:42:00 +00:00
|
|
|
|
|
|
|
def starts_with_vowel(word):
|
2017-06-28 09:59:46 +00:00
|
|
|
return word != "" and word[0] in vowels
|
2017-06-27 23:42:00 +00:00
|
|
|
|
|
|
|
def deduplicate(word):
|
2017-06-28 09:59:46 +00:00
|
|
|
if len(word) > 2 and word[-2] == word[-1] and word[-1] in consonants:
|
2017-06-27 23:42:00 +00:00
|
|
|
return word[:-1]
|
|
|
|
else:
|
|
|
|
return word
|
|
|
|
|