#! /bin/bash -e
# Last edited on 2025-08-15 19:37:15 by stolfi

# Reads a fragment of IVTFF transcription from imput.
# Prints a table of the {N} most common words, with their counts.

N="$1"; shift

counts_file=".frag.fcts"
table_file=".frag.ftab"

export PYTHONPATH=".:${HOME}/projects/work:${HOME}/lib:${PYTHONPATH}"

cat \
  | ./ivtff_frac_word_counts.py \
  > ${counts_file}
  
./tabulate_frac_counts.py \
    -sortBy 1 decreasing \
    -maxLines ${N} \
    -language plain \
    -type raw 5.3 \
    ${counts_file} \
  > ${table_file}

cat ${table_file} \
  |  pr -3 -t -T -S' # ' \
  | expand \
  | sed -e 's:^:    # :g' -e 's:[ ][|][|][ ]: :g' \
  1>&2

echo "" \

