Skip to content

Text statistics

analyze_text(text="", path=null, groups=["basic", "readability"], distributions=false, readability_preset="general", blank_lines=false, seseo=false, descriptions=true, per_text=[])

Measures a text with the statistics of esTS by groups: only the requested groups are computed, and each one becomes a key of the response. A statistic comes with its value, share or reading by a scale, if there is one, and with a description of what it computes. The warnings key tells when the values are unstable or meaningless for this text. Descriptions known from a previous call need not be requested again: descriptions=false gives a shorter response. For a query link the groups are computed over all its texts together, and per_text gives the chosen statistics for every text as a table with a summary over the corpus.

Errors - those common to the tools and:

  • the text has no words for the basic, diversity, morph, phon, cohesion, style or syntax group; the readability, lexical, verse and unadapted_readability groups of such a text are empty, and a warning says why;
  • an empty groups without per_text;
  • per_text without a query link in path, a statistic of per_text that is not «group.key» or that no text has (the distributions of the basic group need distributions=true).
{
  "name": "analyze_text",
  "arguments": {
    "text": "Mientras por competir con tu cabello,\noro bruñido al sol relumbra en vano;\nmientras con menosprecio en medio el llano\nmira tu blanca frente el lilio bello;\n\nmientras a cada labio, por cogello,\nsiguen más ojos que al clavel temprano,\ny mientras triunfa con desdén lozano\nde el luciente cristal tu gentil cuello,\n\ngoza cuello, cabello, labio y frente,\nantes que lo que fue en tu edad dorada\noro, lilio, clavel, cristal luciente,\n\nno sólo en plata o vïola troncada\nse vuelva, mas tú y ello juntamente\nen tierra, en humo, en polvo, en sombra, en nada.",
    "groups": ["verse"],
    "descriptions": false
  }
}
{
  "verse": {
    "n_lines": {"value": 14},
    "n_stanzas": {"value": 4},
    "meter": {"value": "endecasílabo"},
    "n_feet": {"value": 11},
    "p_deviations": {"value": 0.0},
    "p_pyrrhics": {"value": 0.0},
    "p_rhymed": {"value": 1.0},
    "p_masculine": {"value": 0.0},
    "p_feminine": {"value": 1.0},
    "p_dactylic": {"value": 0.0},
    "rhyme_schemes": {"value": {"ABBA": 2, "ABA": 2}},
    "rhymes": {"value": {"consonante": 14}},
    "strophes": {"value": {"cuarteto": 2, "terceto": 2}},
    "form": {"value": "soneto"}
  },
  "warnings": []
}

Parameters

Parameter Type Default Description
text string "" Text in Spanish
path string null Absolute path to a file with the text or a link ests://datasets/... instead of text
groups array[string] ["basic", "readability"] Groups of statistics; each is a key of the response
distributions boolean false Add the distributions of words by letters and syllables and of punctuation marks by type (the basic group)
readability_preset string "general" Coefficients of the Flesch reading ease and the scale that reads it, on which the consensus grade depends as well (the readability group): general - Szigriszt-Pazos with the INFLESZ scale, fits any text; classic - Fernández Huerta with his bands, for comparison with studies and tools that use his formula
blank_lines boolean false A paragraph is the part of the text between blank lines rather than a line (the cohesion group): for a text whose lines are wrapped inside its paragraphs
seseo boolean false Read the rhyme with seseo (the verse group): z, and c before e and i, rhyme with s (voz - dos, taza - casa), as poets of Andalusia, the Canary Islands and America rhyme
descriptions boolean true Add descriptions to the statistics
per_text array[string] [] Statistics «group.key» (verse.meter, readability.consensus_grade), up to 10, for every text of the query link in path: the response is a table of texts instead of the groups

Groups

Group What it computes Data
basic Sentences, words, syllables, characters, long and complex words -
readability Consensus grade and readability formulas with the school stage and reader age -
diversity Lexical diversity -
morph Parts of speech, grammatical features, verb forms and clitics -
phon Sound classes, consonant clusters, hiatuses, word junctions, alliteration and assonance -
cohesion Cohesion: overlaps between sentences and paragraphs, givenness, connectors -
style SEO metrics and markers of the administrative style -
lexical Word frequency, frequency bands, surprisal frequency dictionary
verse Meter, rhyme, line endings, strophes and the form of a poem -
syntax Syntax by the dependency tree -
unadapted_readability Readability formulas of other languages -

