Both examples contain the word "have", but in the first example it was unstressed, while in the latter example it's stressed. Why? Beats me. It's just what happens in my head when I read it. Sadly, that's not very useful information for a computer. It turns out that the problem of teaching a computer to find the right scansion (marking the stressed and unstressed syllables) is quite a complex one. I found a Python library called pronouncing that can help determine the stressed and unstressed syllables of a single word. For example:

import pronouncing pronounciation = pronouncing.phones_for_word('have') pronouncing.stresses(pronounciation[0]) > 1

import pronouncing pronounciation = pronouncing.phones_for_word('another') pronouncing.stresses(pronounciation[0]) > 010

where 1 denotes a stressed syllable, and 0 denotes an unstressed syllable. For "have", it gives us a single stressed syllable, which as we saw in the example may or may not be correct based on the context. For "another" it returns 010 , which is in line with the scansion of our second example. I think this is correct regardless of context; try to pronounce "another" like "ANother" or "anothER" and you'll understand why.

So we are definitely not going to get a perfect scansion for each poem by simply using this pronouncing library. However, I came up with a method to use it to at least get the poem's primary meter:

For each line, determine the scansion by determining the scansion for each word. This will give us a string of 0's and 1's.

Divide the lines of the poem into groups by the amounts of syllables per line. (So for example, lines with 9 syllables are grouped together)

Try to find the closest match for each line in a set of known meters, also represented as 0's and 1's.

Per group, find the most found known meter.

Now we have a set of meters that together make up the meter of the poem.

There are a few more steps in this process to make it work. In the previous notebook, we saw that sprog quite often splits a line over two or even more lines. For example;