Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from typing import List
import numpy as np
class Verse:
self.readings = list()
self.author = None
self.work = None
self.place = None
def __init__(self, verse:str,
readings:List[Reading] = list()):
self.text = verse
if readings = None:
pass
else:
self.readings = readings
def set_author(author:str):
self.author = author
def set_work(work:str):
self.work = work
def set_place(place:str):
self.place = place
class Reading:
self.tokens = list()
def __init__(self, tokens:List[Token]):
self.tokens = tokens
class Token:
def __init__(self, token:str, span:List[int],
syllables:List[Syllable]=list):
if len(token) != span[1]-span[0]:
raise ValueError('Token length does not match token span.')
else:
self.text = token
self.span = span
self.syllables = syllables
class Syllable:
def __init__(self, syllable:str,
span:List[int], idx:int,
syllable_length:int, vowel_length:int,
phenomena:dict=dict()):
if len(syllable) != span[1]-span[0]:
raise ValueError('Syllable length does not match syllable span.')
else:
self.text = syllable
self.span = span
self.id = idx
self.syllable_length = syllable_length
self.vowel_length = vowel_length
self.phenomena = phenomena
class Phenomenon:
def __init__(self, name:str, caused_by=False, overruled_by=False):
self.name = name
self.caused_by = caused_by
self.overruled_by = overruled_by
class PositionalLengthening(Phenomenon):
def __init__(self, chars:str):
Phenomenon.__init__(self, 'positional lengthening')
self.chars = chars
class IambicShortening(Phenomenon):
def __init__(self, typus:str):
Phenomenon.__init__(self, 'iambic shortening')
self.typus = typus
class S_Elision(Phenomenon):
def __init__(self):
Phenomenon.__init__(self, 's-elision')
omitted = 's'
class VerseEnd(Phenomenon):
def __init__(self):
Phenomenon.__init__(self,'verse end')
class MultisyllablePhenomenon(Phenomenon):
def __init__(self, name:str, beginning:int, end:int):
Phenomenon.__init__(self, name)
self.beginning = beginning
self.end = end
class Apheresis(MultisyllablePhenomenon):
def __init__(self,beginning,end):
MultisyllablePhenomenon.__init__(self, 'apheresis', beginning, end)