# Text Alignment in the Service of Text Reuse Detection
## 1 Introduction  
Text reuse detection may be pivotal in studying the transmission and evolution of ancient texts and examining their intertextual relations. The nature of the affinity between intertextually related texts differs from case to case. It may be a short quotation of exact phrases (as in citations of biblical texts), an extended reproduction of a text with minor changes (as in the transmission of works in manuscripts), or a loose rephrasing of content (as in two different performances of a folk story, two synoptic gospels, or parallel rabbbinic traditions). Computational solutions for text reuse detection have attracted significant recent research interest [1], as they address the challenges of a labor-intensive manual process. Automating this process involves three steps: first, implementing information retrieval methods to select pairs of documents with a high probability of local text reuse; second, applying a text alignment method to each pair, where each word in the first text is matched with its equivalent in the second; and third, using statistical methods on the aligned pairs to infer the strength, directionality, and nature of their affinity [2]. The second step, text alignment, presents unique challenges. Reused texts may appear significantly different, as words may be replaced with synonyms or abbreviations. Sometimes, multiple words are condensed into a single term, as seen with acronyms or gematria. Additionally, practical challenges arise from the linguistic characteristics of our corpus (Hebrew/Aramaic). Semitic languages are orthographically and morphologically complex [3]. For instance, during the medieval and late antiquity periods, there was no standardized orthography [4], as reflected in the varied usage of Matres Lectionis. Adding to the complexity is the nature of Semitic morphology, which allows multi-word expressions to be compressed into a single word. For example, the English phrase 'I taught him' can appear in Hebrew as a three-word sequence: ani limmadti oto. However, due to Hebrew's morphological structure, the same meaning can be conveyed using a single word: limmadtihu. A practical text alignment method must account for this morphological richness and variability, ensuring that alignments accurately capture both word-to-word correspondences and multi-word-to-single-word mappings. One might consider the case illustrated in Figure 1, which highlights the intricacy of text collation. The medieval manuscripts Bodleian Opp. Add. fol. 3 (hereafter referred to as Ox3) and British Library Add. 27,169 (denoted as Lon) serve as two textual witnesses of Leviticus Rabba, a rabbitinic homiletic work from late antiquity. The illustration presents a color-coordinated alignment, delineating various categories of textual divergences found in these manuscripts: acronyms (highlighted in green), abbreviations (indicated in cyan), gematria (depicted in brown), and word transpositions (evidenced by the interchange of words bearing identical coloration). [PERSON] et al. [5] introduce a state-of-the-art Hebrew/Aramaic textual alignment methodology. Their approach employs the Needleman-Wunsch global alignment algorithm (hereafter NW) [6], complemented by a novel distance metric designed to quantify word disparity. This metric is derived from a linear combination of word2 vec embeddings [7] and the traditional edit distance [8]. However, due to its strict adherence to linearity, the algorithm occasionally fails to align transposed words. Additionally, the proposed distance metric has limited effectiveness in handling abbreviations and acronyms. In this study, we propose refining the approach introduced by [PERSON] et al. [5] through three key modifications. First, we replaced the Needleman-Wunsch (NW) algorithm with the Smith-Waterman (SW) algorithm [9] to facilitate local alignment, thereby improving the matching of full compositions with their constituent fragments.