MCPcopy Index your code
hub / github.com/clips/pattern / is_short_syllable

Function is_short_syllable

pattern/vector/stemmer.py:40–53  ·  view source on GitHub ↗

A short syllable in a word is either: - a vowel followed by a non-vowel other than w, x or Y and preceded by a non-vowel - a vowel at the beginning of the word followed by a non-vowel. Checks the three characters before the given index in the word (or entire word if None).

(w, before=None)

Source from the content-addressed store, hash-verified

38 return s in DOUBLE
39
40def is_short_syllable(w, before=None):
41 """ A short syllable in a word is either:
42 - a vowel followed by a non-vowel other than w, x or Y and preceded by a non-vowel
43 - a vowel at the beginning of the word followed by a non-vowel.
44 Checks the three characters before the given index in the word (or entire word if None).
45 """
46 if before != None:
47 i = before<0 and len(w)+before or before
48 return is_short_syllable(w[max(0,i-3):i])
49 if len(w) == 3 and is_consonant(w[0]) and is_vowel(w[1]) and is_consonant(w[2]) and w[2] not in "wxY":
50 return True
51 if len(w) == 2 and is_vowel(w[0]) and is_consonant(w[1]):
52 return True
53 return False
54
55def is_short(w):
56 """ A word is called short if it consists of a short syllable preceded by zero or more consonants.

Callers 2

is_shortFunction · 0.85
step_5aFunction · 0.85

Calls 3

lenFunction · 0.85
is_consonantFunction · 0.85
is_vowelFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…