séparation de l'auteur
This commit is contained in:
35
dico.php
35
dico.php
@ -1,21 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
const MIN_LETTRES = 0;
|
const MIN_LETTRES_MOT_1 = 2;
|
||||||
|
const MIN_LETTRES_MOT_2 = 0;
|
||||||
const MAX_MOTS = 100000;
|
const MAX_MOTS = 100000;
|
||||||
|
|
||||||
|
|
||||||
$dico = [];
|
$dico = [];
|
||||||
if (($handle = fopen("dico.csv", "r")) !== FALSE) {
|
if (($lecteur = fopen("dico.csv", "r")) !== FALSE) {
|
||||||
$header = fgetcsv($handle, 0, "\t");
|
$header = fgetcsv($lecteur, 0, "\t");
|
||||||
while (($ligne = fgetcsv($handle, 0, "\t")) !== FALSE) {
|
while (($ligne = fgetcsv($lecteur, 0, "\t")) !== FALSE) {
|
||||||
if (count($ligne) >= 2) {
|
if (substr($ligne[0], 0, 1) != "#" && count($ligne) >= 3) {
|
||||||
$mot = $ligne[0];
|
[$mot, $definition, $auteur] = $ligne;
|
||||||
$definition = $ligne[1];
|
if ($auteur) {
|
||||||
$dico[$mot] = $definition;
|
$dico[$mot] = "$definition <small><em>$auteur</em></small>";
|
||||||
|
} else {
|
||||||
|
$dico[$mot] = $definition;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose($handle);
|
fclose($lecteur);
|
||||||
}
|
}
|
||||||
|
|
||||||
$mots_de_n_lettres = [];
|
$mots_de_n_lettres = [];
|
||||||
@ -37,25 +41,26 @@ function fisherYatesShuffle(&$items)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mots_espaces($longueur) {
|
function mots_espaces($longueur)
|
||||||
|
{
|
||||||
global $mots_de_n_lettres;
|
global $mots_de_n_lettres;
|
||||||
global $dico;
|
global $dico;
|
||||||
|
|
||||||
$nb_mots = 0;
|
$nb_mots = 0;
|
||||||
fisherYatesShuffle($mots_de_n_lettres[$longueur]);
|
fisherYatesShuffle($mots_de_n_lettres[$longueur]);
|
||||||
foreach($mots_de_n_lettres[$longueur] as $mot) {
|
foreach ($mots_de_n_lettres[$longueur] as $mot) {
|
||||||
yield $mot;
|
yield $mot;
|
||||||
if (++$nb_mots > MAX_MOTS) {
|
if (++$nb_mots > MAX_MOTS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for ($i = 2; $longueur - $i - 1 >= MIN_LETTRES; $i++) {
|
for ($i = MIN_LETTRES_MOT_1; $longueur - $i - 1 >= MIN_LETTRES_MOT_2; $i++) {
|
||||||
foreach ($mots_de_n_lettres[$i] as $mot1) {
|
foreach ($mots_de_n_lettres[$i] as $mot1) {
|
||||||
foreach (mots_espaces($longueur - $i - 1) as $mot2) {
|
foreach (mots_espaces($longueur - $i - 1) as $mot2) {
|
||||||
if ($mot1 != $mot2) {
|
if ($mot1 != $mot2) {
|
||||||
$dico["$mot1 $mot2"] = $dico[$mot1] && $dico[$mot2] ? "{$dico[$mot1]}<br/>{$dico[$mot2]}." : $dico[$mot1] . $dico[$mot2];
|
$dico["$mot1 $mot2"] = $dico[$mot1] && $dico[$mot2] ? "<ol><li>{$dico[$mot1]}</li><li>{$dico[$mot2]}</li></ol>" : $dico[$mot1] . $dico[$mot2];
|
||||||
yield "$mot1 $mot2";
|
yield "$mot1 $mot2";
|
||||||
$dico["$mot2 $mot1"] = $dico[$mot2] && $dico[$mot1] ? "{$dico[$mot2]}<br/>{$dico[$mot1]}." : $dico[$mot2] . $dico[$mot1];
|
$dico["$mot2 $mot1"] = $dico[$mot2] && $dico[$mot1] ? "<ol><li>{$dico[$mot2]}</li><li>{$dico[$mot1]}</li></ol>" : $dico[$mot2] . $dico[$mot1];
|
||||||
yield "$mot2 $mot1";
|
yield "$mot2 $mot1";
|
||||||
$nb_mots += 2;
|
$nb_mots += 2;
|
||||||
if ($nb_mots > MAX_MOTS) {
|
if ($nb_mots > MAX_MOTS) {
|
||||||
@ -65,4 +70,4 @@ function mots_espaces($longueur) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
style.css
14
style.css
@ -95,10 +95,22 @@ table.grille {
|
|||||||
width: 45%;
|
width: 45%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.definitions li::marker {
|
.definitions ol {
|
||||||
|
padding-left: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.definitions > div > ol > li::marker {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.definitions li ol {
|
||||||
|
padding-left: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.definitions li li::marker {
|
||||||
|
font-size: small;
|
||||||
|
}
|
||||||
|
|
||||||
button[type='submit'] {
|
button[type='submit'] {
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
Reference in New Issue
Block a user