Repository navigation
0.7.0
The seventh release of esTS moves the library onto anyTS 0.2.13, the language-independent core of text statistics. It also:
- reads every readability statistic by a scale;
- starts a sentence after a blank line in a parsed
Doc; - shows the words behind the officialese markers and the academic nausea, which now leaves out the stopwords;
- keeps abbreviations whole in every case.
Requires Python 3.11 or newer. Install with pip install -U pyests and import with import ests. The dependencies are now anyts>=0.2.13,<0.3 and spacy>=3.8.15, both installed with the package.
New
- Readability readings.
ReadabilityStats.describe(stat)reads every statistic that has a scale. The reading ease is read by the scale of the preset, INFLESZ forgeneraland Fernández Huerta forclassic;level_scale(stat)returns that scale. Legibilidad µ is read by its bands, and LIX by the text types of Björnsson (the English labels of the core).- The grades of Crawford, SOL, RIX and the consensus grade are read as a stage of the Spanish school system with its ages.
describegivesNonefor a statistic without a scale or with an undefined value.scale_level, the reading of a value by any scale, is exported fromests.readability_stats.
- Blank lines.
- The
ests_blank_linescomponent starts a sentence after a blank line, so the parser no longer glues a paragraph to the next sentence.get_nlpputs it before the parser (or thesenterorsentencizer).- It runs in linear time (0.025 s on 4000 paragraphs), so
get_nlpparses as fast as in 0.6.1. - It has an entry point, so a saved pipeline loads without importing esTS.
SentsExtractorsplits at blank lines with a tokenizer of your own too.- A
Docwith only partial sentence starts, such as one run without the parser, is read by its text inBasicStats,CohesionStats,kwic,sentence_lengthsand the highlighting.
- The
- Style.
StyleStats.markers()returns the words and phrases each officialese marker counts: the verbal nouns, the compound prepositions, the parenthetical expressions and the clichés, in the order of the text.find_parentheticals(words)returns the bounds of the parenthetical expressions in a list of words, as pairs of start and end.StyleStats.nausea_words()andfind_nausea_wordsreturn the words of the academic nausea with their occurrences. Thenausea_stopwordsparameter ofStyleStatsand of theests_stylecomponent sets its stopwords; it is the last parameter, so positional calls keep working.
- Abbreviations.
ests.constants.TOKENIZER_ABBREVIATIONSlists the 46 abbreviations that spaCy keeps whole in some cases only (Sr.,pág.,etc.,a.m.). Every tokenizer of esTS keeps them whole in lower case, capitalized and in upper case, sokwic(text, "sr. pérez")findsSr. Péreztoo. - Corpus.
ests.corpus.check_keyness_paramschecks the parameters ofkeynessand is documented. - Demo. The readability table has a "Reading" column.
Incompatible changes
The public classes and functions keep their names. Their signatures change only by new optional parameters:
nausea_stopwordsofStyleStatsandests_style, andstopwordsofcalc_academic_nausea, both last;- the keyword-only
messagesofcalc_windowedandcheck_paramsinests.diversity_stats.
- Dependencies.
- anyTS 0.2.13 or newer within 0.2 is required.
- spaCy 3.8.15 or newer is required: spaCy 3.8.2-3.8.14 import
clickwithout requiring it, soimport estsfailed there without it.
- Readability levels.
describe_level,flesch_reading_easy_to_levelandmu_to_levelraiseParameterErrorfor a value that is not a finite number. Before:- for
nanthey returned""; - for
infand-infthey returned the top and the bottom band; - for a value that is not a number they raised
TypeError.
- for
describe_levelandflesch_reading_easy_to_levelraiseParameterErrorfor a scale that is not a known name. A list or a set raisedTypeError, and a false scale ("",[],0) indescribe_levelfell back to the scale of the preset.describe_graderaisesParameterErrorfor an array of names, where it raisedTypeError.describe_level("lix")returns a band instead of raising.
- Academic nausea. It sums the
top_nmost frequent words without the stopwords, divided by all words. Before, the stopwords were counted, so the top ten of almost every text wasde,la,que,el, and none of 300 excerpts ofSpanishLiteraturewas within the norm of Advego (5-15%). On these excerpts the median falls from 29.2% to 6.3%, and 245 of them are within the norm. - Abbreviations as words. The tokenizer of
get_tokenizerandget_nlpkeeps the 46 abbreviations ofTOKENIZER_ABBREVIATIONSwhole in every case, sosr.,ud.,Pág.andSR.are one word with the period, where 0.6.1 split the period off. The words of the extractors and the frequency counts change with them, and a keyword without the period no longer finds such a word:kwic("Habló el sr. Pérez ayer.", "sr")finds nothing,"sr."finds it. - Pipeline.
get_nlp().pipe_nameshasests_blank_linesbefore the parser, so the sentences of a parsedDocstart after blank lines.- Every component of esTS applies the tokenizer rules to the whole pipeline it is added to, abbreviations included.
LexicalStats.band_coverageraisesParameterErrorfor bounds that are not an iterable (100,None), where it raisedTypeError. An iterator is read once.- Characters without a UTF-8 form. A text with a lone surrogate raises
SourceErrorin every class that parses it, where spaCy raisedUnicodeEncodeError.
Numbers
On a fixed set of texts 534 of 4620 results changed against 0.6.1, all in these categories; everything else is bitwise equal.
- Sentences of a
Doc. A string or aDocparsed throughget_nlpnow has a sentence boundary at every blank line. A paragraph opened by a dash or a quote keeps the mark with its first word.- Everything built on the sentences of a
Docmoves for the texts with blank lines: syntax, cohesion, andBasicStatsandReadabilityStatsof aDoc. SyntaxStatsandCohesionStatsof a string parse it withget_nlp, so they move with theDoc.BasicStatsandReadabilityStatsof a string split it withsentenize, so these changes do not touch them.
- Everything built on the sentences of a
- Sentences of a string.
- A sentence goes on after an abbreviation written without spaces (
a.c.,p.ej.,EE.UU.), as it does after the spaced forms, and afteresq.andapdo.. - A line of Unicode spaces (a no-break space, U+3000) between two line breaks is now blank and ends a sentence.
- A sentence goes on after an abbreviation written without spaces (
- Abbreviations.
- Texts with
SR.,Pág.,ud.,ee. uu.ora.m.change their words and their parse. - A dash of a dialogue glued to a dotted acronym (
S.A.—dijo,»P.D.--El) no longer splits its last period off. LexicalStatslooks an abbreviation up without its period, soSr.,SRA.,pág.andetc.findsr,sra,páginaandetcéterain the frequency dictionary. An initial (D.,J.) keeps its period and stays out of the dictionary.
- Texts with
- Academic nausea, as described above.
PhonStatsof a text without sounds. Every statistic isnan; the shares were0while the ratios werenan.p_heavy_clustersisnanfor a text without consonants.zipf_naturalnessis computed in integers, so only its last bits change: frequencies 11, 8, 8, 2, 2 give 50.0 instead of 49.999999999999986, just under the norm.n_spacesandp_spacescount every Unicode space (Zs), so they rise in texts with no-break spaces.
Fixes
SyntaxStatsfollows a long chain of coordinated clauses without recursion: 600 of them raisedRecursionError.dispersion_plotandfrequency_spectrum_plotaccept a numpy array or a pandas Series of words, andfingerprintingandwordtreeone of texts, instead of failing on their truth value; an empty one raisesSourceError(anyTS 0.2.10).ests.utils.count_words_by_spansreads a pandas Series by position, not by its index labels, and returns Python integers.- A component of esTS added to a pipeline that has its tokenizer rules already does not reload the tokenizer. Loading
es_core_news_smwith the ten components takes about half the time of 0.6.1. - The demo shows an infinite value as a dash.
Quality
-
1995 tests pass with 100% line and branch coverage, which is now required.
-
ruffandmypyare clean. -
A QA pass before the release covered:
- a fuzzing of 2.6 million calls on 3504 inputs;
- the lowest versions of the dependencies and Python 3.14;
- the notebooks and the demo;
- the documentation in English and Spanish, with its 132 examples run on each language.
Its findings are fixed in anyTS 0.2.13 and in this release.