Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setLocale(self,locale):
"""
Sets locale-related data.
"""
if os.path.exists(locale):
self.hyphenator = pyphen.Pyphen(filename=locale)
elif len(locale) > 1 and locale in pyphen.LANGUAGES:
self.hyphenator = pyphen.Pyphen(lang=locale)
self.setTokenizeLanguage(locale)
else:
raise LookupError("provided locale not supported by pyphen")
def _get_hyphenator(self, lang):
if not lang in HtmlHyphenator.hyphenator_f:
if has_wordaxe and lang in wordaxe_languages:
h = DCWHyphenator(lang, minWordLength=3)
HtmlHyphenator.hyphenator[lang] = h
HtmlHyphenator.hyphenator_f[lang] = \
lambda w: wordaxe_hyphenation_wrapper(h, w)
elif has_pyphen and lang in pyphen.LANGUAGES:
h = pyphen.Pyphen(lang=lang)
HtmlHyphenator.hyphenator[lang] = h
HtmlHyphenator.hyphenator_f[lang] = \
lambda w: h.inserted(w, hyphen=HtmlHyphenator.html_hypenation_mark)
else:
HtmlHyphenator.hyphenator_f[lang] = lambda x: x
return HtmlHyphenator.hyphenator_f[lang]
def _pyphen(words):
if 'en' not in pyphen.LANGUAGES:
print('pyphen: No English dictionary!')
return
dct = pyphen.Pyphen(lang='en')
syllables = []
for word in words:
syl = dct.inserted(word).count('-') + 1
syllables.append(syl)
return syllables