Nuvola apps important.png Attention, suite à une analyse de sécurité, les liens vers quelques serveurs d'exploration sont désactivés.

-

Wicri:CobaltMaghrebV1/Paramètres, filtre Maghreb

De Wicri Terre

Cette page introduit un ensemble d'outils d'extraction de contenus (ExplorAddFullText, ExplorExtractContent, SxmlCumul) qui permettent d'insérer des filtres spécifiques relativement simples à concevoir.

En l’occurrence le filtre lex sur le Maghreb devrait être remplacé bientôt par un outil opérant sur des tables.

Le résultat final est reproduit sur Serveur d'exploration sur le cobalt au Maghreb.

Le filtre

cat <<... >Import/maghrebFilter.lex
%START K
%START W
%START C
%{
 char *key;
 double w;
 void print (char* text, double param)
 {
      printf ("%s\t%s\t%08.3f\n", key, text, param*w);
 }
%}
%%
<K>\t      BEGIN W;
<K>[^\t]+  {strcpy(key, yytext);}
<W>\t      BEGIN C;
<W>[^\t]+  {w=strtod(yytext, NULL);}
<C>Morocco     print("Maroc", 1.);
<C>Maroc       print(yytext, 1.); 
<C>Rabat       print(yytext, 1.); 
<C>Tunisi[ae]  print("Tunisie", 1.);
<C>Tunis      print("Tunis", 1.);
<C>Atlas       print(yytext, 0.5); 
<C>"Anti-Atlas"       print(yytext, 1.5); 
<C>Algiers       print("Alger", 1.); 
<C>Alger       print("Alger", 1.); 
<C>Oran       print("Oran", 1.); 
<C>Maghreb      print("Maghreb", 2.); 
<C>Bou[\- ]Azzer print("Bou-Azzer", 2.); 
<C>Oued      print(yytext, 2.); 
<C>[Dd]jebel print(yytext, 2.); 
<C>\n          BEGIN K;
<C>.       ;
%%
main()
{
   key=malloc(10);
   BEGIN K;
   yylex();
}
...
lex Import/maghrebFilter.lex
gcc lex.yy.c -ll -o bin/maghrebFilter

Test de mise en œuvre

HfdIndexSelect -h $EXPLOR_AREA/Data/Main/Exploration/Title.i  -Sk "cobalt"  \
   | ExplorAddFullText -h Data/Main/Exploration/biblio.hfd -K               \
   | ExplorExtractContent -f kwc                                            \
   | bin/maghrebFilter                                                      \
   | sort                                                                   \
   | SxmlSelect -p @1 -p "@2(@3)"                                           \
   | IndexBuildRec                                                          \
   | SxmlSelect -g idx/f/1 -g idx/k/1 -p @g1 -p @g2                         \
   | sort -rn
Exemple de résultat
8	000609
7	000684
6	001437
5	000814
4	001A31
4	000295
3	000422
2	001D00
2	001754
2	001696
2	001595
2	001088
2	000D20
2	000C11
2	000B95
2	000B93
2	000A43
2	000970
2	000858
2	000606
2	000419
2	000320

Nouveau test

 HfdIndexSelect -h $EXPLOR_AREA/Data/Main/Exploration/Title.i  -Sk "cobalt"   \
   | ExplorAddFullText -h Data/Main/Exploration/biblio.hfd -K     \
   | ExplorExtractContent -f kwc                                  \
   | bin/maghrebFilter                                            \
   | SgmlFast -c2                                                 \
   | sort |                                                      \
   | SxmlCumul -wd                                               \
   | SxmlSelect -g i/w/1 -g i/k/1 -p @g1 -p @g2 | sort -rn
résultat
0030.000	001595
0010.000	001394
0008.000	000609
0007.000	001437
0007.000	000684
0004.500	000814
0004.000	001A31
0004.000	000295
0003.000	001754
0003.000	000888
0003.000	000832
0003.000	000482
0003.000	000445
0003.000	000422
0003.000	000355
0002.000	001D00
0002.000	001696
0002.000	001088
0002.000	000D20
0002.000	000C11
0002.000	000B95
0002.000	000B93
0002.000	000A43
0002.000	000970
0002.000	000858
0002.000	000606
0002.000	000419
0002.000	000320

Test final

HfdIndexSelect -h $EXPLOR_AREA/Data/Main/Exploration/Title.i  -Sk "cobalt"    \
  | ExplorAddFullText -h Data/Main/Exploration/biblio.hfd -K                  \
     | ExplorExtractContent -f kwc                                          \
     | bin/maghrebFilter                     \
    |   SgmlFast -c2                           \
    | sort | SxmlCumul -wd   \
   | SxmlSelect -g i/w/1 -g i/k/1 -p @g1 -p @g2 | sort -rn   \
   | SxmlSelect -p @2 -p @1 | HfdSelect -h $EXPLOR_AREA/Data/Main/Exploration/biblio -i \
  | SxmlSelect -g record/TEI/teiHeader/fileDesc/titleStmt/title/1 \
    -g record/TEI/teiHeader/fileDesc/publicationStmt/idno@type=RBID/1 -p "*[@2] : {{Explor lien
   |wiki=    Wicri/Terre
   |area=    CobaltMaghrebV1
   |flux=    Main
   |étape=   Exploration
   |type=    RBID | clé=@g2 | texte=@g1}}"
Résultat

Sur tout le corpus

time HfdCat Data/Main/Exploration/biblio.hfd | SgmlFast -c2                  \
  | ExplorAddFullText -h Data/Main/Exploration/biblio.hfd -K                  \
     | ExplorExtractContent -f kwc                                          \
     | bin/maghrebFilter                     \
    |   SgmlFast -c2                           \
    | sort | SxmlCumul -wd   \
   | SxmlSelect -g i/w/1 -g i/k/1 -p @g1 -p @g2 | sort -rn   \
   | SxmlSelect -p @2 -p @1 | HfdSelect -h $EXPLOR_AREA/Data/Main/Exploration/biblio -i \
  | SxmlSelect -g record/TEI/teiHeader/fileDesc/titleStmt/title/1 \
    -g record/TEI/teiHeader/fileDesc/publicationStmt/idno@type=RBID/1 -p "*[@2] : {{Explor lien
   |wiki=    Wicri/Terre
   |area=    CobaltMaghrebV1
   |flux=    Main
   |étape=   Exploration
   |type=    RBID | clé=@g2 | texte=@g1}}"
Nouvel essai