Skip to main content
Glama

Comparison of corpora

compare_texts
Read-onlyIdempotent

Compares two corpora of Spanish texts across 210 style features to reveal where they differ most, supporting authorship attribution and genre, translation or human-vs-model comparison.

Instructions

Compare two corpora of texts by the features of style and find where they differ most.

Use it for authorship attribution and for comparing genres, translations, texts by a person and by a model. The texts are cut in order into windows of exactly window words (whole_texts - the whole texts), 210 features of esTS are computed for every window, and the distributions of a feature in the corpora A and B are compared. The rest of a text shorter than a window and a text shorter than a window are left out: the response warns about such texts and about losing more than 10% of the words of a corpus on the rests. The comparison needs two windows at least in each corpus. The syntactic parse takes most of the time: two corpora of 250 thousand characters each are compared in about 6 seconds, of 500 thousand - in about 12. Pass the texts from files through a_paths and b_paths.

Features by prefix: basic_ - shares of long, complex, simple, mono- and polysyllabic words, of letters, spaces and marks, letters and syllables per word; readability_ - the readability formulas and the consensus grade; diversity_ - measures of lexical diversity; morph_ - shares of the parts of speech and of the features of one value among all the words (morph_pos_NOUN, morph_polarity_Neg) and of the values of the other features among the words that carry them (morph_mood_Sub, morph_tense_Imp), shares of the infinitive, gerund, participle, clitics, ser, adverbs in -mente and diminutives (morph_p_enclitics); sents_ - the mean length of a sentence in words, its standard deviation, coefficient of variation and the autocorrelation of adjacent lengths; punct_ - the marks by type per 1000 words and the share of the inverted ¿ and ¡ among the question and exclamation marks (punct_inverted_share); cohesion_ - the cohesion statistics: repetitions between sentences, pronouns, givenness, repetition of tense and mood, connectors per 1000 words; syntax_ - the statistics of the group syntax: dependency lengths, tree shape, clauses and the indices of L2SCA, chains, participial and gerund clauses, the passive and se, word order, similarity of adjacent sentences.

The result has "window" - the size of a window (null - the whole texts), "n_windows" and "n_texts" - the number of windows and texts in A and B, and "features" - the features by decreasing absolute Cliff's delta, with equal delta by the relative difference of the medians: the means over the windows "mean_a" and "mean_b", the difference of the medians A - B "median_diff" with its 95% bootstrap interval "ci_low" - "ci_high", Cliff's delta "cliff_delta" (from -1 to 1: the share of the pairs of windows where A is greater minus the share where it is smaller; in absolute value from 0.147 - a small, from 0.33 - a medium, from 0.474 - a large effect, Romano et al. 2006) and the p-value of the Mann-Whitney U test with Holm's correction for the number of features "p_holm". The windows of one text are not independent: p_holm takes them as independent and is too small when a corpus has few texts, while the bootstrap interval takes whole texts and is undefined with one text in a corpus. The key "warnings" lists the warnings: a corpus not in Spanish, texts of the corpora of different length with whole_texts, texts or their rests left out of the comparison, one text in a corpus, no significant difference.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "compare_texts"
  }
}

Input Schema

NameRequiredDescriptionDefault
aNoTexts of the first corpus (A)
bNoTexts of the second corpus (B)
top_nNoNumber of the features with the largest difference
windowNoSize of a window in words; not set - at most 1000 and such that the shortest text splits into two windows at least, but at least 100
a_pathsNoAbsolute paths to files with the texts of corpus A or links ests://datasets/... from find_texts, with a or instead of it; a query link gives all its texts as separate texts of the corpus
b_pathsNoAbsolute paths to files with the texts of corpus B or links ests://datasets/... from find_texts, with b or instead of it; a query link gives all its texts as separate texts of the corpus
whole_textsNoCompare the whole texts, without windows; needs two texts at least in each corpus

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.5/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations only declare readOnly/idempotent/closed-world, and the description goes far beyond them: it discloses windowing mechanics, that short texts and rests are dropped, that warnings are raised when >10% of words are lost, the two-window minimum per corpus, and runtime scaling (~6s per 250k characters). It even documents statistical pitfalls: p_holm is anti-conservative with few texts and the bootstrap CI is undefined for a single-text corpus. That is unusually rich behavioral disclosure for a read-only tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Purpose is front-loaded, but the body is a dense unbroken block of ~500 words including a long catalogue of feature prefixes and a full walkthrough of result keys that the output schema already defines. Some sentences are garbled ('The rest of a text shorter than a window and a text shorter than a window are left out'), which costs readability. The feature-prefix inventory has interpretive value, but the retrieval/result repetition does not earn its space.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 7-parameter statistical tool with rich output, nothing an agent needs to call it correctly is missing: input sources, window derivation, minimum corpus size, failure/warning conditions, runtime, and interpretation of the effect-size thresholds are all present.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds meaning beyond the schema: window=null means whole texts, whole_texts requires at least two texts per corpus, and a_paths/b_paths accept ests:// links from find_texts where a query link expands into all its texts as separate texts. top_n is only implicitly explained via 'features by decreasing absolute Cliff's delta', which the schema already covers.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb+resource+scope: 'Compare two corpora of texts by the features of style and find where they differ most.' This clearly separates it from siblings like analyze_text or keyness, which work on single texts or word frequencies rather than cross-corpus stylistic distributions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives concrete use cases (authorship attribution, genres, translations, human-vs-model texts) and states where to supply input ('Pass the texts from files through a_paths and b_paths'). It also implies the alternative mode (whole_texts vs. windowing) and its precondition. It does not explicitly say when to prefer a sibling tool (e.g., analyze_text for a single text), so usage guidance is contextual rather than fully contrastive.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.