pair-at-a-time
Quick Start
- Command:
pair-at-a-time - Local executable:
/home/vimalinx/miniforge3/envs/bio/bin/pair-at-a-time - I/O shape: reads plain text on stdin and writes adjacent token pairs on stdout
When To Use This Tool
- Convert free text into adjacent word pairs for simple co-occurrence or neighbor analysis.
- Normalize punctuation and case before downstream counting, filtering, or sorting.
- Chain after XML / text extraction steps in lightweight EDirect shell pipelines.
- Keep using shell text tools instead of pulling text into Python just to make bigrams.
- Not for paired-end sequencing reads; this is a text-stream wrapper, not a genomics read-pair utility.
Common Patterns
# 1) Adjacent pairs from a sentence
printf 'Alpha beta gamma\n' | pair-at-a-time
# 2) Punctuation is stripped and tokens are lowercased
printf 'BRCA1, TP53; EGFR\n' | pair-at-a-time
# 3) Downstream counting of repeated neighboring pairs
xtract -pattern DocumentSummary -element Title |
pair-at-a-time |
sort | uniq -c | sort -nr
Recommended Workflow
- Feed the tool plain text on stdin, usually after
xtract,sed,tr, or another shell extractor. - Assume punctuation will be discarded and alphabetic text lowercased before pairing.
- Capture stdout directly into
sort,uniq -c, or other downstream shell filters. - If record boundaries matter, split and process each record separately before calling this wrapper.
Guardrails
- There is no real option parsing:
-hor--helpproduce no useful built-in help text. - The script depends on the companion helper
word-at-a-timebeing onPATH; invokingpair-at-a-timeby absolute path alone can still fail withword-at-a-time: command not found. - Non-alphanumeric characters are converted to spaces and all alphabetic characters are lowercased.
- Consecutive duplicate tokens are collapsed by
uniqbefore pairing, sofoo foo barbecomesfoo bar. - Original line / record boundaries are not preserved; the wrapper effectively pairs across the flattened token stream.