#!/bin/sh
#  This shell is generated by NlmMedlineExplorDataShells / generIndexAutAff
if test -e  $EXPLOR_AREA/Data/PubMed/Corpus/AutAff.i.hcs
then
echo "----- Executing -rf  $EXPLOR_AREA/Data/PubMed/Corpus/AutAff.i.*"
rm -rf  $EXPLOR_AREA/Data/PubMed/Corpus/AutAff.i.*
fi
( HfdCat $EXPLOR_AREA/Data/PubMed/Corpus/biblio.hfd\
  | SxmlSelect -s record/TEI/teiHeader/fileDesc/titleStmt/author -p @s1 -p @1  \
  |  SxmlSelect -s author/name/attribute::uniqKey -p @s1 -g author/name/1 -p @g1  \
 -s author/affiliation/nlm:affiliation author/affiliation/wicri:noCountry -p @s2  -p @2       

 HfdCat $EXPLOR_AREA/Data/PubMed/Corpus/biblio.hfd\
  | SxmlSelect -s record/TEI/teiHeader/fileDesc/titleStmt/author -p @s1 -p @1  \
  | grep -v "</nlm:affiliation>"     \
  | SxmlSelect -s author/name/attribute::uniqKey -p @s1 -g author/name/1 -p @g1   \
          -p "<nlm:affiliation>NONE</nlm:affiliation>"   -p @2       

 ) | sort      \
  | SxmlGrouping | HfdBuild -h $EXPLOR_AREA/Data/PubMed/Corpus/AutAff.i   
 IndexBuildHid -h $EXPLOR_AREA/Data/PubMed/Corpus/AutAff.i -e k   
 HfdCat $EXPLOR_AREA/Data/PubMed/Corpus/AutAff.i.hfd     \
      |  SxmlSelect -g g/t/1 -g g/k/1 -p @g1 -p "<idx><kw>@g2</kw><f>@g1</f></idx>"     \
      | sort -rn    \
      | SgmlFast -c 1     \
      | head -500 > /Users/jacquesducloy/Documents/WicriRoot/Wicri/Manuel/explor/Rabelais.storage/RabelaisV1/Data/PubMed/Corpus/AutAff.i.sort    
 echo "==== " PubMed, step Corpus, index aut-aff done
 HfdCat /Users/jacquesducloy/Documents/WicriRoot/Wicri/Manuel/explor/Rabelais.storage/RabelaisV1/Data/PubMed/Corpus/AutAff.i.hfd | wc 