How to download the dictionary is described in Data.

Basic statistics

basic · BasicStats

Sentences, words, syllables, characters, letters, spaces and punctuation marks; unique, long (from 7 letters), complex (from 3 syllables), simple, monosyllabic and polysyllabic words; the entropy of word lengths in letters and syllables. A count of words or characters comes with its share of all words or characters (share). Numbers count as words but have no syllables. With distributions=true the group adds the distributions of words by letters and syllables and of punctuation marks by type.

Readability

readability · ReadabilityStats · ests://scales/readability

Consensus grade and the formulas for Spanish: the Flesch reading ease with the coefficients of the preset, Gutiérrez de Polini, Crawford, Legibilidad µ, SOL, LIX, RIX, reading time. The grade formulas (Crawford, SOL), the consensus grade and RIX read as a stage of the Spanish school system and the reader age; the reading ease, Legibilidad µ and LIX as a band of their own scale; Gutiérrez de Polini and the reading time have no scale. readability_preset sets the coefficients of the reading ease and its scale, from which the consensus grade also takes a grade; the other formulas do not depend on it. Numbers are not counted as words. On a text shorter than 30 sentences the formulas are unstable, and the response warns about it.

Lexical diversity

diversity · DiversityStats

TTR and its corrections, MATTR, MSTTR, MTLD and its variants, HD-D, the indices of Simpson, Yule and Honoré, Orlov's Z, entropy, the laws of Zipf and Heaps, burstiness of frequent words - over word forms in lower case. On a text shorter than 50 words the measures are unstable, and on a text shorter than 200 words texts are better compared by MATTR, MTLD and HD-D: the response warns about it.

Morphology

morph · MorphStats

Parts of speech and 15 grammatical features by esMorph in the context of the sentence and the shares of the forms that mark the register: the moods among the finite forms, the infinitive, gerund and participle, verb forms with clitics after them («dámelo») and before them («me lo da»), ser against estar, adverbs in -mente, diminutives. The value of a feature is the number of words with each of its values, labeled as in esTS, and share gives their shares of all words. The imperative of tú that has the form of the indicative («Abre la ventana») is read as indicative, so the share of the imperative under-reports orders.

Phonostatistics

phon · PhonStats

Shares of vowels, sonorants, voiced and voiceless obstruents, the ratio of consonants to vowels, heavy consonant clusters, hiatuses inside words and at word junctions - the junctions open to a synalepha, junctions of 4 or more consonants, entropy of the consonant-vowel patterns of words, hardness, open syllables and syllable length, the indices of alliteration and assonance. Computed by the transcription of the words in the pronunciation of Spain: ch, ll, rr and qu are one sound, h is none.

Cohesion

cohesion · CohesionStats

Cohesion after Coh-Metrix and TAACO: overlaps of nouns, arguments and content words between sentences - adjacent ones, all pairs and the next two - and between adjacent paragraphs, pronouns and demonstratives, givenness, repetition of tense and mood, connectors per 1000 words by class (causal, adversative, concessive, temporal, additive, conditional, reformulative) and kind. A paragraph is a line of the text, with blank_lines the part of the text between blank lines. Connectors are split by their place: those that link a sentence to the previous ones open it («Sin embargo», «Por lo tanto»), the others are inside the sentence, including subordinating conjunctions and prepositions at its start («Cuando llegó»).

Style

style · StyleStats

SEO metrics by word forms - classic and academic nausea, water content, spam score and naturalness by Zipf's law - and the lexical markers of the administrative style: verbal nouns, compound prepositions («en el marco de»), parenthetical expressions, clichés («dar cumplimiento», «proceder a»). The SEO metrics have no norms for Spanish: texts are compared with each other. They are meant for website texts of a few hundred words, and on a text shorter than 200 or longer than 1000 words the response warns about it.

Beyond the metrics of esTS the group gives the number of words n_words, the most frequent word forms top_words and the most frequent content words nausea_words, by which the academic nausea is computed. The markers of the administrative style come with the number of occurrences count and the words and phrases found found; a suffix of verbal nouns also catches nouns that come from no verb («ciencia», «distancia»). The syntactic markers of the administrative style are in the syntax group: to check a text for it, take both groups.

Lexical sophistication

lexical · LexicalStats · frequency dictionary

Share of words found in the frequency dictionary of Google Books Ngram (Spanish books of 1980-2019), mean frequency (ipm) and its logarithm over all words and over content words, range and dispersion over the years, surprisal and perplexity, shares of words from the 1000-10000 most frequent lemmas, lexical density, the shares of proper nouns and abbreviations. Without the dictionary the group computes only the shares of frequency bands, the lexical density and the shares of proper nouns and abbreviations; the other metrics are null, and a warning names the command that downloads it.

Verse

verse · VerseStats

Lines and stanzas, the meter and its metrical syllables counted with synalephas and the law of the final stress, lines off the meter and lines without its rhythmic stresses, the share of rhymed lines (consonante or asonante) and the rhyme schemes of the stanzas, aguda, llana and esdrújula endings, the strophes of the stanzas (cuarteto, redondilla, terceto, lira, décima) and the form of the poem (soneto, romance, silva). A line of the text is a line of verse, a blank line separates stanzas. The stresses come from the spelling: no dictionary is needed. With seseo z, and c before e and i, rhyme with s.

Syntax

syntax · SyntaxStats

Syntax by the dependency tree of esSyntax: dependency length, depth and shape of the tree, words before the root, verb valency, clauses, subordinate and infinitive clauses, the L2SCA indices (T-units, verb phrases, coordinate phrases, complex nominals), coordination chains, noun modifiers, prepositional chains and chains of de («el aumento de la eficiencia del uso de los recursos»), participial and gerund clauses, the passive with ser and with se, impersonal se, infinitives, negations, split predicates («llevar a cabo», «hacer una revisión»), the order of subjects and objects, the similarity of adjacent sentences, the ratio of nouns to verbs. An infinitive clause («quiere salir», «salió para ayudar») is a clause of its own but not a subordinate one, while a periphrasis («puede salir», «tiene que venir») is one clause. The parser takes nearly every se without a subject of its own for the se of the passive, so the passive with se runs high and the impersonal se low: they are read together.

Formulas of other languages

unadapted_readability · UnadaptedReadabilityStats

Readability formulas of English, German and Italian with their original coefficients: FORCAST, Linsear Write, Powers-Sumner-Kearl, EFLAW, four Wiener Sachtextformeln, Dickes-Steiwer, Gulpease, Fucks, Strain, ELF and Wheeler-Smith. They are computed from the letters and syllables of Spanish words without calibration: the values compare Spanish texts with each other and with other tools but give no Spanish grade and have no scale. A Spanish word has more syllables than an English one, so the formulas by syllables read a Spanish text as harder, and the response warns about it. The description of every formula names its language and direction: the greater, the harder or the easier the text.

Result

A key for each requested group and warnings. A statistic of a group is an object with the fields:

Field Type Description
value number / string / object Value; null - the statistic is undefined on this text
share number / object Share of all words or characters, if there is one
interpretation string Reading by a scale of esTS, if there is a scale: the school stage and age of the reader, the band of the INFLESZ scale
count integer For the markers of the administrative style of the style group: the number of occurrences
found object For the markers of the administrative style of the style group: the words and phrases found with their frequencies, up to the 20 most frequent
description string What the statistic computes; absent with descriptions=false

With per_text the response has the keys per_text and warnings. In per_text: stats - the requested statistics, rows - a row per text with the link path, the title title and the values of the statistics by the keys «group.key», summary - a summary of every statistic: for numbers the number of texts n, the mean mean, the smallest min and the greatest max, for strings (the meter) - n and the frequencies of the values counts, for dictionaries (parts of speech, rhyme schemes) - n and the summed frequencies totals, up to the 20 most frequent. For a text where the group does not give the statistic the value is null. The warnings come once each with the number of texts that have them, and the differing numbers of the texts in them as a range («Sentences in the text: 1-3, fewer than 30... (texts: 30)»).