Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

VOCD – Vocabulary Diversity (D Statistic)

Status: Current Last updated: 2026-06-01 12:03 EDT

Purpose

Computes the D statistic for lexical diversity using bootstrap sampling of type-token ratios (TTR). The D statistic provides a more stable measure of vocabulary diversity than raw TTR because it accounts for sample size effects.

See the CLAN manual for the original VOCD command specification.

Usage

chatter-clan vocd file.cha
chatter-clan vocd --speaker CHI file.cha
chatter-clan vocd --format json file.cha

Options (chatter-native)

OptionCLAN FlagDescription
--speaker <CODE>+t*CHI (or +tCHI)Include speaker
--exclude-speaker <CODE>-t*CHI (or -tCHI)Exclude speaker
--gem <LABEL>+g"label"Restrict to gem segment
--range <START-END>+z25-125Utterance range
--id-filter <PATTERN>+t@ID="..."Filter by @ID pattern
--include-retracings+r6Include retraced words in counting
--format <FMT>–Output format: clan (default), text, json, csv

CLAN +-flag coverage audit

Authoritative enumeration of every CLAN vocd flag, mapped against chatter’s coverage. Sources:

  • OSX-CLAN/src/clan/vocd/vocd.cpp: usage() and getflag().
  • OSX-CLAN/src/clan/cutt.cpp: mainusage() VOCD branches.
  • crates/talkbank-clan/src/clan_args.rs: chatter’s rewriter.
  • crates/talkbank-cli/src/cli/args/clan_commands.rs::Vocd plus clan_common.rs::CommonAnalysisArgs.

(Status legend: same as FREQ.)

VOCD has the largest command-specific flag surface of any CLAN analysis tool, dominated by the D_optimum sampling parameters.

VOCD-specific +-flags (from vocd.cpp::getflag)

CLAN flagMeaningChatterStatusNotes
+b0D_optimum: use split half, even,MissingSampling-method switch.
+b1D_optimum: use split half, odd,Missing
+bsND_optimum: size N of starting sample (default 35),Missing
+blND_optimum: size N of largest sample (default 50),Missing
+biND_optimum: size N of increments (default 1),Missing
+bnND_optimum: N number of samples (default 100),Missing
+brD_optimum: random sampling with replacement (default: without),Missing
+beD_optimum: sequential sampling,Missing
+c / +c0 / +c1Find capitalised words only (+c/+c0) or mid-uppercase (+c1)--capitalization <initial|mid>DoneLanded 2026-05-22. Shares the CapitalizationFilter enum with FREQ. +c/+c0 (alias) → initial filter; +c1 → mid (e.g. McDonald, iPhone). Applied before VOCD’s token sequence reaches the D-statistic sampler.
+d, +d1, +d2, +d3Output mode (utterances + types/tokens; summary only; etc.),MissingOSX-CLAN/src/clan/vocd/vocd.cpp:311 sets onlydata = atoi(getfarg(...))+1 (bounded by OnlydataLimit; onlydata == 4 rejected under CLAN_SRV). chatter has no --display-mode consumer for VOCD. Per-VOCD rewriter arm in clan_args.rs passes the token through so clap reports the literal +dN argument rather than the misleading --display-mode rewrite.
+gnS / -gnSCompute LRD, S = NUMERATOR +s directives,MissingLRD = Limiting Relative Diversity.
+gdS / -gdSCompute LRD, S = DENOMINATOR +s directives,Missing
+oOverride default lemma-based analysis,MissingSwitches VOCD from %mor lemma-based to main-tier word-based.
+o3Combine selected speakers per filepartial via --per-file inversePartial

General +-flags VOCD inherits (from cutt.cpp::mainusage)

