# A Hierarchical Orthographic Similarity Measure for Interconnected Texts Represented by Graphs
## 4 Representing a Textual Corpus as a Graph
### Graph Representation of a Textual Corpus
```
0: A fuzzy graph \(\tilde{G}\big{(}N,\tilde{E},\rho,\lambda_{N},\lambda_{E},\sigma\big{)}\) representing the texts in a corpus
0: The fuzzy graph \(\tilde{G}\) with the calculated similarity scores
1:for\(i\gets 0,|L|-1\)do
2: Determine parameters \(c_{I,D},c_{R}\) and \(c_{T}\) or \(c_{I,D},c_{T},r\) and \(t\)
3:for all\((n_{1},n_{2})\in N_{l_{i}}^{2}\)do
4:if\(i=0\)then
5:\(s=sim^{s}(c(n_{1},\text{text{text}}),\sigma(n_{2},\text{text}))\)
6:else
7:\(s=sim^{n}(n_{1},n_{2})\)
8:endif
9: Create edge \(\rho(e)\leftarrow(n_{1},n_{2})\)
10:\(\lambda_{E}(e)\leftarrow\texttt{SIMILAR\_TO}\)
11:\(\tilde{E}\leftarrow\tilde{E}\cup\{e\}\)
12:\(\mu_{E}(e)\gets s\)
13:endfor
14:endfor
15:return\(\tilde{G}\big{(}N,\tilde{E},\rho,\lambda_{N},\lambda_{E},\sigma\big{)}\)
```

**Algorithm 3** Similarity calculation in the graph-based text representation. In this algorithm, we hierarchically compute the pairwise similarity for all node pairs sharing a specific label. For the lowest-level text elements, the string-based similarity proposed in Section 5.1 is used. The similarities between all other text elements sharing the same label are determined by the node-based similarity, as described in Section 5.2. Note that the parameters \(c_{I,D},c_{R}\) and \(c_{T}\) for the string-based similarity and parameters \(c_{I,D},c_{T},r\) and \(t\) for the node-based similarity may vary at each level within the hierarchy but remain fixed throughout the calculations within a specific level. As a result, each parameter at every level of the hierarchical calculation can be fine-tuned, either through expert knowledge or empirical analysis, to suit the specifics of a given corpus. Once the similarity between two nodes is determined, a new edge is created to indicate the similarity between those two elements. As the similarity measure between two nodes is symmetric, only a single undirected edge is created between the nodes. Upon completion of the procedure, the graph-based text representation is returned, including the similarity scores between all elements within the same discourse unit. As an illustration, the result of the hierarchical computation between two texts is provided in Example 4. **Example 4**. : _In Figure 5, we revisit our textual graph from Example 1 and display the similarity scores between all text elements that are required to compute the similarity between both full texts. For the calculation of this example, all parameters \(c_{I,D},c_{R},c_{T},t\) and \(r\) are equal to \(1\) for every level._The time required to calculate the the similarities between all nodes on every level of the graph is equal to the sum of the calculation time at every level of the hierarchy. In Sections 5.1 and 5.2, we concluded that the time required for every level is, where is equal to the amount of nodes at a specific level and. Since the time complexity is dominated by the largest term, the overall time complexity is equal to. The space complexity of the complete algorithm, on the other hand, is equal to the largest space requirement among the different hierarchical levels. As a result, the space complexity is also equal to. After the initial computation of the similarity values between text elements in the graph, there remains the possibility of incorporating additional text documents into this graph. First, the new texts should be included into the graph as described in Section 4.2. Then, only the additional similarity values between the newly added nodes and all existing nodes at the same hierarchical level should be computed in the same manner as outlined in Algorithm 3. ## 6 Experiments

In this section, we demonstrate and motivate the relevance of the proposed technique by its use as a research tool for the analysis of ancient texts and compare it to another state-of-the-art soft measure. In Section 6.1, we illustrate the characteristics of Byzantine book epigrams [50], the corpus used as a dataset in the following experiments.