Glebova, Daria
Higher School of Economics, Russian Federation
kashalotdar@gmail.com
Kostyanitsyna, Anastasiya
Higher School of Economics, Russian Federation
anastasiya.kost98@gmail.com
Glazunov, Evgenii
Higher School of Economics, Russian Federation
e.glznv@yandex.ru
Developed around epic poetry, the oral formulaic theory described the formula as a building block of oral composition that was strictly connected to meter (Parry 1930; Lord 1960). However, recently there have been several studies discussing formulas in prose traditional narratives (Lamb 2015; Sävborg 2018) and showing that in such prose corpora formulas are used without metrical conditions. This theoretic direction creates a ground for an automatic search for formulas in medieval prose texts. Such an experiment is the main goal of this project focused on formulas and meaningful repetitions in Old Norse-Icelandic sagas (corpus information see in Eiríkur Rögnvaldsson / Sigrún Helgadóttir 2011).
The main idea of the algorithm is the compilation of a list of ngrams, its further filtration, and application of NLP methods to determine repeating semantically significant word sequences. Formulas have at least two important features that are problematic for an automatic search:
Therefore, the entity filtering based on frequency is not applicable. Special heuristics were designed to gradually filter examples and combine contextual synonyms in groups. The algorithm consists of four main stages:
To begin with, the list of ngrams has to be compiled (4 to 8 words). To get only meaningful phrases, each ngram was tested on compliance with the following criteria: 1) Presence of a verb, 2) Syntactic integrity, 3) Part of speech (POS) significance of at least 90%. The phrasal syntactic integrity was validated based on the POS and word cases (i.e. there are no violations of agreement and government). The POS significance score was calculated according to the formula:

Significance - the significance of a POS (each POS was assigned a number reflecting its semantic significance in the process of phrase formation, see Appendix);
Frequency - frequency of a POS in an ngram;
nwords - number of words in an ngram.
Thus, the ngram was skipped if its score is less than 0.9 (the threshold was determined by a test sample analysis), if it does not have syntactic integrity and if it does not have a verb. As a result, a list of 663,775 phrases was compiled.
Then the ngrams should be grouped. The grouping consists of three stages: 1) the ngrams were normalised (e.g. adjectives and adverbs were omitted as modifiers may vary within the same structure or pronouns and proper nouns were transformed into POS and case tag, e.g. PrpNom, etc.); 2) resulting representations with the same word content but different word order were combined; 3) all phrases were grouped by their syntactic constituents, e.g. all sequences consisting of a verb, a pronoun in dative and a noun in nominative were grouped together.
As the ngram groups should be semantically similar, each syntactic group was clustered using the spectral clustering algorithm (von Luxburg 2007). This algorithm was adjusted for the current research purposes as a graph of phrases was created for each syntactic group where each two semantically similar nodes had a connection added. To find semantic similarity between the nodes, the following operation was designed: 1) each phrase was represented as a list of fastText vectors (Joulin et al. 2016); 2) the cosine similarities between words in the same position in construction were calculated; 3) the similarity scores for phrases were computed based on the average values of words they consist of. The resulting scores were used as weights for connections between graph nodes; the connection was added if the semantic similarity between the two phrases was more than 0.85.
As formulas in Old Icelandic sagas are usually used in similar situations (see Sävborg 2018: 58-59), the last step was to find clusters that occur in similar contexts. For this, a topic model for the whole corpus was built and each sentence received a vector of topic distribution in the surrounding fragment (5 sentences before and after). To evaluate the thematic similarity of phrases within the clusters special metrics were created: sparseness coefficient (how thematically sparse a certain cluster is) and cluster core (share of a strongly connected group of entries). To calculate sparseness coefficient community unfolding using greedy modularity maximization algorithm (Clauset et al. 2004) was performed on cluster graphs that were beforehand reduced by calculating median vectors of thematically similar ngram entries. The formula goes as follows:

Nbiggest - the biggest community size
Nnodes - cluster size
𝜎 - standard deviation of community sizes
To calculate the cluster core, outliers are omitted on each step and the average pairwise cosine similarity is computed until it reaches 0.9; the coefficient is the share of entries left.
Finally, 1270 word sequences were collected. As there is no ‘golden standard’, it is impossible to use accuracy or recall, so precision was chosen as an evaluation metric. We used random samples (with different parameters; 100 ngrams in each sample) evaluated manually by the expert.
| Filter | Precision | Confidence interval | |
|---|---|---|---|
| Lower bound | Upper bound | ||
| Exact repetitions | 12% | 5,6% | 18,4% |
| Sparseness coefficient <= 0.15 | 13% | 6,4% | 19,6% |
| Cluster core >= 0.9 | 18% | 10,5% | 25,5% |
Sparseness coefficient <= 0.15 & Cluster core >= 0.9 | 11% | 4,9% | 17,1% |
| All | 15% | 8,00% | 22,00% |
While the search gives good examples (e.g. variants for famous "X hét maður" (A man called X) or beginnings like "var það á einni nótt að/ það var á einni nótt þar sem…"), the precision shows low general results. In future the filtering algorithm could be improved and other semantic models could be used. However, although it is still work-in-progress, the presented algorithm can narrow down the list of all possible ngrams to several hundred that can be then evaluated manually.