Alliteration¶
poetry_analysis.alliteration
¶
The definition of alliteration that we use here is the repetition of word-initial consonants or consonant clusters.
count_alliteration(text)
¶
Count the number of times the same word-initial letter occurs in a text.
Examples:
>>> text = "Sirius som seer"
>>> count_alliteration(text)
{'s': 3}
Source code in src/poetry_analysis/alliteration.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
extract_alliteration(text)
¶
Extract words that start with the same letter from a text.
NB! This function is case-insensitive and compares e.g. S to s as the same letter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
list
|
A list of strings, where each string is a line of text. |
required |
Examples:
>>> text = ['Stjerneklare Septembernat Sees Sirius', 'Sydhimlens smukkeste Stjerne']
>>> extract_alliteration(text)
[{'line': 0, 'symbol': 's', 'count': 4, 'words': ['Stjerneklare', 'Septembernat', 'Sees', 'Sirius']}, {'line': 1, 'symbol': 's', 'count': 3, 'words': ['Sydhimlens', 'smukkeste', 'Stjerne']}]
Source code in src/poetry_analysis/alliteration.py
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 | |
find_line_alliterations(text, allowed_intervening_words=None)
¶
Find alliterations on a line.
Source code in src/poetry_analysis/alliteration.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
group_alliterating_indices(indices, all_words_in_line, stop_words)
¶
Groups indices of words that alliterate, allowing specified stop_words in between.
Source code in src/poetry_analysis/alliteration.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |