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

COMBO – Boolean Keyword Search

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

Purpose

Searches for utterances matching boolean combinations of keywords. Supports AND (+) and OR (,) logic with case-insensitive substring matching. This is the primary search tool for finding utterances containing specific words or word combinations.

See the CLAN manual for the original COMBO command specification.

Usage

chatter-clan combo -S "want+cookie" file.cha
chatter-clan combo -S "want,milk" file.cha
chatter-clan combo -S "want+cookie" --speaker CHI file.cha

Options (chatter-native)

OptionCLAN flagDescription
--speaker <CODE>+t*CHI (or +tCHI)Include speaker
--exclude-speaker <CODE>-t*CHI (or -tCHI)Exclude speaker
-S, --search <EXPR>+s"EXPR"Search expression (required, repeatable; multiple --search flags combined with OR)
--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 combo flag, mapped against chatter’s coverage. Sources:

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

(Status legend: same as FREQ.)

COMBO-specific +-flags (from combo.cpp::getflag)

CLAN flagMeaningChatterStatusNotes
+bNSearch an N number-cluster unit,MissingMulti-utterance match.
+g1String-oriented search on the whole tier (default: word-oriented),Missingchatter does not yet implement string-oriented whole-tier search. Per-COMBO rewriter arm in clan_args.rs returns None so the literal +g1 token passes through to clap (which rejects it) rather than silently mis-routing to --gem 1 via the generic +g → rewrite_gem arm.
+g2String-oriented search on a single word,Missingchatter does not yet implement string-oriented single-word search. Same passthrough pattern as +g1.
+g3Find only the first match per utterance--first-match-onlyDoneLanded 2026-05-22. When set, the per-expression matcher short-circuits after the first hit per utterance, expr_hits records only the first matching expression. Default behaviour reports every matching expression.
+g4Exclude utterance delimiters from the search(no-op accept)DoneLanded 2026-05-23. chatter’s COMBO calls countable_words on the main tier, which iterates UtteranceContent::Word/AnnotatedWord/ReplacedWord (and recursively into groups) but never reaches Terminator, terminators live at a separate AST level. So +g4’s effect (exclude delimiters) is the chatter default; the rewriter consumes the flag, clap never sees it. Without the arm, +g4 would fall through to the generic gem-segment branch and mis-route to --gem 4. Pinned by combo_g4_is_silently_consumed_as_noop.
+g5Use ^ as AND operator instead of “followed-by”(no-op accept)DoneLanded 2026-05-22. chatter’s combo already uses + as AND (matching +g5’s semantic), so +g5 is consumed by the rewriter as a no-op; no clap field is needed; the flag is silently dropped.
+g6Include the tier’s code name in the search,Missingchatter’s search does not include the tier code name. Same passthrough pattern as +g1/+g2.
+g7Do not count duplicate matches--dedupe-matchesDoneLanded 2026-05-22. Repeated word forms within a single utterance contribute at most one entry to each expression’s matched_words; first-encounter order preserved. Mainly affects OR expressions (cookie,milk) over utterances with repeated tokens.
+sS / -sSPattern (required), output tiers matching / not matching-S / --search plus --exclude-searchDoneBoth polarities mapped 2026-05-22. The rewriter routes +sS → --search S and -sS → --exclude-search S for COMBO specifically (other commands keep the per-word +s/-s semantic). Utterances matching any --exclude-search expression are dropped even if they match an --search expression.
+s@F / -s@FLoad search expressions from file F (one per line)--search-file / --exclude-search-fileDoneLanded 2026-05-22. Each surviving line is parsed by SearchExpr::parse, so AND (+) and OR (,) operators work per line, just like inline --search. File format matches cutt.cpp::rdexclf: blank lines, # -comments, ;%* -annotation lines skipped; UTF-8 BOM stripped. Repeatable. Pinned by combo_search_at_sigil_routes_to_search_file and combo_exclude_search_at_sigil_routes_to_exclude_search_file in clan_args.rs.
+dvDisplay all parsed individual parts of the search pattern,MissingSearch-debug output.
+d, +d1..+d5Display modes (CHAT, line numbers, file names, matched-only, etc.),MissingFull local handler at OSX-CLAN/src/clan/combo.cpp:2858: +dv → search-debug echo (separate +dv row above); +d7 → linkDep2Other cross-tier linkage; +d8 → onlydata = 9 override; +d/+d0..+d6 → onlydata = atoi+1 with +d2 (onlydata==3) also resetting puredata = 0. Per-COMBO passthrough arm lands the literal-flag error rather than the misleading --display-mode rewrite.

General +-flags COMBO 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
+gXGem filter--gemDoneDistinct from +g1..+g7 (no S suffix).
+zN-MUtterance range--rangeDone
+rNRetrace / clitic / prosodic controls--include-retracings (+r6)Partial
+uCombine across files(default)Done
+reRecurse(default)Done
+pSWord delimiter,Missing
+kCase-sensitive--case-sensitiveDoneLanded 2026-05-23. Reads CommonAnalysisArgs::case_sensitive. Two-layer fix: SearchExpr::parse_with_case preserves case in the stored terms (default parse() lowercases), and process_utterance populates words via cleaned_text() instead of NormalizedWord::from_word. Both sides must agree, so ComboConfig::case_sensitive is the single switch threaded into both. Pinned by combo_case_sensitive_uppercase_keyword_misses_lowercase_word and combo_case_sensitive_matches_when_case_aligned.
+wN / -wNContext window--context-after N / --context-before NDoneLanded 2026-05-23. Same shape as KWAL: ComboState carries a VecDeque ring buffer for pre-context plus an awaiting_after Vec for post-context. process_utterance interleaves the bookkeeping with match-detection. Exclude (-sS) utterances still feed the windows (they count as non-matches), so context bookkeeping is correct around excluded utterances. Pinned by combo_context_after_captures_post_match_lines, combo_context_before_captures_pre_match_lines, combo_default_no_context_window.
+f / +fEXTOutput to file--output-ext (rewriter target)Rewriter onlyPhase 1.1.

Audit summary

BucketCount
Done13
Partial2
Rewriter only6
Missing8

COMBO has the second-largest “Rewriter only” bucket after KWAL, driven by the same +dN display-mode story. The COMBO-specific +g1..+g7 search-mode switches are also load-bearing: they each change the matching semantic, and a researcher pasting combo +g1 +s"want milk" file.cha into chatter today gets chatter’s word-oriented match (no analog for +g1).

Search Syntax

  • + between terms means AND (all terms must be present in the utterance)
  • , between terms means OR (at least one term must be present)
  • Terms are case-insensitive substring matches against countable words
  • Multiple --search flags are combined with OR (any expression matching counts)
  • AND takes precedence if both + and , appear in one expression

CLAN Equivalence

CLAN commandRust equivalent
combo +s"want^cookie" file.chachatter-clan combo file.cha -S "want+cookie"
combo +s"want|milk" file.chachatter-clan combo file.cha -S "want,milk"
combo +s"want^cookie" +t*CHI file.chachatter-clan combo file.cha -S "want+cookie" --speaker CHI

Display Modes (+dN / --display-mode N), DRAFT, awaiting PI review

Status: drafted from CLAN manual; not yet implemented. Rewriter at crates/talkbank-clan/src/clan_args.rs:101 translates +dN → --display-mode N; no clap field consumes it today. Drafted from CLAN manual §7.7.10 (Unique Options, COMBO) for PI review.

NCLAN behavior (verbatim from manual)
+d (no number)“Normally, combo outputs the location of the tier where the match occurs. When the +d switch is turned on you can output only each matched sentence in a simple legal chat format.”
+d1“Outputs legal chat format along with line numbers and file names.”
+d2“Outputs files names once per file only.”
+d3“Outputs legal chat format, but with only the actual words matched by the search string, along with @Comment headers that are ignored by other programs.”
+d4“Use of the +d4 switch was described in the previous section.” (Manual cross-reference; resolution pending.)
+d7“Search for words linked between two tiers.”

Open questions for PI review

  1. +d/+d1/+d2 parallel KWAL’s +d/+d1/+d2 almost exactly. Worth defining a shared --display-mode enum across search-style commands (KWAL + COMBO) with the same variant names?
  2. +d3 “matched words plus @Comment headers” is COMBO-specific. Probably a separate enum variant.
  3. +d4: manual cross-references the “previous section”. This needs PI clarification, the immediately-previous section is general COMBO description, not a +d-table.
  4. +d7 (cross-tier linkage) overlaps with FREQ +d7. If both commands’ +d7 is “compare two tiers”, the enum variant name should match.

Output

Each matching utterance with:

  • Source filename
  • Speaker code
  • Full utterance text (CHAT format)
  • Summary counts of matching vs. total utterances

Differences from CLAN

  • Operator syntax: CLAN uses ^ for AND and \| for OR; this implementation uses + and , respectively for shell-friendliness.