Repository navigation
0.6.0
The sixth release of esTS moves the library onto the second slice of anyTS, the language-independent core of text statistics. It also:
- revisits how sentences, clauses and connectors are counted;
- computes alliteration and assonance against the words in random order;
- adds a gallery of notebooks.
Requires Python 3.11 or newer. Install with pip install pyests and import with import ests. The dependencies are now anyts>=0.2.3,<0.3 and spacy>=3.8, both installed with the package.
Incompatible changes
The public classes and functions keep their names, and their signatures change only where noted below.
- Dependencies. spaCy 3.8 or newer is required: on spaCy 3.7
import estsfails withoutclick, which typer no longer installs. The modeles_core_news_sm3.8 and the demo were on 3.8 already. anyTS 0.2.3 or newer within 0.2 is also required. calc_smog_index(n_complex, n_sents, a, b, c).bis now the number of sentences of the sample (30), and the constant isc. A positionalbchanges meaning:calc_smog_index(10, 30, 1.043, 3.1291)gave 6.427 and now gives 4.194.- Names that left esTS. They live in the core; import them from
anyts.ests.constantsno longer hasCOMPLEX_SYL_FACTOR,LONG_WORD_LETTER_FACTOR,SPACES,PUNCTUATION_TYPES,BASIC_STATS_DESC,SMOG_COMPLEX_SYL_FACTORandLIX_LONG_WORD_LETTER_FACTOR(they are inanyts.constants), norPUNCTUATIONS,HIGHLIGHT_SYNTAX_LAYERSandHIGHLIGHT_TAGGED_LAYERS(replaced byHIGHLIGHT_LAYER_ANNOTATIONS).ests.utilsno longer hasto_path,download_file,extract_archive,sha256(inanyts.datasets),DOWNLOAD_TIMEOUTorTAR_DATA_FILTER. The moduleests.datasets.datasetis gone.- Undocumented names are gone:
DASH_PATTERN,ELLIPSIS_PATTERNandPUNCTUATION_CHARSofests.basic_stats;WordTree,TreeDrawer,FreqNodeandDirectionofests.visualizers.word_tree;MARGIN,MISSING_COLORandSQUAREofests.visualizers.fingerprinting;LINE_BREAK,CSS,select_layers,get_text_words,get_text_sents,get_doc_words,get_doc_sentsandsplit_segmentsof the highlighting;SOUNDS,SOUNDS_ORDER,CONSONANT_COLUMNSand the private helpers of the repetition index inests.phon_stats.
Word,SentandHighlightare the classes of the core.
- Stricter checks. These raise
ParameterErrororSourceTypeErrorinstead of being accepted or failing with a bare Python error:- Readability.
calc_consensus_gradechecks the preset even without a reading ease.- A grade or a reading ease that is not a finite number raises
ParameterErrorwhen it is converted or averaged:flesch_reading_easy_to_grade,ReadabilityStats.reading_ease_to_grade,calc_consensus_gradeandgrade_to_age.flesch_reading_easy_to_grade(nan)gave 13. - A reading speed that is not a positive number also raises:
calc_reading_time(10, nan)gavenan. ReadabilityStatschecks the extractors given with ready basic statistics and refuses basic statistics of another class.
- Types of words and features.
- A word that is not a string in the syllables (
syllabify,count_syllables,word_stress,word_stresses,stress_type), intranscribeand inis_stopword. - Words or parts of speech of
find_connectorsthat are not a list: generators are refused now. Parts of speech must be as many as the words. - Features of
compare_corporaandcorpus_featuresthat are not a function:features=0no longer falls back to the default.
- A word that is not a string in the syllables (
- Plots.
- The axes of every plot (
ax) must be a matplotlibAxes. - The keywords of
keyness_plot, the collocations ofcollocation_networkand the concordances offormat_kwicare checked; iterators are still accepted. highlightrefuses a bool ornanasalliteration_threshold, andsentence_lengthsrefuses sets, mappings and negative lengths.- A component name taken by an extension of another package raises
ParameterError.
- The axes of every plot (
- Readability.
- The formulas of counts return
nanwhen the number of words or sentences they divide by is zero, instead of raisingZeroDivisionError. This covers Flesch, Flesch-Kincaid, Coleman-Liau, ARI, SMOG, fog, LIX, RIX, Gutiérrez de Polini, Crawford and SOL. On other inputs the values are unchanged. kwiccompares the word forms in NFC without soft hyphens, so a decomposed accent matches. A phrase no longer runs across the end of a sentence (by the Spanish rules) or of a paragraph.expand_phrases: a phrase written as such wins over the forms of another phrase (a efectos delnext toa efectos de). The built-in lists do not change.fingerprintingmakes every segmentsegment_lenwords long (anyTS 0.2).
Numbers
The numbers of 0.5.0 are kept except for the changes below. On a fixed set of texts 156 of 4620 results changed, all in these categories.
- Sentences.
- A dash glued to the terminal mark, as the editions of Project Gutenberg type it, now ends the sentence:
baja.--Tieneopens a new line of dialogue. - A glued dash before whitespace closes its line of dialogue and stays with it:
¡Traidores!--,viuda.-- El niño. - A remark after a spaced dash no longer splits the sentence:
Sí. --dijo él. - Abbreviations, initials and list markers still end nothing.
- The corpus of literature has 634,712 sentences instead of 624,200 (+1.7%).
n_sentsand the readability of a string move with the sentence count. A parsedDockeeps the sentences of the parser.
- A dash glued to the terminal mark, as the editions of Project Gutenberg type it, now ends the sentence:
- Clauses (
SyntaxStats). On 450 windows of the corpus of literature,clauses_per_sentrises by 11.7%,subordinate_clauses_per_sentby 21.2% andp_complex_sentsby 8.6%, whilemean_clause_lenfalls by 10.2%. The modelses_core_news_lgandes_dep_news_trfshift by about as much. The rules behind this:- An infinitive under
xcompheads a subordinate clause (quiere salir), unless it makes a periphrasis with its verb (suele salir,vuelve a salir:INFINITIVE_PERIPHRASES, NGLE ch. 28) or the verb isparecer. - A periphrasis whose infinitive the models attach as
conj(tiene que salir) is one predicate. - The form of a predicate is read from its first auxiliary or copula (
predicate_form):- compound tenses, passives and progressives head their clauses (
había llegado,estaba cantando), and so do finite predicates underaclandxcomp; - an infinitive form under
aclis no clause (el miedo de ser robado); - compound and copular gerunds are gerund clauses (
habiendo llegado tarde,siendo elegido presidente).
- compound tenses, passives and progressives head their clauses (
- An infinitive under
- Connectors (
CohesionStats).- The dictionary has 250 markers.
apenas,nada más,lo mismo que,esto esandes másare removed.después de todois now reformulative;en primer/segundo/tercer/último lugarandprimeramenteare now additive. - Rules of place:
puesopening a sentence is no connector;encimacounts only at the start of a sentence or aftery,e,niorpero;en cuanto aandalgo así comocount nothing.
- On the 450 windows, connectors per 1000 words fall by 2.3%: causal −16.1%, reformulative −10.1%, temporal −5.9%.
- The documentation now credits the markers correctly (Martín Zorraquino & Portolés and the NGLE, grouped in the seven classes of the library), with the corrected Coh-Metrix-Esp link.
- The dictionary has 250 markers.
- Alliteration and assonance (
PhonStats,calc_alliteration,calc_assonance).- The expected number of repetitions is the exact one for the words in random order (hypergeometric), through
anyts.phonetics.calc_repetition_index. - Before, it was binomial and read below 1 on random text: 0.966 on shuffled sonnets, now 0.996.
- Books change in the third digit.
- A text where no sound is shared by two words gives
naninstead of0.0.
- The expected number of repetitions is the exact one for the words in random order (hypergeometric), through
Notebooks
A gallery of four notebooks in examples/ shows the library on its datasets, and a Colab button opens each:
- a short story of Quiroga through every tool;
- ten prose authors compared by stylometry;
- the Spanish sonnet across four centuries;
- the corpus measures, Spain against Spanish America.
The outputs are kept, and a weekly workflow runs the notebooks and fails when a number their text quotes has moved.
Fixes
- Sentence splitting is linear on long runs of spaces after a dash and on runs of terminal marks, which took seconds.
- Highlighting a
Docis linear again: 400,000 characters take 0.16 s instead of 42 s (anyTS 0.2.3). zipf(show_theory=True)accepts an integeralpha.SyntaxStatsfinds the clause heads once, so it is about as fast as in 0.5.0 despite the new rules.- The documentation examples, the rules on the pages, the Spanish of the translations and the notes on the models (the recall of the imperative per model) are corrected.
Quality
- 1811 tests pass with 100% line and branch coverage.
ruffandmypyare clean.- The notebooks are checked weekly.
- The numbers of all statistics were compared with 0.5.0 on a fixed set of texts; everything outside the changes above is bitwise equal.