<jupyter_start><jupyter_text>Syllables<jupyter_code># http://docs.cltk.org/en/latest/latin.html#syllabifier
from cltk.stem.latin.syllabifier import Syllabifier

cato_agri_praef = "Est interdum praestare mercaturis rem quaerere, nisi tam periculosum sit, et item foenerari, si tam honestum. Maiores nostri sic habuerunt et ita in legibus posiverunt: furem dupli condemnari, foeneratorem quadrupli. Quanto peiorem civem existimarint foeneratorem quam furem, hinc licet existimare. Et virum bonum quom laudabant, ita laudabant: bonum agricolam bonumque colonum; amplissime laudari existimabatur qui ita laudabatur. Mercatorem autem strenuum studiosumque rei quaerendae existimo, verum, ut supra dixi, periculosum et calamitosum. At ex agricolis et viri fortissimi et milites strenuissimi gignuntur, maximeque pius quaestus stabilissimusque consequitur minimeque invidiosus, minimeque male cogitantes sunt qui in eo studio occupati sunt. Nunc, ut ad rem redeam, quod promisi institutum principium hoc erit."

from cltk.tokenize.word import WordTokenizer
word_tokenizer = WordTokenizer('latin')
cato_cltk_word_tokens = word_tokenizer.tokenize(cato_agri_praef.lower())
cato_cltk_word_tokens_no_punt = [token for token in cato_cltk_word_tokens if token not in ['.', ',', ':', ';']]

# now you can see the word '-que'
print(cato_cltk_word_tokens_no_punt)
syllabifier = Syllabifier()

for word in cato_cltk_word_tokens_no_punt:
    syllables = syllabifier.syllabify(word)
    print(word, syllables)<jupyter_output>est ['est']
interdum ['in', 'ter', 'dum']
praestare ['praes', 'ta', 're']
mercaturis ['mer', 'ca', 'tu', 'ris']
rem ['rem']
quaerere ['quae', 're', 're']
nisi ['ni', 'si']
tam ['tam']
periculosum ['pe', 'ri', 'cu', 'lo', 'sum']
sit ['sit']
et ['et']
item ['i', 'tem']
foenerari ['foe', 'ne', 'ra', 'ri']
si ['si']
tam ['tam']
honestum ['ho', 'nes', 'tum']
maiores ['ma', 'io', 'res']
nostri ['nos', 'tri']
sic ['sic']
habuerunt ['ha', 'bu', 'e', 'runt']
et ['et']
ita ['i', 'ta']
in ['in']
legibus ['le', 'gi', 'bus']
posiverunt ['po', 'si', 've', 'runt']
furem ['fu', 'rem']
dupli ['du', 'pli']
condemnari ['con', 'dem', 'na', 'ri']
foeneratorem ['foe', 'ne', 'ra', 'to', 'rem']
quadrupli ['qua', 'dru', 'pli']
quanto ['quan', 'to']
peiorem ['peio', 'rem']
civem ['ci', 'vem']
existimarint ['ex', 'is', 'ti', 'ma', 'rint']
foeneratorem ['foe', 'ne', 'ra', 'to', 'rem']
quam ['quam']
furem ['fu', 'rem']
hinc ['hinc']
licet ['li', 'cet']
existimare ['ex', 'is', 'ti', 'ma', 're']
et ['et']
virum ['vi[...]<jupyter_text>ProsodyTakes two steps: first find long vowels, then scan actual meter<jupyter_code># macronizer
# http://docs.cltk.org/en/latest/latin.html#macronizer
from cltk.prosody.latin.macronizer import Macronizer

macronizer = Macronizer('tag_ngram_123_backoff')

text = 'Quo usque tandem, O Catilina, abutere nostra patientia?'

scanned_text = macronizer.macronize_text(text)
# scanner
# http://docs.cltk.org/en/latest/latin.html#prosody-scanning

from cltk.prosody.latin.scanner import Scansion

scanner = Scansion()
prose_text = macronizer.macronize_tags(scanned_text)
print(prose_text)<jupyter_output>[('quō', None, 'quō'), ('usque', 'd--------', 'usque'), ('tandem', 'd--------', 'tandem'), (',', 'u--------', ','), ('ō', None, 'ō'), ('catilīnā', None, 'catilīnā'), (',', 'u--------', ','), ('abūtēre', None, 'abūtēre'), ('nostrā', None, 'nostrā'), ('patientia', 'n-s---fn-', 'patientia'), ('?', None, '?')]
{'fraction_non_alphanumeric': 0.1942823803967328, 'fraction_numerical': 0.0008751458576429405, 'mean_word_length': 5.955375253549696, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '3268', 'license': 'MIT', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1387, 'n_words': 361, 'path': '7 Syllabification, prosody, phonetics.ipynb', 'repo_name': 'cs145442/gsoc2018Practice', 'size': '3428'}