Latin Metrical Scansion Net Trained on The Aeneid

Contributed by: Laney Moy

Annotate Latin text with diacritical marks

Released in 2019, this net is based on a simple sequence-to-sequence architecture that successfully determines the metrical pattern of lines of Latin poetry in dactylic hexameter. The net takes a plain line of poetry as input and outputs the likelihood that each character falls into one of three categories: a long vowel; a short vowel; or an ignored vowel, consonant, or punctuation mark.

Number of layers: 5 | Parameter count: 12,063 | Trained size: 102 KB |

Training Set Information

Performance

Examples

Resource retrieval

Get the pre-trained net:

In[1]:=
NetModel["Latin Metrical Scansion Net Trained on The Aeneid"]
Out[1]=

Evaluation function

Obtain the evaluation function for this model:

In[2]:=
calcOutput[probs_] := Table[
   If[Max[x] == x[[1]], 1, If[Max[x] == x[[2]], 2, 3]], {x, probs}
   ];
markings = {Style["-", Bold], Style["u", Smaller]};
overscripts[line_, probs_] := Table[If[probs[[x]] == 3, StringPart[line, x], Overscript[StringPart[line, x], markings[[probs[[x]]]]]], {x, Range[Length[probs]]}];
colors[line_, probs_] := Block[{newLine},
  newLine = Table[If [probs[[x]] == 3, line[[x]], Style[line[[x]], If[probs[[x]] == 1, Blue, Red]]], {x, Range[Length[probs]]}];
  Style[Row[newLine], Large]
  ]
In[3]:=
scan[line_] := With[{out = calcOutput[
     NetModel["Latin Metrical Scansion Net Trained on The Aeneid"][
      line]]},
  colors[overscripts[line, out], out]
  ]

Basic usage

Obtain a line of Latin text:

In[4]:=
line = RandomChoice[
  TextCases[ResourceData["The Aeneid - Latin"], "Line"]]
Out[4]=

Obtain the probabilities that each character falls into one of three categories: a long vowel; a short vowel; or an ignored vowel, consonant, or punctuation mark.

In[5]:=
NetModel["Latin Metrical Scansion Net Trained on The Aeneid"][line]
Out[5]=

Display the color-coded line with metrical markings:

In[6]:=
scan[line]
Out[6]=

Net information

Inspect the number of parameters of all arrays in the net:

In[7]:=
NetInformation[
 NetModel[
  "Latin Metrical Scansion Net Trained on The Aeneid"], "ArraysElementCounts"]
Out[7]=

Obtain the total number of parameters:

In[8]:=
NetInformation[
 NetModel[
  "Latin Metrical Scansion Net Trained on The Aeneid"], "ArraysTotalElementCount"]
Out[8]=

Obtain the layer type counts:

In[9]:=
NetInformation[
 NetModel[
  "Latin Metrical Scansion Net Trained on The Aeneid"], "LayerTypeCounts"]
Out[9]=

Display the summary graphic:

In[10]:=
NetInformation[
 NetModel[
  "Latin Metrical Scansion Net Trained on The Aeneid"], "SummaryGraphic"]
Out[10]=

Export to MXNet

Export the net into a format that can be opened in MXNet:

In[11]:=
jsonPath = Export[FileNameJoin[{$TemporaryDirectory, "net.json"}], NetModel["Latin Metrical Scansion Net Trained on The Aeneid"], "MXNet"]
Out[11]=

Export also creates a net.params file containing parameters:

In[12]:=
paramPath = FileNameJoin[{DirectoryName[jsonPath], "net.params"}]
Out[12]=

Get the size of the parameter file:

In[13]:=
FileByteCount[paramPath]
Out[13]=

The size is similar to the byte count of the resource object:

In[14]:=
NetModel["Latin Metrical Scansion Net Trained on The Aeneid", "ByteCount"]
Out[14]=

Represent the MXNet net as a graph:

In[15]:=
Import[jsonPath, {"MXNet", "NodeGraphPlot"}]
Out[15]=

Requirements

Wolfram Language 12.0 (April 2019) or above

Resource History

Reference