How to use the pysle.isletool.search function in pysle

To help you get started, we’ve selected a few pysle 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 timmahrt / pysle / examples / dictionary_search.py View on Github external
def printOutMatches(matchStr, numSyllables=None, wordInitial='ok',
                    wordFinal='ok', spanSyllable='ok',
                    stressedSyllable='ok', multiword='ok',
                    numMatches=None, matchList=None, pos=None):
    '''Helper function to run searches and output results'''
    if matchList is None:
        matchList = isleDict.search(matchStr, numSyllables, wordInitial,
                                    wordFinal, spanSyllable,
                                    stressedSyllable, multiword, pos)
    else:
        matchList = isletool.search(matchList, matchStr, numSyllables,
                                    wordInitial, wordFinal, spanSyllable,
                                    stressedSyllable, multiword, pos)

    if numMatches is not None and len(matchList) > numMatches:
        random.shuffle(matchList)

    for i, matchTuple in enumerate(matchList):
        if numMatches is not None and i > numMatches:
            break
        word, pronList = matchTuple
        pronList = ["%s(%s)" % (tmpWord, ",".join(posInfo))
                    for tmpWord, posInfo in pronList]
        print("%s: %s" % (word, ",".join(pronList)))
    print("")

    return matchList