def test_get_syllable_dict(self): syll_lu = _resources.get_syllable_dict() self.assertIsInstance(syll_lu, dict) self.assertEqual(2, syll_lu.get('aa')) self.assertEqual(4, syll_lu.get('a cappella')) self.assertEqual(3, syll_lu.get('zyrian')) self.assertIsNone(syll_lu.get('Ahab'))
Run with -h for detailed options. Created on Nov 26, 2012 @author: Henry Keiter @version: Python 3.3 ''' import argparse import collections import os import sys import _resources from prosl_utils import split_string, memoized SYLLABLE_LOOKUP = _resources.get_syllable_dict() PROXIMITY_FLAG = 10 CTHRESH_FLAG = 20 WTHRESH_FLAG = 30 @memoized def _count_syllables(word): '''Get a real or estimated value for the number of syllables in the word. If the word is present in the mhyph hyphenated corpus, return the number of syllables found there. Else, estimate the number of syllables as best as (easily) possible (_estimate_syllables(word)). @NOTE: The given word should be lowercase, or it will fall through this