#! /bin/bash -eu
# Last edited on 2026-01-17 23:39:40 by stolfi

version="$1"; shift

  JOIN_FILE=join${version}.ivt

echo "MERGING JS AND RZ VERSIONS ..." 1>&2

  # Let's create a file "${JOIN_FILE}" that has my own transcriptions
  # with the holes completed with Rene's transcription:
  
    merge_my_rz_transcriptions.sh 25e1 25rz

echo "ADDING SECTION AND TEXT TYPE FIELDS ..." 1>&2

  # We add to each line of the transcription
  # the fields "{SEC} {TYP}" derived from the locus ID
  # {LOC} = "<{FNUM}.{LSEQ}>"

  STJOIN_FILE=join${version}.stivt

  add_sec_type_fnum_lseq_to_ivt.sh < ${JOIN_FILE} > ${STJOIN_FILE}

echo "SPLITTING BY SECTION AND TEXT TYPE ..." 1>&2

  # We create a separate file "st_files/{sec}-{txty}.ivt" with {LOC} and {DATA}:

  rm -rf st_files/*.ivt
  split_stivt_per_section_and_type.gawk \
      -f error_funcs.gawk \
      -v ext=ivt \
    < ${STJOIN_FILE}

