nombre de mots
This commit is contained in:
parent
ddebd453df
commit
ca39709fbd
24
dico.php
24
dico.php
@ -6,10 +6,16 @@ const MIN_PREMIER_MOT = 1;
|
|||||||
const MIN_MOTS_SUIVANTS = 1;
|
const MIN_MOTS_SUIVANTS = 1;
|
||||||
|
|
||||||
|
|
||||||
|
$nb_mots = 0;
|
||||||
|
|
||||||
function dico($longueur_max) {
|
function dico($longueur_max) {
|
||||||
|
global $nb_mots;
|
||||||
|
|
||||||
|
$transliterator = Transliterator::createFromRules(':: Any-Latin; :: Latin-ASCII; :: NFD; :: [:Nonspacing Mark:] Remove; :: Upper(); :: NFC;', Transliterator::FORWARD);
|
||||||
|
|
||||||
$dico = [[""]];
|
$dico = [[""]];
|
||||||
if (($lecteur = fopen("dico.csv", "r")) !== FALSE) {
|
if (($lecteur = fopen("dico.csv", "r")) !== FALSE) {
|
||||||
$header = fgetcsv($lecteur, 0, "\t");
|
$entete = fgetcsv($lecteur, 0, "\t");
|
||||||
while (($ligne = fgetcsv($lecteur, 0, "\t")) !== FALSE) {
|
while (($ligne = fgetcsv($lecteur, 0, "\t")) !== FALSE) {
|
||||||
if (
|
if (
|
||||||
$ligne[0] == NULL
|
$ligne[0] == NULL
|
||||||
@ -31,7 +37,17 @@ function dico($longueur_max) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mot = strtoupper($mot);
|
$mot = $ligne[0];
|
||||||
|
$definitions = array_slice($ligne, 1);
|
||||||
|
|
||||||
|
$mot = $transliterator->transliterate($mot);
|
||||||
|
if (strpos($mot, " ") !== false) {
|
||||||
|
$mots = explode(" ", $mot);
|
||||||
|
$nb_mot = count($mots);
|
||||||
|
$mot = implode("", $mots);
|
||||||
|
$definition .= " ($nb_mot mots)";
|
||||||
|
}
|
||||||
|
|
||||||
$longueur = strlen($mot);
|
$longueur = strlen($mot);
|
||||||
if (!isset($dico[$longueur])) $dico[$longueur] = new Trie();
|
if (!isset($dico[$longueur])) $dico[$longueur] = new Trie();
|
||||||
if (!isset($dico[$longueur][$mot])) $dico[$longueur][$mot] = [];
|
if (!isset($dico[$longueur][$mot])) $dico[$longueur][$mot] = [];
|
||||||
@ -44,9 +60,9 @@ function dico($longueur_max) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mots_espaces($longueur_max) {
|
function mots_espaces($longueur_max) {
|
||||||
$dico = dico($longueur_max);
|
global $nb_mots;
|
||||||
|
|
||||||
$_tries = [[]];
|
$dico = dico($longueur_max);
|
||||||
for ($longueur = 1; $longueur <= $longueur_max; $longueur++) {
|
for ($longueur = 1; $longueur <= $longueur_max; $longueur++) {
|
||||||
for ($position_espace = MIN_PREMIER_MOT; $position_espace + MIN_MOTS_SUIVANTS < $longueur; $position_espace++) {
|
for ($position_espace = MIN_PREMIER_MOT; $position_espace + MIN_MOTS_SUIVANTS < $longueur; $position_espace++) {
|
||||||
$mots_suivants = $dico[$longueur - $position_espace - 1];
|
$mots_suivants = $dico[$longueur - $position_espace - 1];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user