#!/usr/bin/bash #bash PROGRAMMES/programme_tableau.bash DOSSIER_URLS FICHIER_HTML MOTIF echo "" > $2 echo "TABLEAUX" >> $2 echo "" >> $2 comtab=1 for fichier in $(ls $1) do echo '' > corpus-$comtab.txt echo '' > corpus_ctx-$comtab.txt compteur=1 echo "" >> $2 echo "" >> $2 for ligne in $(cat $1/$fichier) do code_sortie=$(curl -sIL $ligne | head -n1 | cut -d" " -f2) function UTF8(){ lynx --assume-charset="UTF-8" --display-charset="UTF-8" -dump -nolist $ligne > ./DUMP-TEXT/$comtab-$compteur.txt egrep -i "$3" ./DUMP-TEXT/$comtab-$compteur.txt > ./CONTEXTES/$comtab-$compteur.txt echo -e "\n" >> corpus-$comtab.txt cat ./DUMP-TEXT/$comtab-$compteur.txt >> corpus-$comtab.txt echo -e "\n\n" >> corpus-$comtab.txt echo -e "\n" >> corpus_ctx-$comtab.txt cat ./CONTEXTES/$comtab-$compteur.txt >> corpus_ctx-$comtab.txt echo -e "\n\n" >> corpus_ctx-$comtab.txt nbmotif=$(egrep -coi "$3" ./DUMP-TEXT/$comtab-$compteur.txt) perl5.28.0.exe ./minigrep/minigrepmultilingue.pl "utf-8" ./DUMP-TEXT/$comtab-$compteur.txt ./minigrep/motif-regexp.txt mv resultat-extraction.html ./CONTEXTES/$comtab-$compteur.html egrep -o "\w+" ./DUMP-TEXT/$comtab-$compteur.txt | sort | uniq -c | sort -r > ./DUMP-TEXT/$comtab-$compteur-index.txt egrep -o "\w+" ./DUMP-TEXT/$comtab-$compteur.txt > bi1.txt tail -n +2 bi1.txt > bi2.txt tail -n +2 bi2.txt > bi3.txt paste bi1.txt bi2.txt > big.txt paste big.txt bi3.txt > tri.txt cat big.txt | sort | uniq -c | sort -r > ./DUMP-TEXT/$comtab-$compteur-bigramme.txt cat tri.txt | sort | uniq -c | sort -r > ./DUMP-TEXT/$comtab-$compteur-trigramme.txt echo "" >> $2 } function UTF8conv(){ lynx --assume-charset="UTF-8" --display-charset="UTF-8" -dump -nolist $ligne > ./DUMP-TEXT/$comtab-$compteur-$1.txt iconv -s -f "$1" -t "UTF-8" ./DUMP-TEXT/$comtab-$compteur-$1.txt > ./DUMP-TEXT/$comtab-$compteur.txt echo -e "\n" >> corpus-$comtab.txt cat ./DUMP-TEXT/$comtab-$compteur.txt >> corpus-$comtab.txt echo -e "\n\n" >> corpus-$comtab.txt egrep -i "$3" ./DUMP-TEXT/$comtab-$compteur.txt > ./CONTEXTES/$comtab-$compteur.txt echo -e "\n" >> corpus_ctx-$comtab.txt cat ./CONTEXTES/$comtab-$compteur.txt >> corpus_ctx-$comtab.txt echo -e "\n\n" >> corpus_ctx-$comtab.txt nbmotif=$(egrep -coi "$3" ./DUMP-TEXT/$comtab-$compteur.txt) perl5.28.0.exe ./minigrep/minigrepmultilingue.pl "utf-8" ./DUMP-TEXT/$comtab-$compteur.txt ./minigrep/motif-regexp.txt mv resultat-extraction.html ./CONTEXTES/$comtab-$compteur.html egrep -o "\w+" ./DUMP-TEXT/$comtab-$compteur.txt | sort | uniq -c | sort -r > ./DUMP-TEXT/$comtab-$compteur-index.txt egrep -o "\w+" ./DUMP-TEXT/$comtab-$compteur.txt > bi1.txt tail -n +2 bi1.txt > bi2.txt tail -n +2 bi2.txt > bi3.txt paste bi1.txt bi2.txt > big.txt paste big.txt bi3.txt > tri.txt cat big.txt | sort | uniq -c | sort -r > ./DUMP-TEXT/$comtab-$compteur-bigramme.txt cat tri.txt | sort | uniq -c | sort -r > ./DUMP-TEXT/$comtab-$compteur-trigramme.txt echo "" >> $2 } function Pbenc(){ echo -e "PB Encodage...$comtab::$compteur::$code_sortie::$1::$ligne\n" echo "" >> $2 } function Pburl(){ echo -e "PB URL...$comtab::$compteur::$code_sortie::::$ligne\n" echo "" >> $1 } if [[ $code_sortie == 200 ]] then curl -sL -o ./PAGES-ASPIREES/$comtab-$compteur.html $ligne #on essaie sans file encodage=$(egrep -oi "charset=[\"a-zA-Z0-9-]*" ./PAGES-ASPIREES/$comtab-$compteur.html | head -1 | cut -d"=" -f2 | egrep -oi "[a-zA-Z0-9-]*" | tr "[a-z]" "[A-Z]") echo "ligne$comtab-$compteur encodage: $encodage" if [[ $encodage == "UTF-8" ]] then UTF8 $encodage $2 $3 else reponse=$(iconv -l | egrep "$encodage") if [[ $reponse != "" ]] then UTF8conv $encodage $2 $3 else Pbenc $encodage $2 fi fi else Pburl $2 fi compteur=$((compteur+1)) done echo "
N° du lien Code Http URL Page aspirée Dump text Encodage Contexte Context HTML Fq Motif Index Bigramme Trigramme
$comtab-$compteur $code_sortie $ligne Page aspirée n° $comtab-$compteur Dump text n°$comtab-$compteur $1 Contexte $comtab-$compteur Ctx HTML $comtab-$compteur $nbmotif Index $comtab-$compteur Bigramme $comtab-$compteur Trigramme $comtab-$compteur
$comtab-$compteur $code_sortie $ligne Page aspirée n° $comtab-$compteur Dump text n°$comtab-$compteur $1 Contexte $comtab-$compteur Ctx HTML $comtab-$compteur $nbmotif Index $comtab-$compteur Bigramme $comtab-$compteur Trigramme $comtab-$compteur
$comtab-$compteur $code_sortie $ligne Page aspirée n° $comtab-$compteur - $1 - - - - - -
$comtab-$compteur $code_sortie $ligne Page aspirée n° $comtab-$compteur - - - - - - - -
" >> $2 egrep -o "\w+" ./corpus-$comtab.txt | sort | uniq -c | sort -r > corpus-$comtab-index.txt egrep -o "\w+" ./corpus_ctx-$comtab.txt | sort | uniq -c | sort -r > corpus_ctx-$comtab-index.txt echo " Corpus N° $comtab Contexte N° $comtab Corpus index N° $comtab Contexte index N° $comtab " >> $2 echo "
" >> $2 comtab=$((comtab + 1)) done echo "" >> $2 echo "" >> $2