" >> "$2/tableau.html" ;
for ligne in $(cat "$1/$fichier")
do
coderetour=$(curl -SI -o toto -w %{http_code} $ligne);
#si coderetour est egale à 200, alors
if [[ $coderetour == 200 ]]
then
encodage=$(curl -SI -o encode -w %{content_type} $ligne| cut -f2 -d"="|tr '[a-z]' '[A-Z]'|tr -d '\r');
echo - e "$numtableux::$compteur::$coderetour::$encodage::$ligne\n" ;
if [[ $encodage == 'UTF-8' ]]
then
echo -e "encodage initial <$encodage> OK:on passe au traitement \n" ;
#aspiration de l'URL
curl -sL -o ./PAGES-ASPIREES/$numtableux-$compteur.html "$ligne" ;
# dump de l'URL
lynx -dump -nolist -assume_charset=$encodage -display_charset=$encodage "./PAGES-ASPIREES/$numtableux-$compteur.html" > ./DUMP-TEXT/$numtableux-$compteur.txt;
if [[ $fichier == "urlchinois.txt" ]]
then
# 1. segmentation
bash ./stanford-segmenter-2018-10-16/segment.sh -k ctb ./DUMP-TEXT/$numtableux-$compteur.txt "UTF-8" "0" > ./SEGMENTATION/chi-$numtableux-$compteur.txt;
# 2. contextes
egrep -i -C2 $MOTIF ./SEGMENTATION/chi-$numtableux-$compteur.txt > ./CONTEXTES/$numtableux-$compteur.txt;
# 3. Fq motif
nbmotif=$(egrep -oc $MOTIF ./SEGMENTATION/chi-$numtableux-$compteur.txt);
# 4. contexte html
perl ./MINIGREP/minigrepmultilingue.pl "UTF-8" ./SEGMENTATION/chi-$numtableux-$compteur.txt ./MINIGREP/motif-regexp-chi.txt;
mv resultat-extraction.html ./CONTEXTES/$numtableux-$compteur.html;
# 5. index hierarchique
egrep -o "\w+" ./SEGMENTATION/chi-$numtableux-$compteur.txt | sort | uniq -c | sort -gr > ./DUMP-TEXT/index-$numtableux-$compteur.txt;
# 6. bigramme
egrep -o "\w+" ./SEGMENTATION/chi-$numtableux-$compteur.txt > chi.txt ;
tail -n +2 chi.txt > chi2.txt ;
paste chi.txt chi2.txt > chi3.txt ;
cat chi3.txt | sort | uniq -c| sort -gr > ./DUMP-TEXT/bigrams-$numtableux-$compteur.txt;
elif [[ $fichier == "urlarabe" ]]
then
# 1. segmentation
java -cp stanford-segmenter-2018-10-16/stanford-segmenter-3.9.2.jar -mx1g edu.stanford.nlp.international.arabic.process.ArabicSegmenter -loadClassifier stanford-segmenter-2018-10-16/data/arabic-segmenter-atb+bn+arztrain.ser.gz -textFile ./DUMP-TEXT/$numtableux-$compteur.txt > ./SEGMENTATION/ara-$numtableau-$compteur.txt
# 2. contextes
egrep -i -C2 $MOTIF ./SEGMENTATION/ara-$numtableau-$compteur.txt > ./CONTEXTES/$numtableux-$compteur.txt;
# 3. Fq motif
nbmotif=$(egrep -oc $MOTIF ./SEGMENTATION/ara-$numtableau-$compteur.txt);
# 4. contexte html
perl ./MINIGREP/minigrepmultilingue.pl "UTF-8" ./SEGMENTATION/ara-$numtableau-$compteur.txt ./MINIGREP/motif-regexp-ara.txt;
mv resultat-extraction.html ./CONTEXTES/$numtableux-$compteur.html;
# 5. index hierarchique
egrep -o "\w+" ./SEGMENTATION/ara-$numtableux-$compteur.txt | sort | uniq -c | sort -gr > ./DUMP-TEXT/index-$numtableux-$compteur.txt;
# 6. bigramme
egrep -o "\w+" ./SEGMENTATION/ara-$numtableux-$compteur.txt > ara.txt ;
tail -n +2 ara.txt > ara2.txt ;
paste ara.txt ara2.txt > ara3.txt ;
cat ara3.txt | sort | uniq -c| sort -gr > ./DUMP-TEXT/bigrams-$numtableux-$compteur.txt;
else
# 1. contextes
egrep -i -C2 $MOTIF ./DUMP-TEXT/$numtableux-$compteur.txt > ./CONTEXTES/$numtableux-$compteur.txt;
# 2. Fq motif
nbmotif=$(egrep -oc $MOTIF ./DUMP-TEXT/$numtableux-$compteur.txt);
# 3. contexte html
perl ./MINIGREP/minigrepmultilingue.pl "UTF-8" ./DUMP-TEXT/$numtableux-$compteur.txt ./MINIGREP/motif-regexp-fra.txt;
mv resultat-extraction.html ./CONTEXTES/$numtableux-$compteur.html;
# 4. index hierarchique
egrep -o "\w+" ./DUMP-TEXT/$numtableux-$compteur.txt | sort |uniq -c| sort -gr > ./DUMP-TEXT/index-$numtableux-$compteur.txt;
# 5. bigramme
egrep -o "\w+" ./DUMP-TEXT/$numtableux-$compteur.txt > fic1; #on met les mots dans un fichier fic1
tail -n +2 fic1 > fic2; #on met tous les 2e mots dans le fic2
paste fic1 fic2 > fic3 ;
cat fic3 | sort | uniq -c| sort -gr > ./DUMP-TEXT/bigrams-$numtableux-$compteur.txt;
fi
echo "$compteur |
$ligne |
CODE RETOURE=$coderetour |
ENCODAGE=$encodage |
$numtableux-$compteur.html |
$numtableux-$compteur.txt |
$numtableux-$compteur.txt |
$numtableux-$compteur.html |
index-$numtableux-$compteur.txt |
bigrams-$numtableux-$compteur.txt |
$nbmotif |
" >> "$2/tableau.html";
else
returniconv=$(iconv -l | egrep "\b$encodage\b");
if [[ $returniconv != "" ]] #si c'est pas vide
then
echo -e "encodage initial <$encodage> OK, connu de iconv : on passe au traitement \n";
#aspiration de l'URL
curl -sL -o ./PAGES-ASPIREES/$numtableux-$compteur.html "$ligne" ;
# dump de l'URL
lynx -dump -nolist -assume_charset=$encodage -display_charset=$encodage "./PAGES-ASPIREES/$numtableux-$compteur.html" > ./DUMP-TEXT/$numtableux-$compteur.txt;
if [[ $fichier == "urlchinois.txt" ]]
then
# 1. segmentation
bash ./stanford-segmenter-2018-10-16/segment.sh -k ctb ./DUMP-TEXT/$numtableux-$compteur.txt "UTF-8" "0" > ./SEGMENTATION/chi-$numtableux-$compteur.txt;
# 2. contextes
egrep -i -C2 $MOTIF ./SEGMENTATION/chi-$numtableux-$compteur.txt > ./CONTEXTES/$numtableux-$compteur.txt;
# 3. Fq motif
nbmotif=$(egrep -oc $MOTIF ./SEGMENTATION/chi-$numtableux-$compteur.txt);
# 4. contexte html
perl ./MINIGREP/minigrepmultilingue.pl "UTF-8" ./SEGMENTATION/chi-$numtableux-$compteur.txt ./MINIGREP/motif-regexp-chi.txt;
mv resultat-extraction.html ./CONTEXTES/$numtableux-$compteur.html;
# 5. index hierarchique
egrep -o "\w+" ./SEGMENTATION/chi-$numtableux-$compteur.txt | sort | uniq -c | sort -gr > ./DUMP-TEXT/index-$numtableux-$compteur.txt;
# 6. bigramme
egrep -o "\w+" ./SEGMENTATION/chi-$numtableux-$compteur.txt > chi.txt ;
tail -n +2 chi.txt > chi2.txt ;
paste chi.txt chi2.txt > chi3.txt ;
cat chi3.txt | sort | uniq -c| sort -gr > ./DUMP-TEXT/bigrams-$numtableux-$compteur.txt;
elif [[ $fichier == "urlarabe" ]]
then
# 1. segmentation
java -cp stanford-segmenter-2018-10-16/stanford-segmenter-3.9.2.jar -mx1g edu.stanford.nlp.international.arabic.process.ArabicSegmenter -loadClassifier stanford-segmenter-2018-10-16/data/arabic-segmenter-atb+bn+arztrain.ser.gz -textFile ./DUMP-TEXT/$numtableux-$compteur.txt > ./SEGMENTATION/ara-$numtableau-$compteur.txt
# 2. contextes
egrep -i -C2 $MOTIF ./SEGMENTATION/ara-$numtableau-$compteur.txt > ./CONTEXTES/$numtableux-$compteur.txt;
# 3. Fq motif
nbmotif=$(egrep -oc $MOTIF ./SEGMENTATION/ara-$numtableau-$compteur.txt);
# 4. contexte html
perl ./MINIGREP/minigrepmultilingue.pl "UTF-8" ./SEGMENTATION/ara-$numtableau-$compteur.txt ./MINIGREP/motif-regexp-ara.txt;
mv resultat-extraction.html ./CONTEXTES/$numtableux-$compteur.html;
# 5. index hierarchique
egrep -o "\w+" ./SEGMENTATION/ara-$numtableux-$compteur.txt | sort | uniq -c | sort -gr > ./DUMP-TEXT/index-$numtableux-$compteur.txt;
# 6. bigramme
egrep -o "\w+" ./SEGMENTATION/ara-$numtableux-$compteur.txt > ara.txt ;
tail -n +2 ara.txt > ara2.txt ;
paste ara.txt ara2.txt > ara3.txt ;
cat ara3.txt | sort | uniq -c| sort -gr > ./DUMP-TEXT/bigrams-$numtableux-$compteur.txt;
else
# 1. contextes
egrep -i -C2 $MOTIF ./DUMP-TEXT/$numtableux-$compteur.txt > ./CONTEXTES/$numtableux-$compteur.txt;
# 2. Fq motif
nbmotif=$(egrep -oc $MOTIF ./DUMP-TEXT/$numtableux-$compteur.txt);
# 3. contexte html
perl ./MINIGREP/minigrepmultilingue.pl "UTF-8" ./DUMP-TEXT/$numtableux-$compteur.txt ./MINIGREP/motif-regexp-fra.txt;
mv resultat-extraction.html ./CONTEXTES/$numtableux-$compteur.html;
# 4. index hierarchique
egrep -o "\w+" ./DUMP-TEXT/$numtableux-$compteur.txt | sort |uniq -c| sort -gr > ./DUMP-TEXT/index-$numtableux-$compteur.txt;
# 5. bigramme
egrep -o "\w+" ./DUMP-TEXT/$numtableux-$compteur.txt > fic1; #on met les mots dans un fichier fic1
tail -n +2 fic1 > fic2; #on met tous les 2e mots dans le fic2
paste fic1 fic2 > fic3 ;
cat fic3 | sort | uniq -c| sort -gr > ./DUMP-TEXT/bigrams-$numtableux-$compteur.txt;ux-$compteur-utf8.txt ./MINIGREP/motif-regexp-fra.txt;
mv resultat-extraction.html ./CONTEXTES/$numtableux-$compteur.html;
fi
echo "$compteur |
$ligne |
CODE RETOURE=$coderetour |
ENCODAGE=$encodage |
$numtableux-$compteur.html |
$numtableux-$compteur.txt |
$numtableux-$compteur.txt |
$numtableux-$compteur.html |
index-$numtableux-$compteur.txt |
bigrams-$numtableux-$compteur.txt |
$nbmotif |
" >> "$2/tableau.html";
else
echo -e "encodage initial <$encodage> a pas connu par iconv \n";
returniconv=$(egrep -io ‘charset=\"?[^\",]+\"?’ PAGES-ASPIREES/*.html | cut -f2 -d"=" | tr -d ‘“’);
if [[ $returniconv! = "" ]]
then
#aspiration de l'URL
curl -sL -o ./PAGES-ASPIREES/$numtableux-$compteur.html "$ligne" ;
# dump de l'URL
lynx -dump -nolist -assume_charset=$encodage -display_charset=$encodage "./PAGES-ASPIREES/$numtableux-$compteur.html" > ./DUMP-TEXT/$numtableux-$compteur.txt;
if [[ $fichier == "urlchinois.txt" ]]
then
# 1. segmentation
bash ./stanford-segmenter-2018-10-16/segment.sh -k ctb ./DUMP-TEXT/$numtableux-$compteur.txt "UTF-8" "0" > ./SEGMENTATION/chi-$numtableux-$compteur.txt;
# 2. contextes
egrep -i -C2 $MOTIF ./SEGMENTATION/chi-$numtableux-$compteur.txt > ./CONTEXTES/$numtableux-$compteur.txt;
# 3. Fq motif
nbmotif=$(egrep -oc $MOTIF ./SEGMENTATION/chi-$numtableux-$compteur.txt);
# 4. contexte html
perl ./MINIGREP/minigrepmultilingue.pl "UTF-8" ./SEGMENTATION/chi-$numtableux-$compteur.txt ./MINIGREP/motif-regexp-chi.txt;
mv resultat-extraction.html ./CONTEXTES/$numtableux-$compteur.html;
# 5. index hierarchique
egrep -o "\w+" ./SEGMENTATION/chi-$numtableux-$compteur.txt | sort | uniq -c | sort -gr > ./DUMP-TEXT/index-$numtableux-$compteur.txt;
# 6. bigramme
egrep -o "\w+" ./SEGMENTATION/chi-$numtableux-$compteur.txt > chi.txt ;
tail -n +2 chi.txt > chi2.txt ;
paste chi.txt chi2.txt > chi3.txt ;
cat chi3.txt | sort | uniq -c| sort -gr > ./DUMP-TEXT/bigrams-$numtableux-$compteur.txt;
elif [[ $fichier == "urlarabe" ]]
then
# 1. segmentation
java -cp stanford-segmenter-2018-10-16/stanford-segmenter-3.9.2.jar -mx1g edu.stanford.nlp.international.arabic.process.ArabicSegmenter -loadClassifier stanford-segmenter-2018-10-16/data/arabic-segmenter-atb+bn+arztrain.ser.gz -textFile ./DUMP-TEXT/$numtableux-$compteur.txt > ./SEGMENTATION/ara-$numtableau-$compteur.txt
# 2. contextes
egrep -i -C2 $MOTIF ./SEGMENTATION/ara-$numtableau-$compteur.txt > ./CONTEXTES/$numtableux-$compteur.txt;
# 3. Fq motif
nbmotif=$(egrep -oc $MOTIF ./SEGMENTATION/ara-$numtableau-$compteur.txt);
# 4. contexte html
perl ./MINIGREP/minigrepmultilingue.pl "UTF-8" ./SEGMENTATION/ara-$numtableau-$compteur.txt ./MINIGREP/motif-regexp-ara.txt;
mv resultat-extraction.html ./CONTEXTES/$numtableux-$compteur.html;
# 5. index hierarchique
egrep -o "\w+" ./SEGMENTATION/ara-$numtableux-$compteur.txt | sort | uniq -c | sort -gr > ./DUMP-TEXT/index-$numtableux-$compteur.txt;
# 6. bigramme
egrep -o "\w+" ./SEGMENTATION/ara-$numtableux-$compteur.txt > ara.txt ;
tail -n +2 ara.txt > ara2.txt ;
paste ara.txt ara2.txt > ara3.txt ;
cat ara3.txt | sort | uniq -c| sort -gr > ./DUMP-TEXT/bigrams-$numtableux-$compteur.txt;
else
# 1. contextes
egrep -i -C2 $MOTIF ./DUMP-TEXT/$numtableux-$compteur.txt > ./CONTEXTES/$numtableux-$compteur.txt;
# 2. Fq motif
nbmotif=$(egrep -oc $MOTIF ./DUMP-TEXT/$numtableux-$compteur.txt);
# 3. contexte html
perl ./MINIGREP/minigrepmultilingue.pl "UTF-8" ./DUMP-TEXT/$numtableux-$compteur.txt ./MINIGREP/motif-regexp-fra.txt;
mv resultat-extraction.html ./CONTEXTES/$numtableux-$compteur.html;
# 4. index hierarchique
egrep -o "\w+" ./DUMP-TEXT/$numtableux-$compteur.txt | sort |uniq -c| sort -gr > ./DUMP-TEXT/index-$numtableux-$compteur.txt;
# 5. bigramme
egrep -o "\w+" ./DUMP-TEXT/$numtableux-$compteur.txt > fic1; #on met les mots dans un fichier fic1
tail -n +2 fic1 > fic2; #on met tous les 2e mots dans le fic2
paste fic1 fic2 > fic3 ;
cat fic3 | sort | uniq -c| sort -gr > ./DUMP-TEXT/bigrams-$numtableux-$compteur.txt;
fi
echo "$compteur |
$ligne |
CODE RETOURE=$coderetour |
ENCODAGE=$encodage |
$numtableux-$compteur.html |
$numtableux-$compteur.txt |
$numtableux-$compteur.txt |
$numtableux-$compteur.html |
index-$numtableux-$compteur.txt |
bigrams-$numtableux-$compteur.txt |
$nbmotif |
" >> "$2/tableau.html";
fi
fi
fi
else
echo "$compteur | $ligne | Code_http:$coderetour | - | - | - | - | - | - | - | - |
" >> "$2/tableau.html";
fi
compteur=$((compteur+1));
done
echo "