MCPcopy Create free account
hub / github.com/clips/pattern / _count_syllables

Function _count_syllables

pattern/text/en/inflect.py:755–764  ·  view source on GitHub ↗

Returns the estimated number of syllables in the word by counting vowel-groups.

(word)

Source from the content-addressed store, hash-verified

753SUPERLATIVE = "est"
754
755def _count_syllables(word):
756 """ Returns the estimated number of syllables in the word by counting vowel-groups.
757 """
758 n = 0
759 p = False # True if the previous character was a vowel.
760 for ch in word.endswith("e") and word[:-1] or word:
761 v = ch in VOWELS
762 n += int(v and not p)
763 p = v
764 return n
765
766def grade(adjective, suffix=COMPARATIVE):
767 """ Returns the comparative or superlative form of the given adjective.

Callers 1

gradeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…