page d'exploration des fichiers d'un corpus : extraction 1ère et dernière ligne des fichiers jsonl
This commit is contained in:
parent
75744f6302
commit
21e0793c54
2 changed files with 107 additions and 0 deletions
71
content/mouline_corpus.html
Normal file
71
content/mouline_corpus.html
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
<h1>Liste des fichiers disponibles</h1>
|
||||||
|
<div class="la_une">
|
||||||
|
<ul>
|
||||||
|
<BOUCLE_corpus(DATA){source ls, #CHEMIN{tmp}/corpus/*}{par basename}>
|
||||||
|
<li>
|
||||||
|
#SET{liste_lignes,#LISTE{1}}
|
||||||
|
#SET{nb_lignes, #FILE|nombre_ligne} [(#GET{nb_lignes}|!={1}|oui) #SET{liste_lignes,#LISTE{1,#GET{nb_lignes}}}]
|
||||||
|
<h3 class="spip">[(#FILE|basename)] : [(#GET{nb_lignes}) [(#GET{nb_lignes}|singulier_ou_pluriel{page,pages})]]</h3>
|
||||||
|
<BOUCLE_2lignes(DATA){liste #GET{liste_lignes}}>
|
||||||
|
<div>
|
||||||
|
<h4 class="aff_masq">Ligne #VALEUR:</h4>
|
||||||
|
<div class="details">
|
||||||
|
[(#SET{content,[(#FILE|affiche_ligne{1}|json_decode{true})]})]
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<div class="aff_masq">Contenu brut :</div>
|
||||||
|
<textarea class="details">[(#FILE|affiche_ligne{1})]</textarea>
|
||||||
|
</li>
|
||||||
|
<BOUCLE_content(DATA){source table, #GET{content}}>
|
||||||
|
<li>
|
||||||
|
[(#CLE|=={htmlBytes}|oui)
|
||||||
|
<div class="aff_masq">[(#CLE)] = HTML de la page : </div>
|
||||||
|
<div class="details js-hidden">
|
||||||
|
<textarea>[(#VALEUR|base64_decode|replace{<,<}|replace{>,>})]</textarea>
|
||||||
|
</div>
|
||||||
|
]
|
||||||
|
[(#CLE|=={htmlBytes}|non)
|
||||||
|
<div class="aff_masq">[(#CLE)] : </div>
|
||||||
|
<div class="details">
|
||||||
|
[(#VALEUR|print|replace{<,<}|replace{>,>})]
|
||||||
|
</div>
|
||||||
|
]
|
||||||
|
</li>
|
||||||
|
</BOUCLE_content>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</BOUCLE_2lignes>
|
||||||
|
</li>
|
||||||
|
</BOUCLE_corpus>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
jQuery(function () {
|
||||||
|
$('.aff_masq').each(function() {
|
||||||
|
$(this).siblings('.details').toggleClass('js-hidden');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.aff_masq').on('click', function() {
|
||||||
|
$(this).siblings('.details').toggleClass('js-hidden');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style type="text/css" media="screen">
|
||||||
|
.aff_masq {
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.aff_masq:hover {
|
||||||
|
background-color: #DDD;
|
||||||
|
}
|
||||||
|
.details br:first-of-type {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
textarea {
|
||||||
|
width: 100%;
|
||||||
|
height: 200px;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -12,3 +12,39 @@
|
||||||
if (!defined('_ECRIRE_INC_VERSION')) {
|
if (!defined('_ECRIRE_INC_VERSION')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function nombre_ligne($fichier) {
|
||||||
|
if (!file_exists($fichier)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$num_ligne = 0;
|
||||||
|
$handle = @fopen($fichier, "rb");
|
||||||
|
if ($handle) {
|
||||||
|
while (($buffer = fgets($handle)) !== false) {
|
||||||
|
$num_ligne = $num_ligne + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $num_ligne;
|
||||||
|
}
|
||||||
|
|
||||||
|
function affiche_ligne($fichier, $num) {
|
||||||
|
if (!file_exists($fichier)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$handle = @fopen($fichier, "rb");
|
||||||
|
if ($handle) {
|
||||||
|
while (($buffer = fgets($handle)) !== false) {
|
||||||
|
$num_ligne = $num_ligne + 1;
|
||||||
|
if ($num_ligne == $num) {
|
||||||
|
return $buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!feof($handle)) {
|
||||||
|
echo "Erreur: fgets() a échoué\n";
|
||||||
|
}
|
||||||
|
fclose($handle);
|
||||||
|
}
|
||||||
|
return 'Erreur : nombre de lignes du fichier '.$fichier.' inférieur à '.$num;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue