Exemplo n.º 1
0
    elif syllable_counter < 35 and current_sylct > 35 - syllable_counter:
        return True
    return False


limericks = []
word_data = {}
i = 0
while i < len(tokens):
    if tokens[i] == '':
        tokens.remove('')
        continue
    start_word = tokens[i]
    if not start_word in word_data:
        word_data[start_word] = {"sylct": poetry.nsyl(start_word),
        "phonemes": poetry.phonemes(start_word)}
        # Uses more space in exchange for getting more speed
    word_array = [start_word]
        # Holds the actual words of the potential limerick
    syllable_counter = word_data[start_word]['sylct']
    n = i + 1
    rhyme_scheme = {}  # Tracks the rhyme scheme
    while n < len(tokens):
        if tokens[n] == '':
            tokens.remove('')
            continue
        next_word = tokens[n]
        if not next_word in word_data:
            word_data[next_word] = {"sylct": poetry.nsyl(next_word),
            "phonemes": poetry.phonemes(next_word)}
        sylct = word_data[next_word]['sylct']
Exemplo n.º 2
0
    elif syllable_counter < 21 and current_sylct > 21 - syllable_counter:
        return True
    elif syllable_counter < 26 and current_sylct > 26 - syllable_counter:
        return True
    elif syllable_counter < 35 and current_sylct > 35 - syllable_counter:
        return True
    return False


limericks = []
word_data = {}
i = 0
while i < len(tokens):
    start_word = tokens[i]
    if not start_word in word_data:
        word_data[start_word] = {"sylct": poetry.nsyl(start_word), "phonemes": poetry.phonemes(start_word)}
        # Uses more space in exchange for getting more speed
    word_array = [start_word]  # Holds the actual words of the potential limerick
    syllable_counter = word_data[start_word]['sylct']
    n = i + 1
    rhyme_scheme = {}  # Tracks the rhyme scheme
    # if not syllable_counters[i]: print start_word  #    looks for not-in-cmudict words for me to study from
    while n < len(tokens):
        next_word = tokens[n]
        if not next_word in word_data:
            word_data[next_word] = {"sylct": poetry.nsyl(next_word), "phonemes": poetry.phonemes(next_word)}
        sylct = word_data[next_word]['sylct']
        if overflows_line(syllable_counter, sylct):
            break  # break out if a word overflows the line
        word_array.append(next_word)
        syllable_counter += sylct
Exemplo n.º 3
0
def new_word_data(word):
    ''' return a dict with the syllable count and phonemes in the word '''
    return {"sylct": poetry.nsyl(word), "phonemes": poetry.phonemes(word)}
Exemplo n.º 4
0
def new_word_data(word):
    ''' return a dict with the syllable count and phonemes in the word '''
    return {"sylct": poetry.nsyl(word), "phonemes": poetry.phonemes(word)}