Esempio n. 1
0
    def test_loading_full_built_in_isle_dictionary(self):
        # This takes time (~0.5s) so we'll only do it for this one test
        # In other tests for Isle, we'll open the much smaller VirtualIsle,
        # which should be almost instant
        sut = isletool.Isle()

        # This test requires knowledge of the built in dictionary.
        # Please reference that file (pysle/data/ISLEdict.txt)
        # I don't like it, but I don't know of another way
        # Notice that the entry for cat is slightly different
        # than with the one defined in the VirtualIsle.
        cat = sut.lookup("cat")
        self.assertEqual(1, len(cat))
        self.assertEqual(
            phonetics.Entry("cat", [[["k", "ˈæ", "t"]]], ["nn", "nnp"]), cat[0]
        )

        # The number of unique words in the built-in dictionary
        self.assertEqual(254_430, len(sut.rawData.keys()))
Esempio n. 2
0
# encoding: utf-8
"""
An example of how to syllabify a textgrid.

This code is an optional feature of pysle that requires the
praatio library.
"""

from os.path import join

from praatio import textgrid
from pysle import isletool
from pysle import praattools

root = join(".", "files")
isle = isletool.Isle(join(root, "ISLEdict_sample.txt"))

tg = textgrid.openTextgrid(join(root, "pumpkins.TextGrid"),
                           includeEmptyIntervals=False)

# Get the syllabification tiers and add it to the textgrid
syllableTG = praattools.syllabifyTextgrid(
    isle,
    tg,
    "word",
    "phone",
    skipLabelList=[
        "",
    ],
    stressDetectionErrorMode="warning",
    syllabificationErrorMode="warning",
Esempio n. 3
0
# encoding: utf-8
"""
Examples of how to use pysle's regular-expression-based
search functionality.
"""

from pysle import isletool

isle = isletool.Isle()


def printOutMatches(
    matchStr,
    numSyllables=None,
    wordInitial="ok",
    wordFinal="ok",
    spanSyllable="ok",
    stressedSyllable="ok",
    multiword="ok",
    numMatches=None,
    pos=None,
    exactMatch=False,
    randomize=True,
):
    """Helper function to run searches and output results"""
    for i, wordInfo in enumerate(
            isle.search(
                matchStr,
                numSyllables,
                wordInitial,
                wordFinal,