Metric Functions
How to score a metric
All metrics are called via assoc_score(::Type{<:AssociationMetric}, data; kwargs...). You pass a metric type (e.g., DeltaPiRight, LexicalGravity) and a data container (e.g., ContingencyTable).
using TextAssociations
# A tiny toy example
txt = "a b a c a b a b c"
ct = ContingencyTable(txt, "a"; windowsize=2, minfreq=1)
# Compute ΔP Right (rightward influence)
scores = assoc_score(DeltaPiRight, ct; scores_only=true)
# One score per collocate row
length(scores) == nrow(assoc_df(ct))Notes
- Some metrics require access to the original
tokens(e.g., Lexical Gravity). When needed,assoc_scoreinjects them automatically based on internal traits. - Results are aligned to rows of
assoc_df(data)(one score per collocate).
Common metric types
These are the types you pass to
assoc_score. For the full list, see Metrics → Metric Catalog.
TextAssociations.LexicalGravity — Type
Lexical Gravity — LexicalGravity
Direction-sensitive association weighting with n⁺/n⁻ context diversity.
Use: assoc_score(LexicalGravity, data; kwargs...)
- Family:
directional - Needs tokens? Yes
- Reference: Daudaravičius & Marcinkevičienė (2004)
Implementation is internal (eval_lexicalgravity), called via assoc_score. See assoc_score for API and examples.
TextAssociations.DeltaPiLeft — Type
ΔP Left — DeltaPiLeft
P(X|Y) − P(X|¬Y): leftward influence.
Use: assoc_score(DeltaPiLeft, data; kwargs...)
- Family:
directional - Needs tokens? No
- Reference: Gries (2013)
Implementation is internal (eval_deltapileft), called via assoc_score. See assoc_score for API and examples.
TextAssociations.DeltaPiRight — Type
ΔP Right — DeltaPiRight
P(Y|X) − P(Y|¬X): rightward influence.
Use: assoc_score(DeltaPiRight, data; kwargs...)
- Family:
directional - Needs tokens? No
- Reference: Gries (2013)
Implementation is internal (eval_deltapiright), called via assoc_score. See assoc_score for API and examples.
TextAssociations.PMI — Type
Pointwise Mutual Information — PMI
Association strength via surprisal of co-occurrence.
Use: assoc_score(PMI, data; kwargs...)
- Family:
information_theoretic - Needs tokens? No
- Reference: Church & Hanks (1990)
Implementation is internal (eval_pmi), called via assoc_score. See assoc_score for API and examples.
TextAssociations.PPMI — Type
PPMI
Association metric type used with assoc_score(PPMI, ...).
This metric is generated programmatically. See the Metric Catalog page and assoc_score docs for usage and available options.
TextAssociations.LLR — Type
LLR
Association metric type used with assoc_score(LLR, ...).
This metric is generated programmatically. See the Metric Catalog page and assoc_score docs for usage and available options.
TextAssociations.LogDice — Type
LogDice
Association metric type used with assoc_score(LogDice, ...).
This metric is generated programmatically. See the Metric Catalog page and assoc_score docs for usage and available options.
TextAssociations.Tscore — Type
Tscore
Association metric type used with assoc_score(Tscore, ...).
This metric is generated programmatically. See the Metric Catalog page and assoc_score docs for usage and available options.
TextAssociations.Zscore — Type
Zscore
Association metric type used with assoc_score(Zscore, ...).
This metric is generated programmatically. See the Metric Catalog page and assoc_score docs for usage and available options.
TextAssociations.ChiSquare — Type
ChiSquare
Association metric type used with assoc_score(ChiSquare, ...).
This metric is generated programmatically. See the Metric Catalog page and assoc_score docs for usage and available options.
See also
assoc_score- Metrics → Metric Catalog (auto-generated list of all available metrics)
- Internals → Metric Implementations for the underlying
eval_*functions