Bull. Soc. sci. Nancy (1898) Millot/Outils
De Wicri Nancy
(Redirigé depuis Bull. Soc. sci. Nancy (1898) Millot/Lex)
Cette page montre les outils utilisés pour traiter les données relatives à l'article Températures extrêmes de 1878 à 1893 à Nancy.
Génération des tableaux mensuels
L'analyseur lexical lex est ici utilisé pour faciliter la conversion des tableaux.
Le programme lex
cat <<... > convertTab.lex
int zone;
%START TEMP
%START AN
%%
^[1-9][0-9]* {printf("|-\n|%s\n| ", yytext); BEGIN TEMP; zone=2;}
<TEMP>"—" printf("-");
<TEMP>[0-9]"°"[0-9]* {printf("0%s\n", yytext); zone++; BEGIN AN;}
<TEMP>[0-9][0-9]"°"[0-9]* {printf("%s\n", yytext); zone++; BEGIN AN;}
<AN>18[0-9][0-9] {printf("|%s\n|", yytext); zone++; BEGIN TEMP; }
<AN>18[0-9][0-9][ ]*"et"[ ]*18[0-9][0-9] {printf("|%s\n|", yytext); zone++; BEGIN TEMP; }
<AN>18[0-9][0-9][ ]*","[ ]*[0-9][0-9]*[ ]*"et"[ ]*[0-9][0-9]* {printf("|%s\n|", yytext); zone++; BEGIN TEMP; }
. ;
\n BEGIN 0;
%%
int main()
{
printf("{| class=\"wikitable sortable\"\n");
printf("|-\n!jour\n!minimum\n!année\n!maximum\n!année\n!différence\n");
yylex();
printf("|-\n|}\n");
}
...
lex convertTab.lex
gcc lex.yy.c -ll -o convertTab
./convertTab < fevrier.text
Récupération des tableaux
WicriGetPage -l wicri-nancy.fr -p "Bull. Soc. sci. Nancy (1898) Millot/Tableaux mensuels"
cat <<... > consolide.c
#include "SxmlNode.h"
main()
{
SxmlNode *docu;
char *c1, *c2, *c3, *c4, *c5, *mois, *an ;
mois=malloc(10);
an=malloc(10);
while((docu=SxmlInputGetDocumentElement()))
{
c1=SxmlLeafText(SxmlFirstChild(SxmlGetFirstChildByTagName(docu,"c1")));
c2=SxmlLeafText(SxmlFirstChild(SxmlGetFirstChildByTagName(docu,"c2")));
if (strcmp(c1, "mois")==0) {strcpy(mois, c2); continue;}
c3=SxmlLeafText(SxmlFirstChild(SxmlGetFirstChildByTagName(docu,"c3")));
printf("|-\n|");
if(strlen(c3) > 4) {strncpy(an,c3,4); printf ("%s\n", an); }
else printf ("%s\n", c3);
printf("|%s/%s\n", mois, c1);
printf("|%s\n", c2);
c4=SxmlLeafText(SxmlFirstChild(SxmlGetFirstChildByTagName(docu,"c4")));
c5=SxmlLeafText(SxmlFirstChild(SxmlGetFirstChildByTagName(docu,"c5")));
if(strlen(c5) > 4) {strncpy(an,c5,4); printf ("|%s\n", an); }
else printf ("|%s\n", c5);
printf("|%s/%s\n", mois, c1);
printf("|%s\n", c4);
}
}
...
gcc consolide.c $DILIB_CC -o consolide