CLAN flagMeaningChatterStatusNotes
+t*X / -t*XInclude/exclude speaker--speaker / --exclude-speakerDone+tX accepted post-2026-05-21.
+t%X / -t%XInclude/exclude dependent tier--tier / --exclude-tier (rewriter target)Rewriter only
+t@ID="..."Filter by @ID pattern--id-filterDone
+s"word" / -s"word"Include/exclude word--include-word / --exclude-wordDoneVOCD’s +sm suffix variants for %mor searches not special-cased.
+s@F / -s@FSearch / exclude words from file--include-word-file / --exclude-word-fileDoneLanded 2026-05-22. File format: one pattern per line; blank lines, # -comments, and ;%* -annotation lines skipped. Repeatable.
+gXGem filter (without N suffix)--gemDoneDistinct from +gnS/+gdS.
+zN-MUtterance range--rangeDone
+rNRetrace / clitic / prosodic controls--include-retracings (+r6)Partial
+uCombine across files(default)Done
+reRecurse(default)Done
+kCase-fold toggle: VOCD preserves case by default, +k folds to lowercase--plus-k (carries +k)DoneVOCD is in CLAN’s mmaininit nomap=TRUE set (cutt.cpp:7845), so it PRESERVES case by default; +k TOGGLES nomap (cutt.cpp:13816) to fold, collapsing case variants before the D-statistic sampler. INVERSE of the fold-by-default commands; chatter sets VOCD’s case_sensitive keying to !(+k present). VOCD output is non-deterministic (random sampling), so this is pinned by the deterministic token-case tests vocd_default_preserves_case_in_tokens and vocd_plus_k_folds_case_in_tokens, not a byte golden.
+f / +fEXTOutput to file--output-ext (rewriter target)Rewriter only

Audit summary

BucketCount
Done9
Partial2
Rewriter only5
Missing13

VOCD has the largest Missing bucket of any audited command, driven by the D_optimum sampling parameter family (+b0, +b1, +bsN, +blN, +biN, +bnN, +br, +be) and the LRD family (+gnS, +gdS). chatter’s vocd uses a fixed default sampling strategy with no exposed knobs. The +o lemma-vs-main-tier override is also missing, researchers studying main-tier diversity directly cannot get there from chatter today. Filed as Phase 1.7 follow-ups.

CLAN Equivalence

CLAN commandRust equivalent
vocd file.chachatter-clan vocd file.cha
vocd +t*CHI file.chachatter-clan vocd file.cha --speaker CHI

Algorithm

Overview

VOCD fits empirical type-token data to a theoretical curve, finding the D parameter that best explains the relationship between sample size and vocabulary diversity.

Steps

  1. Collect tokens: Gather all countable word tokens per speaker from the main tier
  2. Bootstrap sampling (3 independent trials):
    • For each sample size N from 35 through 50:
      • Draw 100 random samples of N tokens (without replacement)
      • Compute mean TTR across the 100 samples
    • Fit the empirical (N, TTR) curve to the theoretical D-curve using gradient-descent least-squares optimization
    • Record the optimal D value
  3. Report: Per-trial D values and their average

Theoretical TTR Curve

TTR(N) = (D/N) * [sqrt(1 + 2*N/D) - 1]

This models the expected type-token ratio for a sample of size N given a lexical diversity parameter D. Higher D means greater diversity.

Interpretation

D valueInterpretation
< 30Low lexical diversity
30-70Typical range for young children
70-100Typical range for older children/adults
> 100High lexical diversity

(Values are approximate and depend on the population.)

Output

Per-speaker D statistic with per-trial breakdown tables:

Speaker: CHI
  Trial 1:
    N    samples  TTR     std_dev   D
    35   100      0.743   0.045     42.1
    36   100      0.735   0.043     42.3
    ...
    50   100      0.680   0.038     43.0
    D = 42.5
  Trial 2: D = 41.8
  Trial 3: D = 43.2
  Average D = 42.5

Differences from CLAN

Stochastic variation

Because VOCD uses random sampling, D values may differ slightly between runs and between CLAN and our implementation. This is expected behavior, not a bug. Differences of +/- 5 are normal.

Fusional feature stripping

Fusional features (&PRES, &INF, etc.) are stripped from lemmas in %mor echo output. This ensures clean lemma display when VOCD echoes the morphological tier for insufficient-token warnings.

Word identification

Uses AST-based is_countable_word() instead of CLAN’s string-prefix matching. Token collection operates on parsed AST content rather than raw text.

Output formats

Supports text, JSON, and CSV. CLAN produces text only.

Golden test parity

100% parity with CLAN C binary output (within expected stochastic variation).