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

KEYMAP, Contingency Tables for Coded Data

Status: Current Last updated: 2026-05-26 10:36 EDT

Purpose

Builds contingency tables for coded interactional data. The legacy manual describes KEYMAP as choosing initiating or beginning codes on a specific coding tier, then examining all codes on that same tier in the next utterance.

In talkbank-clan, given a set of keyword codes, KEYMAP tracks each keyword occurrence on a specified coding tier and records what code items appear in the immediately following utterance, broken down by speaker.

See the CLAN manual for the original KEYMAP command specification.

Usage

chatter-clan keymap file.cha --keyword code1 --keyword code2
chatter-clan keymap file.cha --keyword code1 --tier spa
chatter-clan keymap file.cha -k code1 -k code2          # short form

Options (chatter-native)

OptionCLAN flagDescription
-k, --keyword <code>+bSPrimary code to track (required, repeatable)
--tier <name>+t%X (rewriter target)Tier label to read codes from (default: cod)
--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
--id-filter <PATTERN>+t@ID="..."Filter by @ID pattern
--format <fmt>–Output format: clan (default), text, json, csv

CLAN +-flag coverage audit

KEYMAP-specific +-flags (from keymap.cpp::usage)

CLAN flagMeaningChatterStatusNotes
+bS / +b@FSet key code(s) to S (or codes in file @F)-k / --keyword (only the inline S form)PartialInline +bS is now routed (since 2026-05-22), rewriter sends --keyword S. File-list form +b@F still missing; it passes through unrewritten so clap rejects loudly.
+cS / +c@FSet complimentary key code to S (or file @F),MissingPair-completion key for the contingency table.
+dOutput in spreadsheet format,MissingOSX-CLAN/src/clan/keymap.cpp:834 no-arg Excel/CSV toggle (no_arg_option(f) + isExcel = TRUE). Per-KEYMAP rewriter arm passes the token through so clap rejects loudly; no --format csv consumer for KEYMAP today.
+oInclude codes that precede target code(s),MissingTwo-sided contingency (before + after).

Audit summary

BucketCount
Done5
Partial1
Rewriter only3
Missing6

KEYMAP’s largest gap is the complimentary code (+cS): without it, the contingency table is one-sided, chatter tracks what follows each keyword, but CLAN’s KEYMAP also pairs keywords with their complimentary codes for a true cross-tabulation. The +o two-sided mode (codes before AND after the target) is also missing.

Output

Per speaker per keyword:

  • Total keyword occurrences
  • Following codes with speaker attribution and frequency counts

Differences from CLAN

  • Manual intent: The legacy manual explicitly treats KEYMAP as a coding-tier command and says that only symbols beginning with $ are considered on that tier; all other strings are ignored.
  • Code extraction for %cod now uses a clan-local semantic %cod item layer derived from the parsed AST rather than flattened tier text
  • Selector handling: %cod selectors such as <w4> and <w4-5> are treated as item scope, not as stand-alone codes, when deriving keyword and following-code items.
  • Manual constraint not yet fully enforced: KEYMAP currently retains a generic non-%cod tier fallback. The manual suggests tighter coding-tier semantics than that fallback provides.
  • Keyword matching is case-insensitive by default
  • Output supports text, JSON, and CSV formats
  • Deterministic ordering via BTreeMap
  • Golden test parity: Verified against CLAN C binary output