How the tools work
The methods behind the tools of the PHI Latin Texts server: what each tool counts, in which order, and where it stops. The numbers on this page come from the server's code, so they are the ones it uses now.
Tools: the data under all tools · search_corpus · find_words and check_words · find_distinctive_words · get_word_profile · get_style_profile · compare_style · find_shared_phrases · the lookup tools · sources
The data under all tools
Every tool reads the same texts: the PHI Latin corpus, in the spelling of each printed edition.
- Folded spelling. Before it compares letters, the server writes each word in lowercase, with u for v and i for j. Punctuation, accents and editorial brackets do not count. Iuuenes, juvenes and [iu]venes are one form.
- Forms and lemmas. A form is a word as it stands in the text (tulit). A lemma is the dictionary word it belongs to (fero). The list of lemmas and of the forms that can belong to each comes from the morphological analyzer Collatinus. A lemma is kept only if it has a dictionary gloss, from Whitaker's Words and Lewis & Short.
- No analysis of each word in its sentence. The server does not parse the text. It knows the analyses a form can have, out of context (malis: dative or ablative plural of malus or malum, or a form of malo), but it never decides which one a given occurrence is. So it cannot find, for example, every ablative absolute or every subjunctive, and a count by lemma is an estimate (see below). A form gets the same treatment at every place it occurs.
- Words that are not the author's Latin are left out of the word and style counts: Greek, titles, speakers' names in drama, scene headings and page marks.
Forms that belong to two words
Many forms belong to more than one lemma. malis can be from malus, malum or malo. The server does not read the sentence. It gives each form a weight for each of its lemmas: the share of that form's occurrences, over the whole corpus, that it takes to be that lemma's.
The weights come from a statistical model fitted once to the whole corpus (expectation–maximization, 4 rounds). It starts from:
- how often each lemma occurs in the LASLA corpus, which was lemmatized by hand;
- for a lemma that LASLA lacks, the length of its article in Lewis & Short;
- the forms that belong to one lemma only, which are certain;
- how often each kind of ending (case, tense) occurs;
- how often a lemma is written with a capital inside a line, which marks a name.
For the hardest forms the model picks the right word about 7 times in 10. A count that includes shared forms is an estimate, and the answers mark it so.
Two lemmas spelled the same are one entry. effero “carry out” (efferre) and effero “make wild” (efferare) share one entry and one gloss, so a check of elata shows the gloss “make wild” beside the likely lemma elatus. cum is not split into the preposition and the conjunction.
search_corpus
Finds where a string of letters, or every form of a lemma, occurs, and counts the matches by author and work.
Letter search (query)
- The query is folded like the text. Spaces split it into words; a space matches any run of spaces and punctuation, also across a line end.
# at the start or end ties the match to the start or end of a word. Without it, amor also matches clamor.
. is one unknown letter. A query may have at most 8 of them, and at least 2 known letters.
- The server scans the folded text once, start to end. A match never runs from one work into the next.
- It stops after 50,000 matches. The answer then says it stopped, and the counts by author cover only the matches found before that point. They lean toward the early authors, because the corpus is in order of author number.
Lemma search (lemma)
- The server takes every form that the lemma can have.
- It drops a form whose weight for this lemma is under 10%: that form is mostly another word, and its lines would bury the lemma's own. The answer lists the dropped forms.
- It finds every occurrence of each kept form. There is no cap.
- The estimate is the sum, over the forms, of the count times the weight. Forms with a weight under 90% are named in a note as shared with another word.
Two words together (near, near_lemma)
The server finds both terms, then keeps each match of the first that has a match of the second within within lines (default 1, at most 10), in the same work. The same letters at the same place do not count as the second word.
Which lines come back
- Matches come in the order of the corpus, not by relevance. A page has 20 lines unless you ask for more, and at most 100.
spread=true gives a sample in place of the first page. The server takes one match from each author in turn, the authors with most matches first, and spaces each author's picks evenly through that author's matches.
- The search index and the reading text number lines in different ways. The server finds each match again by its letters in the reading text, near the place the index gives. A match it cannot find again is dropped, not guessed.
Example (2026-10-21): /api/v1/search?lemma=lugeo&limit=0 gives 423 matches, about 419 by weight. lugere 71, luget 31, luxit 20 (weight 0.95). luctus and luctu are dropped: almost all of them are the noun luctus. The letters #lug give 524 matches, because they also find lugubris and other words.
find_words and check_words
find_words
- The server reads the English gloss of every lemma.
- It keeps a lemma if the English word or phrase stands in the gloss as whole words, in order. A final -s in the gloss counts: “griefs” matches “grief”.
- Lemmas whose main gloss matches come first. Lemmas that match only in a secondary sense come after them.
- Within each group, the commonest lemma comes first, by its estimated count in the corpus.
It returns 25 lemmas unless you ask for more, and at most 60. A gloss lists every sense of a word, so some lemmas will not fit the meaning you want.
Example (2026-10-21): /api/v1/words?english=grief finds 32 lemmas: dolor (3,919), doleo (932), luctus (727), desiderium (680), scindo (374, “tear in rage/grief/despair”) …
check_words
For each word (at most 40 in one call), the server says whether it is a lemma, with its gloss and estimated count, and whether it is a form in the texts, with its count and the lemmas it can belong to, each with its weight. A word that is neither gets lemmas that begin with the same letters.
Example (2026-10-21): elata occurs 54 times: elatus 0.81, elate 0.12, effero 0.06. lugent occurs 15 times, all lugeo.
find_distinctive_words
Finds the words of an author, or of one work, that the other texts seldom use.
- Count the target. Each form in the target adds its weight to each of its lemmas. A form with no lemma is counted as a form, in a separate list.
- Choose the comparison texts.
all (default): every other text. earlier: authors whose dates fall before the target's. same_genre: texts of the target's genre. The target itself is left out. If the target is one work, the author's other works stay in the comparison.
- Count the comparison texts the same way, author by author. An author uses a lemma if the estimated count is 0.5 or more.
- Join lemmas that come from the same forms. If two lemmas get their count in the target from the same forms, they are one row. The Lucan example below has bellum / bellus: every form of bellus in Lucan is also a form of bellum.
- Sort.
rare (default): fewest other authors first, then fewest uses in the comparison texts, then most uses in the target. keyness: Dunning's log-likelihood (G²), highest first. It compares the word's rate in the target with its rate in the comparison texts, and it is high when the target uses the word much more often than its size predicts. Only words used 2 times or more, and more often than expected, enter this list.
- Set names apart. If more than half of a word's uses in the target begin with a capital inside a sentence, the word goes in a list of names (at most 10).
Each row gives the count in the target, the forms used, the uses elsewhere, the number of other authors, the earliest 3 of them with dates, and 2 references in the target. It returns 30 rows unless you ask for more, and at most 100.
Dunning's log-likelihood (G²)
G² asks: if the target and the comparison texts used the word at the same rate, how surprising would the counts be? Let a be the uses of the word in the target and c the words in the target; b and d are the same for the comparison texts.
- The expected uses at one shared rate are E1 = c(a + b) / (c + d) in the target and E2 = d(a + b) / (c + d) in the comparison texts.
- G² = 2 [ a ln(a / E1) + b ln(b / E2) ]. A count of 0 adds nothing.
- The server gives G² a minus sign when the target uses the word less than the comparison texts. Only positive values enter the list.
This is the short form used in corpus linguistics (Rayson and Garside 2000). Dunning proposed it because the more familiar chi-square test overstates the importance of rare words, and most words in a corpus are rare.
How to read the number:
- G² is 0 when the two rates are the same, and it grows as they part. As a rough guide, G² over 3.84 would happen by chance less than 1 time in 20, over 6.63 less than 1 time in 100, and over 10.83 less than 1 time in 1,000.
- Take that guide loosely. Words are not scattered at random: a word that a passage is about comes again and again, so a large G² can come from one episode.
- G² grows with the size of the texts. Compare values within one list, not between a short work and a long one.
- G² measures how sure the difference is, not how large it is. A common word used a little more often can outrank a rare word used ten times as often.
The corpus has few texts after AD 200. When less than 20% of the comparison words are late, the answer says so: a word of late Latin can look rare only because few late texts are in the corpus.
Example (2026-10-21), sort=rare: in Maximianus (4,220 words, compared with 368 authors and 8.1 million words), scabidus and insuperatus occur in no other author. sort=keyness: Lucan's first words are fatum (G² 987), unda (537), bellum / bellus (492), aequor (443).
get_word_profile
Gives the use of one lemma across authors, eras and genres.
- The server takes every occurrence of every form of the lemma. Each one adds the form's weight to the totals of its author, era and genre. The part that comes from forms of this lemma alone is given as the certain count.
- A rate is uses per million words of that author, era or genre.
- Eras: Archaic (to c. 90 BC), Late Republican (to 43 BC), Augustan (to AD 14), Julio-Claudian (to AD 68), Flavian (to AD 96), Trajanic–Antonine (to c. AD 200), Late, and Undated. An author belongs to one era.
- The list of highest rates has only authors with 10,000 words or more. A rate from a fragment of 300 words is noise. Smaller authors are named with their counts and no rate.
- The earliest and latest users are the 3 dated authors at each end with an estimated count of 0.5 or more.
The answer also lists the lemma's forms with their counts and weights, and the other lemmas that share its forms.
Example (2026-10-21): senectus occurs about 912 times (716 certain) in 76 authors. The rate is highest in Philosophy (338 per million) and, among authors, in Juvenal (544).
get_style_profile
Measures habits of style in an author or a work, and compares each with other works.
The measures
- 46 function words or groups, per 1,000 words: et, atque/ac, sed, autem, enim, igitur, non, cum, ut/uti, quod, in, ad …, and the forms of hic, ille, iste, ipse, is, and est/sunt. These are counted as forms, not lemmas.
- Enclitic -que, per 1,000 words. A word counts if it ends in -que and the rest is a word of the corpus. atque, quoque, itaque, quisque, -cumque and similar words do not count.
- Word length: mean letters a word.
- Sentence length: words between the full stops, question marks and exclamation marks of the edition. A run of dots counts as one. Abbreviations add stops in prose and commentaries.
- Type–token ratio, as a moving average (MATTR): the share of different forms in each window of 500 words, averaged over all windows. A text shorter than the window has no value.
The moving-average type–token ratio (MATTR)
The plain type–token ratio is the number of different forms divided by the number of words. It falls as a text gets longer, because the common words come again and again and each new page brings fewer new words. A long work then looks poorer in words than a short one, and two texts of different length cannot be compared. MATTR removes this effect.
- The server takes the first 500 words and divides the number of different forms in them by 500.
- It moves the window on by one word, and divides again. A text of n words has n − 500 + 1 windows.
- MATTR is the mean over all the windows.
Each window has the same length, so values from a short work and a long one can be compared.
- A type is a form, not a lemma. amo, amat and amauit are three types. Latin has many endings, so its values are higher than those of English. Compare Latin values only with Latin values.
- It measures variety over about a page, not the size of an author's whole vocabulary. Formulae, refrains, lists and legal language repeat words and lower it. Narrative that moves from subject to subject raises it.
- A window does not cross a gap in the text. When the corpus holds a work in parts, each part has its own windows. A work's value is the mean of its parts, weighted by their length, and an author's value is the mean of the works, weighted the same way.
Example (2026-10-22): the mean of 305 works is 0.69. Tacitus' Annales has 0.82 (z +1.5): in 500 words, about 410 different forms. Lucretius has 0.71 (z +0.1).
The comparison
- The comparison works are all works of 3,000 words or more, or with
compare_to=same_genre only those of the target's genre. There must be 5 or more.
- An author target leaves all that author's works out of the comparison. A work target leaves out only that work.
- For each measure, the server takes the mean and standard deviation over the comparison works and gives the target's z-score: how many standard deviations it lies from the mean.
- The answer names the 8 measures furthest from the mean.
Genre, verse or prose, and the editor's punctuation move these numbers as much as the author does. Compare like with like.
Example (2026-10-21): Sallust's Catilina against 25 works of history: sed 9.4 per 1,000 words, mean 3.8 (z +2.9); atque/ac 16.3, mean 8.1 (z +2.0); et 11.5, mean 27.2 (z −1.9).
compare_style
Measures how near an author or a work is in style to other authors, with Burrows' Delta.
- The server takes the most frequent forms of the whole corpus: 150 unless you ask for another number, from 30 to 300.
- For each author, it computes the rate of each form: uses divided by the author's words.
- The target is taken out of its own author first. A work of Sallust is compared with the rest of Sallust, not with all of Sallust.
- The population is every author with 5,000 words or more. For each form, the server takes the mean and standard deviation of the rate over the population, and turns each rate into a z-score.
- Delta between the target and an author is the mean, over the forms, of the absolute difference between their z-scores. Smaller is nearer.
- With candidates (at most 20), the server ranks them. Without, it lists the 12 nearest authors in the population. The answer also gives the median Delta from the target to the whole population, as a scale.
Delta is not reliable for a target under about 1,500 to 2,000 words, and the answer says so. A candidate under 5,000 words gets a note. Genre and verse or prose move Delta as much as the author: a poem is near other poems.
Burrows' Delta
Authors differ most in the common words they use without thought: et, in, non, est, -que. These words do not depend much on the subject, and an author's rates of them stay much the same from work to work. Burrows (2002) made a distance from them.
- Why z-scores. et has a rate of about 35 per 1,000 words, quin less than 1. Raw differences would let et decide everything. A z-score asks how unusual an author's rate of a word is, in standard deviations from the mean of all authors. Each word then has the same weight.
- The formula. Δ = (1/n) Σ |ztarget(w) − zauthor(w)|, over the n words w. It is the mean gap between the two profiles. 0 is the same profile.
- How to read it. There is no fixed level that means “same author”. Read a value against the median that the answer gives, which is the distance from the target to a typical author. A value far under the median is near.
- How many words. With few words, Delta uses function words only. With more, it adds content words, which bring in subject and genre.
- What it can show. Delta ranks the candidates you give. It does not prove who wrote a text, and if the true author is not among the candidates, it still names the nearest one. Burrows made it to choose among a closed set of candidates.
Example (2026-10-21): Sallust's Catilina (10,673 words), against 81 authors, median 1.11: the rest of Sallust 0.51, Livy 0.77, Tacitus 0.86, Caesar 0.87, Cicero 0.96.
find_shared_phrases
Finds the phrases that two texts share, the rarest in the corpus first.
- Make the phrases. Every run of
length words in a row (2 to 6, default 3), in the folded spelling, within one work. A phrase can run across a line end and across punctuation.
- Drop common phrases. A phrase made only of the 100 most frequent forms of the corpus (et, in, non, est …) is dropped. One less common word keeps it.
- Find the shared ones. The server lists the phrases of the smaller text, then looks for each in the larger text. The smaller text may have at most 3,000,000 words; for two larger texts, name a work.
- Count each one in the corpus. The server takes the 2,000 shared phrases with the rarest words. For each, it follows the occurrences of its rarest word (at most 20,000) and counts where the whole phrase occurs: in the corpus, in how many other authors, and in how many grammarians and commentators. These quote other authors, so they are counted apart.
- Sort. Fewest other authors first, then fewest occurrences in the corpus, then most uses in the two texts.
- Add references: the first place of the phrase in each text.
It returns 30 phrases unless you ask for more, and at most 100. The forms must match exactly: proiecit in undas does not match proiecit in undis. A shared phrase is not proof of borrowing; read both lines.
Example (2026-10-21): the Aeneid and Lucan share 63 phrases of 3 words. First: hoc solamen erat (Aen. 10.859, BC 7.181), proiecit in undas (Aen. 5.859, BC 6.401), quo fata trahunt (Aen. 5.709, BC 2.287). No other author has them.
The lookup tools
- get_passage reads a reference such as
Verg. Aen. 1.1-7, Virgil Aeneid 1 or 0690 003 1.1. It does not split the reference by a fixed rule: it tries each way to split it into author, work and place, and keeps the one the corpus has. It gives 200 lines unless you ask for more, and at most 1,000.
- list_authors, get_author and get_work read the PHI tables of authors and works, and the divisions of each work.
Sources
Published methods
- Dunning, T. 1993. “Accurate Methods for the Statistics of Surprise and Coincidence.” Computational Linguistics 19 (1): 61–74.
- Rayson, P., and R. Garside. 2000. “Comparing Corpora Using Frequency Profiling.” In Proceedings of the Workshop on Comparing Corpora, 1–6. Hong Kong: Association for Computational Linguistics.
- Burrows, J. 2002. “‘Delta’: a Measure of Stylistic Difference and a Guide to Likely Authorship.” Literary and Linguistic Computing 17 (3): 267–287.
- Covington, M. A., and J. D. McFall. 2010. “Cutting the Gordian Knot: The Moving-Average Type–Token Ratio (MATTR).” Journal of Quantitative Linguistics 17 (2): 94–100.
Questions about a method: [email protected].