-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add and refactor text statistics functionality #350
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
partial factors should now be computed correctly
this lets us use these functions for Doc property/method extensions! to avoid re-computing potentially expensive operations, we cache a couple functions
I know, I overuse utils modules... but I think it's a bit nicer than importing private funcs from all over the place, or plopping them down in strange in places.
this allows us to use these functions as doc extensions, it makes them easier to call directly a la carte, it moves lang-checking into the functions that need it. only downside is a slight performance hit, but i'll take it.
there's a better way
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
ttr()
: type-token-ratio, in three variations (standard, root, corrected)log_ttr()
: logarithmically-scaled TTR, in three variations (herdan, summer, dugast)segmented_ttr()
: segmented TTR, in two variations (mean, moving average)mtld()
: Measure of Textual Lexical Diversity, a modern and text length-agnostic measurehdd()
: Hypergeometric Distribution Diversity, a(nother) modern and text length-agnostic measureDoc
object as their first positional argument (i.e.Callable[[Doc, ...], int | float]
, so they're more directly usable and accessible.get_words()
utils func to reduce overheadTextStats
readability properties under a singleTextStats.readability()
method, where individual statistics are specified by name; similarly, addsTextStats.diversity()
and.counts()
methods for accessing those statisticsTextStatsComponent
custom spaCy language component with a suite ofDoc
property and method extensions, settable viatextacy.text_stats.set_doc_extensions()
; the outcome is roughly the same -- various text stats accessible via spaCy'sDoc._
-- but the process is differentMotivation and Context
There are lots of use cases and methods for quantifying aspects of a document, and I wanted
textacy
to capture more of them. I even used something like annotation counts for a research project. Also, thetext_stats
functionality was clunky in many ways, and I wanted to make it easier for people to use.Types of changes
Checklist: