From 63ada9239a794599c1f46ddd07ad0a3f206af452 Mon Sep 17 00:00:00 2001 From: Mysaa Date: Sat, 16 Oct 2021 17:44:32 +0200 Subject: [PATCH 1/3] Ajout de TNTSearch. Faut coder maintenant ... --- .gitignore | 1 + .gitmodules | 3 +++ api/request.php | 12 +++++++++++- api/tntsearch | 1 + api/updateIndexes.php | 40 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .gitmodules create mode 160000 api/tntsearch create mode 100644 api/updateIndexes.php diff --git a/.gitignore b/.gitignore index 4db36b5..4d5ee19 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ svg-pan-zoom.min.js tinycolor-min.js api/dbinit.php +api/sallesNoms.index diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..993eaa6 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "api/tntsearch"] + path = api/tntsearch + url = git@github.com:teamtnt/tntsearch.git diff --git a/api/request.php b/api/request.php index 48473aa..1be68e5 100644 --- a/api/request.php +++ b/api/request.php @@ -1,14 +1,24 @@ loadConfig($tntconfig); +$indexer = $tnt->createIndex('tntsearch/sallesNoms.index'); +$indexer->query('SELECT id, nom FROM sallesAlias;'); +$indexer->setLanguage('french'); +$indexer->run(); if(isset($_GET["salle"])) { @@ -57,7 +67,7 @@ if(isset($_GET["salle"])) { } else if (isset($_GET["research"])) { $research = $_GET["research"]; - $stmt = $conn->prepare("SELECT salleID, nom FROM salleAlias WHERE MATCH nom AGAINST (? IN BOOLEAN MODE)"); + $stmt = $conn->prepare("SELECT salleID, nom FROM salleAlias WHERE MATCH nom AGAINST (? IN BOOLEAN MODE)"); $stmt->execute([$research]); $res = $stmt->fetchAll(); diff --git a/api/tntsearch b/api/tntsearch new file mode 160000 index 0000000..1fd7b79 --- /dev/null +++ b/api/tntsearch @@ -0,0 +1 @@ +Subproject commit 1fd7b79467dffe141de3691942d11127a21c2cbd diff --git a/api/updateIndexes.php b/api/updateIndexes.php new file mode 100644 index 0000000..026de49 --- /dev/null +++ b/api/updateIndexes.php @@ -0,0 +1,40 @@ +loadConfig($tntconfig); + +$indexer = $tnt->createIndex('sallesNoms.index'); +$indexer->query('SELECT ID, nom FROM salleAlias;'); +$indexer->setLanguage('french'); +$indexer->setPrimaryKey('ID'); +$indexer->run(); + +echo "Mise à jour de l'index faite avec succès !"; From 77d33a21f6ff22ff95a67e373c21542cdd53b1f8 Mon Sep 17 00:00:00 2001 From: Mysaa Date: Sat, 16 Oct 2021 21:10:09 +0200 Subject: [PATCH 2/3] =?UTF-8?q?L'api=20de=20recherche=20est=20maintenant?= =?UTF-8?q?=20fonctionelle,=20jusqu'au=20nouveaux=20bugs=20d=C3=A9couverts?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/request.php | 81 ++++++++++++++++++++++-------------------- api/setupTntsearch.php | 23 ++++++++++++ api/updateIndexes.php | 32 +++-------------- 3 files changed, 71 insertions(+), 65 deletions(-) create mode 100644 api/setupTntsearch.php diff --git a/api/request.php b/api/request.php index 1be68e5..2df4caf 100644 --- a/api/request.php +++ b/api/request.php @@ -1,24 +1,13 @@ loadConfig($tntconfig); - -$indexer = $tnt->createIndex('tntsearch/sallesNoms.index'); -$indexer->query('SELECT id, nom FROM sallesAlias;'); -$indexer->setLanguage('french'); -$indexer->run(); +include_once 'dbinit.php'; if(isset($_GET["salle"])) { @@ -64,35 +53,51 @@ if(isset($_GET["salle"])) { echo (json_encode($out)); } -} else if (isset($_GET["research"])) { - $research = $_GET["research"]; - - $stmt = $conn->prepare("SELECT salleID, nom FROM salleAlias WHERE MATCH nom AGAINST (? IN BOOLEAN MODE)"); - $stmt->execute([$research]); - $res = $stmt->fetchAll(); - +} else if (isset($_GET["search"])) { + $searchText = $_GET["search"]; + $rescount = isset($_GET["rescount"])?$_GET["rescount"]:7; + + include_once 'setupTntsearch.php'; + + $tnt->selectIndex("salleSearch.index"); + $tnt->fuzziness = true; + $tnt->fuzzy_prefix_length = 2; + $tnt->fuzzy_max_expansions = 50; + $tnt->fuzzy_distance = 2; //represents the Levenshtein distance; + + $res = $tnt->search($searchText,$rescount); + $out = array(); + + for($i=0; $iprepare("SELECT nom FROM salleAlias WHERE salleID=?"); + $stmt->execute([$theid]); + $resS = $stmt->fetchAll(); + + $nomz = array(); + for($j=0;$j $res[$i]['salleID'], "name" => $res[$i]["nom"]); - + $out[$theid] = array('noms' => $nomz); + } + + for($i=0; $iprepare("SELECT personne FROM locataires WHERE salleID=?"); + $stmt->execute([$theid]); + $resL = $stmt->fetchAll(); + + $locatairez = array(); + for($j=0;$jprepare("SELECT salleID, personne FROM `locataires` WHERE MATCH personne AGAINST (? IN BOOLEAN MODE)"); - $stmt->execute([$salleLocSearch]); - $res = $stmt->fetchAll(); - - $out = array(); - - for($i=0;$i $res[$i]['salleID'], "personne" => $res[$i]["personne"]); - - echo (json_encode($out)); - -}else { +} else { echo "Je ne connais pas cette commande ..."; } diff --git a/api/setupTntsearch.php b/api/setupTntsearch.php new file mode 100644 index 0000000..25d384f --- /dev/null +++ b/api/setupTntsearch.php @@ -0,0 +1,23 @@ + loadConfig($tntconfig); diff --git a/api/updateIndexes.php b/api/updateIndexes.php index 026de49..9b06e5d 100644 --- a/api/updateIndexes.php +++ b/api/updateIndexes.php @@ -4,37 +4,15 @@ ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); -set_include_path(get_include_path() . PATH_SEPARATOR . './tntsearch/src/'); -use TeamTNT\TNTSearch\TNTSearch; -use TeamTNT\TNTSearch\Support; - -include_once 'TNTSearch.php'; -include_once 'Support/AbstractTokenizer.php'; -include_once 'Support/TokenizerInterface.php'; -include_once 'Support/Tokenizer.php'; -include_once 'Support/Collection.php'; -include_once 'FileReaders/FileReaderInterface.php'; -include_once 'FileReaders/TextFileReader.php'; -include_once 'Indexer/TNTIndexer.php'; -include_once 'Stemmer/Stemmer.php'; -include_once 'Stemmer/FrenchStemmer.php'; -include_once 'Stemmer/NoStemmer.php'; -include_once 'Connectors/ConnectorInterface.php'; -include_once 'Connectors/Connector.php'; -include_once 'Connectors/MySqlConnector.php'; - -$tnt = new TNTSearch; - // Se connecte à la BDD (identifiants cachés) // Charge les paramètres de tnt dans $tntconfig -include 'dbinit.php'; +include_once 'dbinit.php'; +include_once 'setupTntsearch.php'; -$tnt->loadConfig($tntconfig); - -$indexer = $tnt->createIndex('sallesNoms.index'); -$indexer->query('SELECT ID, nom FROM salleAlias;'); +$indexer = $tnt->createIndex('salleSearch.index'); +$indexer->query('(SELECT salleId AS id, nom AS searchText FROM salleAlias) UNION (SELECT salleId AS id, personne AS searchText FROM locataires)'); $indexer->setLanguage('french'); -$indexer->setPrimaryKey('ID'); $indexer->run(); +echo "
"; echo "Mise à jour de l'index faite avec succès !"; From 23bf37ed490994bc072f2289cb748bf8e8afc5f2 Mon Sep 17 00:00:00 2001 From: Mysaa Date: Tue, 26 Oct 2021 23:14:21 +0200 Subject: [PATCH 3/3] =?UTF-8?q?Fin=20de=20l'=C3=A9tage=204=20(ouf=20...).?= =?UTF-8?q?=20Reste=20=C3=A0=20lier=20les=20salles=20sur=20plusieurs=20?= =?UTF-8?q?=C3=A9tages.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maps/M-MGN1-4.svg | 10874 ++++++++------------------------------------ 1 file changed, 1860 insertions(+), 9014 deletions(-) diff --git a/maps/M-MGN1-4.svg b/maps/M-MGN1-4.svg index 3b99678..c1ab044 100644 --- a/maps/M-MGN1-4.svg +++ b/maps/M-MGN1-4.svg @@ -12,11 +12,12 @@ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.1" id="svg2" - width="1118" - height="3398" - viewBox="0 0 1118 3398" - sodipodi:docname="et4.svg" - inkscape:version="0.92.4 (5da689c313, 2019-01-14)"> + width="3398.0325" + height="1122.184" + viewBox="0 0 3398.0325 1122.184" + sodipodi:docname="M-MGN1-4.svg" + inkscape:version="0.92.4 (5da689c313, 2019-01-14)" + inkscape:label="all"> @@ -44,9021 +45,1866 @@ inkscape:window-height="983" id="namedview4" showgrid="false" - inkscape:zoom="1.5715334" - inkscape:cx="104.41713" - inkscape:cy="2649.6458" + inkscape:zoom="0.27781048" + inkscape:cx="1764.4061" + inkscape:cy="330.83209" inkscape:window-x="1680" inkscape:window-y="0" inkscape:window-maximized="1" - inkscape:current-layer="svg2" /> + inkscape:current-layer="salles-group" + fit-margin-top="0" + fit-margin-left="0" + fit-margin-right="0" + fit-margin-bottom="0" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + x="3.0495999" + y="-3398.0327" + transform="rotate(90)" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +