Package: cadences
CadenceA rhythm analysis toolkit, gathering multiple parsing engines:Prosodicfor fast English and Finnish metrical scansion.Cadence now uses its own metrical parser, a rewritten version of Prosodic's.Stanzafor syntactic parsing.MetricalTreefor sentence rhythm/phrasal stress assignment based on Stanza's syntactic parses.QuickstartInstall1. Install python package# install from pypi
pip install -U cadences    # "cadence" was taken :-/

# or from github very latest
pip install -U git+https://github.com/quadrismegistus/cadence2. Insteall espeak (TTS)Install espeak, free TTS software, to 'sound out' unknown words. Seeherefor all downloads.On Linux, type into the terminal:apt-get install espeakOn Mac:Installhomebrewif not already installed.Type into the Terminal app:brew install espeakOn Windows:
Download and install fromhttp://espeak.sourceforge.net/download.html.Load cadence# this should work following installationimportcadenceascdLoad texts# versesonnetXIV="""How can I then return in happy plight,That am debarred the benefit of rest?When day’s oppression is not eased by night,But day by night and night by day oppressed,And each, though enemies to either’s reign,Do in consent shake hands to torture me,The one by toil, the other to complainHow far I toil, still farther off from thee.I tell the day, to please him thou art bright,And dost him grace when clouds do blot the heaven:So flatter I the swart-complexiond night,When sparkling stars twire not thou gildst the even.But day doth daily draw my sorrows longer,And night doth nightly make grief’s length seem stronger."""# prosemelville="""Is it that by its indefiniteness it shadows forth theheartless voids and immensities of the universe, and thus stabs usfrom behind with the thought of annihilation, when beholdingthe white depths of the milky way? Or is it, that as inessence whiteness is not so much a colour as the visible absenceof colour; and at the same time the concrete of all colours;is it for these reasons that there is such a dumb blankness,full of meaning, in a wide landscape of snows: a colourless,all-colour of atheism from which we shrink?"""# These are identicalsonnet=cd.Verse(sonnetXIV)sonnet=cd.Text(sonnetXIV,linebreaks=True,phrasebreaks=False)# So are theseprose=cd.Prose(melville)prose=cd.Text(melville,linebreaks=False,phrasebreaks=True)Available features# Tokenizesonnet.words()word_ispuncpara_isent_isentpart_iline_iword_iword_str11111How02can03I04then05return0..................4171415grief's016length017seem018stronger019.1135 rows × 1 columns# Syllabifysonnet.sylls()prom_strengthprom_stressprom_weightword_isfuncword_ispuncword_nsyllpara_isent_isentpart_iline_iword_iword_strword_tokword_ipa_iword_ipasyll_isyll_strsyll_ipasyll_stresssyll_weight11111Howhow1haʊ1HowhaʊUHNaN0.01.01.0012cancan1kæn1cankænUHNaN0.01.01.0013Ii1'aɪ1I'aɪPH1.01.01.00.0012aɪ1IaɪUH0.00.01.01.0014thenthen1'ðɛn1then'ðɛnPH1.01.01.00.001.........................................................4171416lengthlength1'lɛŋkθ1length'lɛŋkθPHNaN1.01.00.00117seemseem1'siːm1seem'siːmPHNaN1.01.00.00118strongerstronger1'strɔːŋ.ɛː1stron'strɔːŋPH1.01.01.00.0022gerɛːUL0.00.00.00.00219.00.NaNNaNNaNNaNNaNNaN10186 rows × 6 columns# Syntax-parsesonnet.syntax()dep_headdep_typepos_casepos_definitepos_degreepos_genderpos_moodpos_numberpos_personpos_polaritypos_posspos_prontypepos_tensepos_upospos_verbformpos_voicepos_xposword_depthpara_isent_iword_iword_str111How5advmodIntADVWRB42can5auxAUXFinMD43I5nsubjNomSing1PrsPRONPRP54then5advmodDemADVRB55return0rootVERBInfVB5...............................................................415grief's16compoundPlurNOUNNNS816length14objSingNOUNNN817seem14xcompVERBInfVB1018stronger17xcompCmpADJJJR1219.5punctPUNCT.3135 rows × 18 columnsSentence-level information from MetricalTree# Show sentencessentence=sonnet.sent(1)sentence.mtree()# Show sentence tree for proseprose.sent(1).mtree()# Stress grid of sentence inferred from syntactic treesentence.grid()Metrical parsing# Parse lines (verse)sonnet.parse()How canIthenreturninhappyplight,Thatamdebarredthebenefitofrest?Whenday'soppressionisnoteasedbynight,Butdaybynightandnightbydayoppressed,Andeach, thoughenemiestoeither'sreign,Doinconsentshakehandstotortureme,Theonebytoil, theothertocomplainHowfarItoil,stillfartherofffrom thee.Itelltheday, topleasehim thouartbright,Anddosthimgracewhencloudsdoblottheheaven:SoflatterItheswart- complexiondnight,Whensparklingstarstwirenotthougildsttheeven.Butdaydothdailydrawmysorrowslonger,Andnightdothnightlymakegrief'slengthseemstronger.*total*s_unstressed*unres_across*unres_within*w_peak*w_stresseddep_headdep_typemtree_isheadnum_parsespos_casepos_definitepos_degreepos_genderpos_moodpos_numberpos_personpos_polaritypos_posspos_prontypepos_tensepos_upospos_verbformpos_voicepos_xposprom_lstressprom_pstrengthprom_pstressprom_strengthprom_stressprom_tstressprom_weightword_depthword_isfuncword_ispuncword_nsyllpara_iunit_iparse_rankis_trochparse_iparseparse_strsent_isentpart_iline_icombo_islot_islot_metersyll_str_parseword_iword_strword_tokword_ipa_iword_ipasyll_isyll_strsyll_ipasyll_stresssyll_weight11101wwSSwSwSwS𝖧𝗈𝗐 𝖼𝖺𝗇 𝗜 𝙩𝙝𝙚𝙣 𝗋𝖾𝘁𝘂𝗿𝗻 𝗂𝗇 𝗵𝗮𝗽𝗉𝗒 𝗽𝗹𝗶𝗴𝗵𝘁,11111w𝖧𝗈𝗐1Howhow1haʊ1HowhaʊUH0.00.00.00.00.00.05advmodNaN4IntADVWRB0.0NaN0.0NaN0.00.0000001.041.0012w𝖼𝖺𝗇2cancan1kæn1cankænUH0.00.00.00.00.00.05auxNaN4AUXFinMD0.0NaN0.0NaN0.00.3333331.041.0013s𝗜3Ii1'aɪ1I'aɪPH0.00.00.00.00.00.05nsubjNaN4NomSing1PrsPRONPRP0.0NaN0.01.01.00.0000001.050.0014s𝙩𝙝𝙚𝙣4thenthen1'ðɛn1then'ðɛnPH1.00.01.00.00.00.05advmodNaN4DemADVRB0.0NaN0.01.01.00.0000001.050.0015w𝗋𝖾5returnreturn1rɪ.'tɛːn1rerɪUL0.00.00.00.00.00.00rootNaN4VERBInfVBNaNNaNNaN0.00.0NaN0.050.002.................................................................................................................................................................................14201wSwSwSSwSSw𝖠𝗇𝖽 𝗻𝗶𝗴𝗵𝘁 𝖽𝗈𝗍𝗁 𝗻𝗶𝗴𝗵𝗍𝗅𝗒 𝗺𝗮𝗸𝗲 𝙜𝙧𝙞𝙚𝙛'𝙨 𝘭𝘦𝘯𝘨𝘵𝘩 𝘀𝗲𝗲𝗺 𝙨𝙩𝙧𝙤𝙣𝗀𝖾𝗋.4171418w𝘭𝘦𝘯𝘨𝘵𝘩16lengthlength1'lɛŋkθ1length'lɛŋkθPH1.00.00.00.00.01.014objNaN2SingNOUNNN1.00.00.0NaN1.00.7500001.080.0019s𝘀𝗲𝗲𝗺17seemseem1'siːm1seem'siːmPH0.00.00.00.00.00.014xcompNaN2VERBInfVB1.00.00.0NaN1.00.7500001.0100.00110s𝙨𝙩𝙧𝙤𝙣18strongerstronger1'strɔːŋ.ɛː1stron'strɔːŋPH1.00.01.00.00.00.017xcompNaN2CmpADJJJR1.01.01.01.01.01.0000001.0120.00211w𝗀𝖾𝗋18strongerstronger1'strɔːŋ.ɛː2gerɛːUL0.00.00.00.00.00.017xcompNaN2CmpADJJJRNaNNaNNaN0.00.0NaN0.0120.00212NaN.19.00.NaNNaN0.0NaNNaNNaNNaNNaN5punctNaN2PUNCT.NaNNaNNaNNaNNaNNaNNaN3NaN10303 rows × 36 columns# Parse proseprose.parse()Isitthat byitsindefiniteness itshadowsforththeheartlessvoidsand immensitiesof theuniverse,andthusstabsusfrombehindwith thethoughtof annihilation,whenbeholding thewhitedepthsof themilkyway?Orisit,thatas inessencewhitenessisnot somuch acolourasthevisibleabsence ofcolour;andatthesametimetheconcreteofallcolours;isitfor thesereasonsthatthereissuch adumbblankness,fullofmeaning,in awidelandscapeofsnows:acolourless,all-colourofatheism fromwhichweshrink?*total*s_unstressed*unres_across*unres_within*w_peak*w_stresseddep_headdep_typemtree_isheadnum_parsespos_casepos_definitepos_degreepos_genderpos_moodpos_numberpos_personpos_polaritypos_posspos_prontypepos_tensepos_upospos_verbformpos_xposprom_lstressprom_pstrengthprom_pstressprom_strengthprom_stressprom_tstressprom_weightword_depthword_isfuncword_ispuncword_nsyllpara_iunit_iparse_rankis_trochparse_iparseparse_strsent_isentpart_iline_icombo_islot_islot_metersyll_str_parseword_iword_strword_tokword_ipa_iword_ipasyll_isyll_strsyll_ipasyll_stresssyll_weight11101wSwwSwSwSwwSSw𝖨𝗌 𝗶𝘁 𝗍𝗁𝖺𝗍 𝖻𝗒 𝙞𝙩𝙨 𝗂𝗇𝗱𝗲𝖿𝗂𝙣𝙞𝗍𝖾𝗇𝖾𝗌𝗌 𝘪𝘵 𝘀𝗵𝗮𝗱𝗼𝘄𝘀 𝘧𝘰𝘳𝘵𝘩111121w𝖨𝗌1Isis2ɪz1IsɪzUH0.00.00.00.00.00.08aux0.027IndSing3PresAUXFinVBZ0.0NaN0.00.00.00.6666671.031.0012s𝗶𝘁2itit1'ɪt1it'ɪtPH0.00.00.00.00.00.08nsubjNaN27NomNeutSing3PrsPRONPRP0.0NaN0.01.01.00.3333331.040.0013w𝗍𝗁𝖺𝗍3thatthat2ðət1thatðətUH0.00.00.00.00.00.08markNaN27SCONJIN0.0NaN0.00.00.00.3333331.041.0014w𝖻𝗒4byby1baɪ1bybaɪUH0.00.00.00.00.00.06caseNaN27ADPIN0.0NaN0.0NaN0.00.3333331.041.0015s𝙞𝙩𝙨5itsits1ɪts1itsɪtsUH1.01.00.00.00.00.06nmod:poss0.027NeutSing3YesPrsPRONPRP$0.00.00.0NaN0.00.3333331.051.001..............................................................................................................................................................................14808wSwwSwSwwSwS𝖺𝗅𝗅- 𝗰𝗼𝗅𝗈𝗎𝗋 𝘰𝘧 𝗮𝘁𝗁𝖾𝗶𝗌𝗆 𝘧𝘳𝘰𝘮 𝘄𝗵𝗶𝗰𝗵 𝗐𝖾 𝘀𝗵𝗿𝗶𝗻𝗸?21161410w𝘧𝘳𝘰𝘮66fromfrom1frʌm1fromfrʌmUH1.00.01.00.00.00.067caseNaN8ADPIN0.00.00.0NaN0.00.2500001.0131.00111s𝘄𝗵𝗶𝗰𝗵67whichwhich1'wɪʧ1which'wɪʧPH0.00.00.00.00.00.069oblNaN8RelPRONWDT0.0NaN0.01.01.00.0000001.0140.00112w𝗐𝖾68wewe2wiː1wewiːUL0.00.00.00.00.00.069nsubjNaN8NomPlur1PrsPRONPRP0.00.00.00.00.00.2500000.0141.00113s𝘀𝗵𝗿𝗶𝗻𝗸69shrinkshrink1'ʃrɪŋk1shrink'ʃrɪŋkPH0.00.00.00.00.00.063acl:relclNaN8IndPlur1PresVERBFinVBP1.01.01.0NaN1.01.0000001.0140.00114NaN?70?00?NaNNaN0.0NaNNaNNaNNaNNaN3punctNaN8PUNCT.NaNNaNNaNNaNNaNNaNNaN3NaN101241 rows × 35 columns