Analysis Module (PsychiatryNLPKit.analysis)
Seven categories of linguistic analysis functions, each returning a dictionary keyed by section name with numeric metric values.
All functions accept pre-computed features from TextData properties and are designed
to be called individually or orchestrated via BatchAnalyzer.
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 (ADJP) 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 and intrinsic dimension estimation.
PCA-based density metrics per section. |
|
|
Estimate intrinsic dimensionality using MLE (Levina & Bickel, 2004). |
Lexicon Metrics
Disfluency markers and filler word frequency analysis.
Count the number and ratio of filler words in the text data. |
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 token-patch similarity between an image and text sections. |