#! /bin/nash
for F in valid test train_S1 train_S2 train_S3 ; do cat ./$F.txt | tr '(),.' ' ' | awk 'BEGIN{SR["northern_america"]=1; SR["eastern_europe"]=1; SR["australia_and_new_zealand"]=1; SR["melanesia"]=1; SR["micronesia"]=1; SR["eastern_africa"]=1; SR["southern_asia"]=1; SR["eastern_asia"]=1; SR["south_america"]=1; SR["central_europe"]=1; SR["western_asia"]=1; SR["northern_africa"]=1; SR["western_africa"]=1; SR["northern_europe"]=1; SR["middle_africa"]=1; SR["caribbean"]=1; SR["polynesia"]=1; SR["western_europe"]=1; SR["southern_europe"]=1; SR["central_america"]=1; SR["southern_africa"]=1; SR["central_asia"]=1; SR["south_eastern_asia"]=1; R["americas"]=1; R["europe"]=1; R["africa"]=1; R["oceania"]=1; R["asia"]=1}{if($1!="locatedIn") printf("%s(%s,%s).\n", $1, $2, $3); else {if($NF in SR) printf("%sCS(%s,%s).\n", $1, $2, $3); else if($NF in R) { if ($(NF-1) in SR) printf("%sSR(%s,%s).\n", $1, $2, $3); else printf("%sCR(%s,%s).\n", $1, $2, $3);}}}' > ./${F}_p.txt; done

