Analysis Module (PsychiatryNLPKit.analysis)
Seven categories of linguistic analysis functions, each returning a dictionary keyed by section name with numeric metric values.
Every analysis is invoked by name through TextData.compute(name) or orchestrated in
batch via BatchAnalyzer. Both resolve the required
TextData property, language, and models from the registry.
Registry
Built-in immutable sequence. |
|
Return the |
|
|
Declarative description of a registered analysis. |
Batch Analysis
Container for batch analysis output. |
|
Run selected analyses on a |
Syntax Metrics
POS tag ratios, clause structure, syntax tree depth, and sentence complexity.
Average sentence length (in tokens) per section. |
|
Average syntax tree height per section. |
|
Average number of unique POS tags per sentence per section. |
|
|
Adverb-to-total-word ratio per section. |
|
Coordinating conjunction-to-total-word ratio per section. |
Adjective-to-total-word ratio per section. |
|
|
Pronoun-to-total-word ratio per section. |
Determiner-to-total-word ratio per section. |
|
Modal auxiliary verb-to-total-word ratio per section. |
|
Stop word-to-total-word ratio per section. |
|
Average number of clauses per sentence per section. |
|
Average number of noun phrases (NP) per sentence per section. |
|
Average length of adjective phrases per section. |
Similarity Metrics
Semantic coherence measured as cosine similarity between adjacent embeddings.
Cosine similarity between adjacent word embeddings per section. |
|
|
Cosine similarity between adjacent sentence embeddings per section. |
Perplexity Metrics
Language model perplexity at paragraph and sentence levels (generative + masked LM).
Generative perplexity for full paragraphs. |
|
Generative perplexity averaged across sentences per section. |
|
|
Pseudo-perplexity for full paragraphs using a masked language model. |
|
Pseudo-perplexity averaged across sentences per section using a masked LM. |
Density Metrics
Semantic space dimensionality via PCA explained variance, intrinsic dimension estimation, vector-unpacking semantic density, and propositional idea density.
PCA-based density metrics per section. |
|
|
Estimate intrinsic dimensionality using MLE (Levina & Bickel, 2004). |
Semantic density measured by vector unpacking (Rezaii et al., 2019). |
|
Propositional idea density per section (Hill et al., 2021). |
Lexicon Metrics
Disfluency markers, filler word frequency, and Zipf word frequency analysis.
Count the number and ratio of disfluencies in the text data. |
|
Mean and standard deviation of Zipf word frequency per section. |
Optional Analyses
These require additional dependencies (networkx for graph, pillow for image).
Constructs a structural graph from lemmatized content words per section and immediately computes all network metrics. |
|
Compute cosine similarity between an image and selected text sections. |