mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 09:26:27 +03:00
bounds checks
This commit is contained in:
parent
1ba38b2036
commit
70f4d26c10
|
@ -8,25 +8,25 @@ class IrishMorph:
|
||||||
vowels = broad_vowels + slender_vowels
|
vowels = broad_vowels + slender_vowels
|
||||||
|
|
||||||
def ends_dentals(word):
|
def ends_dentals(word):
|
||||||
if word[-1:] in ['d', 'n', 't', 's']:
|
if word != "" and word[-1] in ['d', 'n', 't', 's']:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def devoice(word):
|
def devoice(word):
|
||||||
if word[-2] == 's' and word[-1] == 'd':
|
if len(word) > 2 and word[-2] == 's' and word[-1] == 'd':
|
||||||
return word[:-1] + 't'
|
return word[:-1] + 't'
|
||||||
else:
|
else:
|
||||||
return word
|
return word
|
||||||
|
|
||||||
def ends_with_vowel(word):
|
def ends_with_vowel(word):
|
||||||
return word[-1] in vowels
|
return word != "" and word[-1] in vowels
|
||||||
|
|
||||||
def starts_with_vowel(word):
|
def starts_with_vowel(word):
|
||||||
return word[0] in vowels
|
return word != "" and word[0] in vowels
|
||||||
|
|
||||||
def deduplicate(word):
|
def deduplicate(word):
|
||||||
if word[-2] == word[-1] and word[-1] in consonants:
|
if len(word) > 2 and word[-2] == word[-1] and word[-1] in consonants:
|
||||||
return word[:-1]
|
return word[:-1]
|
||||||
else:
|
else:
|
||||||
return word
|
return word
|
||||||
|
|
Loading…
Reference in New Issue
Block a user