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_score injects 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.LexicalGravityType

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)
Tip

Implementation is internal (eval_lexicalgravity), called via assoc_score. See assoc_score for API and examples.

source
TextAssociations.DeltaPiLeftType

Δ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)
Tip

Implementation is internal (eval_deltapileft), called via assoc_score. See assoc_score for API and examples.

source
TextAssociations.DeltaPiRightType

Δ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)
Tip

Implementation is internal (eval_deltapiright), called via assoc_score. See assoc_score for API and examples.

source
TextAssociations.PMIType

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)
Tip

Implementation is internal (eval_pmi), called via assoc_score. See assoc_score for API and examples.

source
TextAssociations.PPMIType

PPMI

Association metric type used with assoc_score(PPMI, ...).

Note

This metric is generated programmatically. See the Metric Catalog page and assoc_score docs for usage and available options.

source
TextAssociations.LLRType

LLR

Association metric type used with assoc_score(LLR, ...).

Note

This metric is generated programmatically. See the Metric Catalog page and assoc_score docs for usage and available options.

source
TextAssociations.LogDiceType

LogDice

Association metric type used with assoc_score(LogDice, ...).

Note

This metric is generated programmatically. See the Metric Catalog page and assoc_score docs for usage and available options.

source
TextAssociations.TscoreType

Tscore

Association metric type used with assoc_score(Tscore, ...).

Note

This metric is generated programmatically. See the Metric Catalog page and assoc_score docs for usage and available options.

source
TextAssociations.ZscoreType

Zscore

Association metric type used with assoc_score(Zscore, ...).

Note

This metric is generated programmatically. See the Metric Catalog page and assoc_score docs for usage and available options.

source
TextAssociations.ChiSquareType

ChiSquare

Association metric type used with assoc_score(ChiSquare, ...).

Note

This metric is generated programmatically. See the Metric Catalog page and assoc_score docs for usage and available options.

source

See also

  • assoc_score
  • Metrics → Metric Catalog (auto-generated list of all available metrics)
  • Internals → Metric Implementations for the underlying eval_* functions