Skip to content

Commit

Permalink
Merge pull request #186 from TylerKirby/master
Browse files Browse the repository at this point in the history
Clausulae Analysis Class
  • Loading branch information
kylepjohnson committed Mar 9, 2016
2 parents 4894bde + ce24b12 commit 264fd91
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
49 changes: 49 additions & 0 deletions cltk/prosody/latin/clausulae_analysis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""
Return dictionary of clausulae found in the prosody of Latin prose.
The clausulae analysis function returns a dictionary in which the key is the type of clausula and the value is the number
of times it occurs in the text. The list of clausulae used in the method is derived from the 'Prose Rhythm' section
of John Ramsey's Cambridge commentary on Cicero's Philippics I-II, so it is mostly representative of Ciceronian
clausulae. Because of the heavy Greek influence on Cicero's rhythms, however, the clausulae analysis may also be used
on the prosody of Greek prose as well.
"""

__author__ = 'Tyler Kirby <tyler.kirby9398@gmail.com>'
__license__ = 'MIT License. See LICENSE'


class Clausulae:
def __init__(self):
"""Initialize class."""
return

@staticmethod
def clausulae_analysis(prosody):
"""
Return dictionary in which the key is a type of clausula and the value is its frequency.
:param prosody: the prosody of a prose text (must be in the format of the scansion produced by the scanner classes.
:return: dictionary of prosody
"""

prosody = ''.join(prosody)

return {
'cretic + trochee': prosody.count('¯˘¯¯x'),
'4th paeon + trochee': prosody.count('˘˘˘¯¯x'),
'1st paeon + trochee': prosody.count('¯˘˘˘¯x'),
'substituted cretic + trochee': prosody.count('˘˘˘˘˘¯x'),
'1st paeon + anapest': prosody.count('¯˘˘˘˘˘x'),
'double cretic': prosody.count('¯˘¯¯˘x'),
'4th paeon + cretic': prosody.count('˘˘˘¯¯˘x'),
'molossus + cretic': prosody.count('¯¯¯¯˘x'),
'double trochee': prosody.count('¯˘¯x'),
'molossus + double trochee': prosody.count('¯¯¯¯˘¯x'),
'cretic + double trochee': prosody.count('¯˘¯¯˘¯x'),
'dactyl + double trochee': prosody.count('¯˘˘¯˘¯x'),
'choriamb + double trochee': prosody.count('¯˘˘¯¯˘¯x'),
'cretic + iamb': prosody.count('¯˘¯˘x'),
'molossus + iamb': prosody.count('¯¯¯˘x'),
'double spondee': prosody.count('¯¯¯x'),
'cretic + double spondee': prosody.count('¯˘¯¯¯¯x'),
'heroic': prosody.count('¯˘˘¯x')
}
26 changes: 26 additions & 0 deletions cltk/tests/test_prosody.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
__license__ = 'MIT License. See LICENSE.'

from cltk.prosody.latin.scanner import Scansion as ScansionLatin
from cltk.prosody.latin.clausulae_analysis import Clausulae
from cltk.prosody.greek.scanner import Scansion as ScansionGreek
import unittest

Expand Down Expand Up @@ -85,5 +86,30 @@ def test_scan_text_greek(self):
current = ScansionGreek().scan_text(self.test)
self.assertEqual(current, correct)

def test_clausulae_analysis(self):
"""Test clausulae_analysis"""
correct = {
'cretic + double spondee': 0,
'1st paeon + anapest': 0,
'double cretic': 0,
'double trochee': 1,
'dactyl + double trochee': 0,
'4th paeon + cretic': 0,
'cretic + trochee': 0,
'molossus + iamb': 0,
'cretic + double trochee': 0,
'heroic': 0,
'double spondee': 0,
'molossus + double trochee': 0,
'1st paeon + trochee': 0,
'cretic + iamb': 0,
'substituted cretic + trochee': 0,
'4th paeon + trochee': 0,
'molossus + cretic': 0,
'choriamb + double trochee': 0
}
current = Clausulae().clausulae_analysis(['˘¯¯¯˘¯¯˘¯˘¯˘˘x', '¯¯˘¯x'])
self.assertEqual(current, correct)

if __name__ == '__main__':
unittest.main()

0 comments on commit 264fd91

Please sign in to comment.