How to use the pyphen.LANGUAGES function in pyphen

To help you get started, we’ve selected a few pyphen examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wimmuskee / readability-score / readability_score / textanalyzer.py View on Github external
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")
github wmark / thot / src / thot / plugins / HtmlPostProcessing.py View on Github external
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]
github SwagLyrics / autosynch / src / hyphenate.py View on Github external
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

pyphen

Pure Python module to hyphenate text

(GPL-2.0 OR LGPL-2.0 OR MPL-1…
Latest version published 24 days ago

Package Health Score

79 / 100
Full package analysis