#! /bin/bash -eu
# Last edited on 2026-04-21 22:00:01 by stolfi

min_wlen="$1"; shift
max_wlen="$1"; shift
max_tlen="$1"; shift

min_wpl=$( echo "scale = 0; (${max_tlen} + 1)/(${max_wlen} + 1)" | bc -lq )
echo "min words per line = ${min_wpl}" 1>&2

out_dir="res"
ex_dir="work/VoynichNinja/005"

echo "comparing TLA on uncorrelated and correlated text ..." 1>&2
run_prefix_A="text_0_${min_wlen}_${max_wlen}_TLA_${max_tlen}"
run_prefix_B="text_1_${min_wlen}_${max_wlen}_TLA_${max_tlen}"
top_title="TLA - W = ${max_tlen} - effect of word correlaton"
title_A="independent"
title_B="correlated"
plot_prefix="text_0x1_${min_wlen}_${max_wlen}_TLA_${max_tlen}"
plot_word_stats_by_pos.sh \
  ${min_wlen} ${max_wlen} ${max_tlen} ${min_wpl} \
  "${run_prefix_A}" "${title_A}" \
  "${run_prefix_B}" "${title_B}" \
  "${plot_prefix}" \
  "${top_title}"

echo "comparing TLA with SLA on uncorrelated text ..." 1>&2
run_prefix_A="text_0_${min_wlen}_${max_wlen}_TLA_${max_tlen}"
run_prefix_B="text_0_${min_wlen}_${max_wlen}_SLA_${max_tlen}"
top_title="W = ${max_tlen} - TLA x SLA on uncorrelated text"
title_A="TLA"
title_B="SLA"
plot_prefix="text_0_${min_wlen}_${max_wlen}_TLAxSLA_${max_tlen}"
plot_word_stats_by_pos.sh \
  ${min_wlen} ${max_wlen} ${max_tlen} ${min_wpl} \
  "${run_prefix_A}" "${title_A}" \
  "${run_prefix_B}" "${title_B}" \
  "${plot_prefix}" \
  "${top_title}"

echo "comparing TLA with SLA on correlated text ..." 1>&2
run_prefix_A="text_1_${min_wlen}_${max_wlen}_TLA_${max_tlen}"
run_prefix_B="text_1_${min_wlen}_${max_wlen}_SLA_${max_tlen}"
top_title="W = ${max_tlen} - TLA x SLA on correlated text"
title_A="TLA"
title_B="SLA"
plot_prefix="text_1_${min_wlen}_${max_wlen}_TLAxSLA_${max_tlen}"
plot_word_stats_by_pos.sh \
  ${min_wlen} ${max_wlen} ${max_tlen} ${min_wpl} \
  "${run_prefix_A}" "${title_A}" \
  "${run_prefix_B}" "${title_B}" \
  "${plot_prefix}" \
  "${top_title}"
