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

MLT – Mean Length of Turn

Status: Current

Purpose

Calculates mean length of turn in utterances and words. A “turn” is a maximal consecutive sequence of utterances by the same speaker; the turn boundary is detected when a different speaker produces the next utterance.

See the CLAN manual for the original MLT command specification.

Usage

chatter clan mlt file.cha
chatter clan mlt --speaker CHI file.cha
chatter clan mlt --format json corpus/

Options

OptionCLAN FlagDescription
--speaker <CODE>+t*CHIInclude speaker
--exclude-speaker <CODE>-t*CHIExclude speaker
--gem <LABEL>+g"label"Restrict to gem segment
--range <START-END>+z25-125Utterance range
--format <FMT>–Output format: text, json, csv, clan

CLAN Equivalence

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

Algorithm

  1. Walk utterances in file order
  2. Group consecutive utterances by the same speaker into turns
  3. For each speaker, compute:
    • Number of turns
    • Total utterances and total words
    • MLT-u: mean turn length in utterances
    • MLT-w: mean turn length in words
    • SD: standard deviation of words per utterance (population SD, dividing by n)

Turn boundaries

A turn boundary occurs when a different speaker produces the next utterance. For example:

*CHI: I want a cookie .          <- turn 1 (CHI)
*CHI: please .                   <- still turn 1 (CHI)
*MOT: here you go .              <- turn 2 (MOT)
*CHI: thank you .                <- turn 3 (CHI)

CHI has 2 turns (3 utterances), MOT has 1 turn (1 utterance).

Output

Speaker: CHI
  Turns: 15
  Utterances: 42
  Words: 127
  MLT (utterances): 2.800
  MLT (words): 8.467
  SD: 3.217

Differences from CLAN

Standard deviation

Uses population SD (dividing by n), matching CLAN. This was verified during parity testing.

SD basis

The SD is computed over per-utterance word counts, not per-turn totals. This matches CLAN’s behavior, which was confirmed through golden test comparison.

Turn detection

Operates on parsed speaker codes from the AST rather than raw text line prefixes. Functionally identical but type-safe.

Output formats

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

Golden test parity

100% parity with CLAN C binary output.