diff --git a/outils/stats-corpus/statsCorpus.pl b/outils/stats-corpus/statsCorpus.pl index b3b4bce..216f9eb 100755 --- a/outils/stats-corpus/statsCorpus.pl +++ b/outils/stats-corpus/statsCorpus.pl @@ -17,14 +17,14 @@ my $substitut = " " x length($programme); my $usage = "Usage : \n" . - " $programme -l logfile -c fichier.corpus [ -r répertoireXML ] [ -s sortie ] \n" . + " $programme -l logfile -c fichier.corpus [ -r répertoire_XML ] [ -s sortie ] \n" . " $substitut [ -f (csv|json|tsv) ] [ -x (normal|lodex) ] \n" . - " $programme -m répertoireJSON [ -r répertoireXML ] [ -s sortie ] \n" . + " $programme -m répertoire_JSON [ -r répertoire_XML ] [ -s sortie ] \n" . " $substitut [ -f (csv|json|tsv) ] [ -x (normal|lodex) ] \n". " $programme -h \n"; -my $version = "3.6.0"; -my $dateModif = "7 Décembre 2018"; +my $version = "3.7.1"; +my $dateModif = "24 Janvier 2019"; # Variables pour les options my $aide = 0; @@ -189,7 +189,7 @@ "Catégories INIST" => "nb", ); -if ( $xtended ) { +if ( $xtended eq 'lodex' ) { @champs = ("Nom de fichier", "Titre", "Auteur(s)", "Affiliation(s)", "Revue ou monographie", "ISSN", "e-ISSN", "ISBN", "e-ISBN", "Éditeur", "Type de publication", "Type de document", @@ -208,6 +208,18 @@ "Catégories Scopus", "Catégories INIST"); } +# Liste des champs à traiter en champs JSON simples pour Lodex +my %simple = ( + "Type de publication" => 1, + "Type de document" => 1, + "PMID" => 1, + "DOI" => 1, + "ISSN" => 1, + "e-ISSN" => 1, + "ISBN" => 1, + "e-ISBN" => 1, + ); + my $entete = join("\t", @champs); if ( $type eq "csv" ) { print OUT "\x{FEFF}" . tsv2csv($entete) . "\n"; @@ -588,7 +600,7 @@ } } -if ( $xtended ) { +if ( $xtended eq 'lodex' ) { # Variables spécifiques à l'affichage étendu my $auteurs = ""; my $affiliations = ""; @@ -596,7 +608,7 @@ my $resume = ""; my $motscles = ""; my $doi = ""; - my $pmid = " "; + my $pmid = ""; if ( $hit{'author'} ) { my @authors = @{$hit{'author'}}; my @names = (); @@ -795,6 +807,25 @@ my $valeur = shift @valeurs; if ( ref($valeur) eq 'ARRAY' ) { my @niv1 = @{$valeur}; + if ( $xtended eq 'lodex' and $simple{$champ} ) { + if ( $#niv1 < 0 ) { + print OUT " \"$champ\": null"; + } + else { + my $items = join(" ; ", @niv1); + if ( $items =~ /^[-+]? ?\d+(\.\d+)?\z/o ) { + print OUT " \"$champ\": $items"; + } + else { + $items =~ s/\\/\\\\/go; + $items =~ s/"/\\"/go; + print OUT " \"$champ\": \"$items\""; + } + } + print OUT "," if $nb --; + print OUT "\n"; + next; + } if ( $#niv1 < 0 ) { print OUT " \"$champ\": []", $nb -- ? "," : "", "\n"; next;