Bull. Soc. sci. Nancy (1898) Millot/Outils : Différence entre versions
De Wicri Nancy
imported>Jacques Ducloy (→Le programme lex) |
imported>Jacques Ducloy (→Récupération des tableaux) |
||
(44 révisions intermédiaires par le même utilisateur non affichées) | |||
Ligne 1 : | Ligne 1 : | ||
− | Cette page montre | + | Cette page montre les outils utilisés pour traiter les données relatives à l'article [[Bull. Soc. sci. Nancy (1898) Millot|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== | ==Le programme lex== | ||
Ligne 20 : | Ligne 14 : | ||
^[1-9][0-9]* {printf("|-\n|%s\n| ", yytext); BEGIN TEMP; zone=2;} | ^[1-9][0-9]* {printf("|-\n|%s\n| ", yytext); BEGIN TEMP; zone=2;} | ||
<TEMP>"—" printf("-"); | <TEMP>"—" printf("-"); | ||
− | <TEMP>[ | + | <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] {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; | \n BEGIN 0; | ||
Ligne 28 : | Ligne 24 : | ||
int main() | int main() | ||
{ | { | ||
− | printf("{|\n"); | + | printf("{| class=\"wikitable sortable\"\n"); |
+ | printf("|-\n!jour\n!minimum\n!année\n!maximum\n!année\n!différence\n"); | ||
yylex(); | yylex(); | ||
− | printf(" | + | printf("|-\n|}\n"); |
} | } | ||
... | ... | ||
Ligne 39 : | Ligne 36 : | ||
./convertTab < fevrier.text | ./convertTab < fevrier.text | ||
+ | |||
+ | </source> | ||
+ | |||
+ | ==Récupération des tableaux== | ||
+ | |||
+ | <source lang="sh"> | ||
+ | WicriGetPage -l wicri-nancy.fr -p "Bull. Soc. sci. Nancy (1898) Millot/Tableaux mensuels" | ||
+ | </source> | ||
+ | |||
+ | <source lang="sh"> | ||
+ | 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 | ||
</source> | </source> |
Version actuelle datée du 2 mars 2020 à 10:35
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