コード例 #1
0
ファイル: nantucket.py プロジェクト: laventura/Nantucket
    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']
コード例 #2
0
ファイル: nantucket.py プロジェクト: ajtulloch/Nantucket
    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
コード例 #3
0
ファイル: nantucket.py プロジェクト: martindemello/Nantucket
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)}
コード例 #4
0
ファイル: nantucket.py プロジェクト: vibster/Nantucket
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)}