Commit c0a34611 authored by Arnaud Bey's avatar Arnaud Bey
Browse files

WIP

parent 3be8aad5
......@@ -33,5 +33,6 @@ application/web/upload/profilepic/*
!application/web/upload/profilepic/.gitkeep
application/web/files/*
!aplication/web/files/.gitkeep
application/data/
application/data/lexicons/*
!application/data/lexicons/.gitkeep
*.php~
......@@ -8,6 +8,7 @@ imports:
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
profilepic_directory: '%kernel.root_dir%/../web/upload/profilepic'
languageDir: '%kernel.project_dir%'
framework:
#esi: ~
......
centile;nombre de grilles;formes par grilles;lemmes par grille;lemmes distincts;combos par grille;Taille moyenne combo
0;2000;268;208;23857;83;2.73
10;2000;262;204;23429;81;2.73
100;2000;150;98;242;51;3.15
20;2000;269;208;23583;84;2.75
30;2000;266;207;23407;83;2.73
40;2000;266;206;23137;84;2.73
50;2000;268;208;23503;84;2.74
60;2000;270;208;23361;85;2.74
70;2000;277;214;23379;86;2.75
80;2000;292;220;22679;92;2.77
83;2000;296;221;22031;95;2.78
85;2000;298;222;21485;95;2.79
88;2000;306;222;18001;99;2.82
90;2000;315;224;17335;102;2.85
93;2000;316;219;12405;103;2.9
95;2000;326;216;6766;108;2.93
......@@ -40,7 +40,7 @@
"argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
"integrity": "sha1-vNZ5HqWuCXJeF+WtmIE0zUCz2RE=",
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
"requires": {
"sprintf-js": "~1.0.2"
}
......@@ -151,7 +151,7 @@
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha1-PH/L9SnYcibz0vUrlm/1Jx60Qd0=",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
......@@ -264,7 +264,7 @@
"concat-stream": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz",
"integrity": "sha1-kEvfGUzTEi/Gdcd/xKw9T/D9GjQ=",
"integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==",
"requires": {
"buffer-from": "^1.0.0",
"inherits": "^2.0.3",
......@@ -366,7 +366,7 @@
"errno": {
"version": "0.1.7",
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz",
"integrity": "sha1-RoTXF3mtOa8Xfj8AeZb3xnyFJhg=",
"integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==",
"optional": true,
"requires": {
"prr": "~1.0.1"
......@@ -506,7 +506,7 @@
"function-bind": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
"integrity": "sha1-pWiZ0+o8m6uHS7l3O3xe3pL0iV0="
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
},
"gaze": {
"version": "1.1.3",
......@@ -835,7 +835,7 @@
"iconv-lite": {
"version": "0.4.23",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz",
"integrity": "sha1-KXhx9jvlB63Pv8pxXQzQ7thOmmM=",
"integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==",
"requires": {
"safer-buffer": ">= 2.1.2 < 3"
}
......@@ -876,7 +876,7 @@
"is-buffer": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
"integrity": "sha1-76ouqdqg16suoTqXsritUf776L4="
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
},
"is-builtin-module": {
"version": "1.0.0",
......@@ -1114,7 +1114,7 @@
"minimatch": {
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"requires": {
"brace-expansion": "^1.1.7"
}
......@@ -1297,7 +1297,7 @@
"process-nextick-args": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
"integrity": "sha1-o31zL0JxtKsa0HDTVQjoKQeI/6o="
"integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw=="
},
"promise": {
"version": "7.3.1",
......@@ -1462,7 +1462,7 @@
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha1-mR7GnSluAxN0fVm9/St0XDX4go0="
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"safe-json-parse": {
"version": "1.0.1",
......@@ -1473,7 +1473,7 @@
"safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha1-RPoWGwGHuVSd2Eu5GAL5vYOFzWo="
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"screenfull": {
"version": "3.3.2",
......@@ -1521,7 +1521,7 @@
"spdx-expression-parse": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz",
"integrity": "sha1-meEZt6XaAOBUkcn6M4t5BII7QdA=",
"integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==",
"requires": {
"spdx-exceptions": "^2.1.0",
"spdx-license-ids": "^3.0.0"
......@@ -1736,7 +1736,7 @@
"websocket-extensions": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/websocket-extensions/-/websocket-extensions-0.1.3.tgz",
"integrity": "sha1-XS/yKXcAPsaHpLhwc9+7rBRszyk=",
"integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==",
"dev": true
},
"which": {
......
......@@ -3,14 +3,12 @@
namespace LexiconBundle\Command;
use LexiconBundle\Manager\ImportManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
class ImportLexiconCommand extends Command
class ImportLexiconCommand extends ContainerAwareCommand
{
protected function configure()
{
......@@ -20,19 +18,14 @@ class ImportLexiconCommand extends Command
->addArgument('directory', InputArgument::REQUIRED, 'name of directory in application/data/lexicons');
}
public function __construct(ImportManager $im)
{
$this->im = $im;
parent::__construct();
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$pathLexiconDir = $input->getArgument('directory');
if ($pathLexiconDir) {
echo 'You passed an argument: ' . $pathLexiconDir;
$this->im->importLexicon($pathLexiconDir);
echo 'You passed an argument: ' . $pathLexiconDir . "\n\n";
$importManager = $this->getContainer()->get('lexicon_manager.import');
$importManager->importLexicon($pathLexiconDir);
} else {
echo 'Argument missing';
}
......
......@@ -7,6 +7,7 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="lexicon_feature")
* @ORM\Entity(repositoryClass="LexiconBundle\Repository\FeatureRepository")
*/
class Feature
......
......@@ -8,7 +8,8 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="LexiconBundle\Repository\LanguageRepository")
* @ORM\Table(name="lexicon_language")
* @ORM\Entity()
*/
class Language
{
......
......@@ -6,6 +6,7 @@ use MagicWordBundle\Entity\Rules\LetterPoints;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="lexicon_letter")
* @ORM\Entity(repositoryClass="LexiconBundle\Repository\LetterRepository")
*/
class Letter
......
......@@ -7,6 +7,7 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="lexicon_root")
* @ORM\Entity(repositoryClass="LexiconBundle\Repository\RootRepository")
*/
class Root
......
......@@ -7,6 +7,7 @@ use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="lexicon_word")
* @ORM\Entity(repositoryClass="LexiconBundle\Repository\WordRepository")
*/
class Word
......
......@@ -6,7 +6,7 @@ use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Index;
/**
* @ORM\Table(name="word_start", indexes={
* @ORM\Table(name="lexicon_word_start", indexes={
* @Index(columns={"value"}, flags={"fulltext"}),
* @Index(name="language", columns={"language"}),
* })
......
......@@ -2,13 +2,17 @@
namespace LexiconBundle\Manager;
use Doctrine\ORM\EntityManagerInterface;
use JMS\DiExtraBundle\Annotation as DI;
use LexiconBundle\Entity\Language;
use LexiconBundle\Manager\WordManager;
use LexiconBundle\Manager\LetterManager;
use LexiconBundle\Manager\WordManager;
use MagicWordBundle\Manager\Rules\WordLengthManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
/**
* @DI\Service("lexicon_manager.bigram")
*/
class BigramManager
{
public function generateBigrams($bigrams, $pathLexiconDir)
......
......@@ -3,14 +3,23 @@
namespace LexiconBundle\Manager;
use Doctrine\ORM\EntityManagerInterface;
use App\Entity\Lexicon\Feature;
use App\Entity\Lexicon\Language;
use LexiconBundle\Entity\Feature;
use LexiconBundle\Entity\Language;
use JMS\DiExtraBundle\Annotation as DI;
/**
* @DI\Service("lexicon_manager.feature")
*/
class FeatureManager
{
private $em;
public function __construct(EntityManagerInterface $em)
/**
* @DI\InjectParams({
* "em" = @DI\Inject("doctrine.orm.entity_manager"),
* })
*/
public function __construct($em)
{
$this->em = $em;
}
......
......@@ -2,18 +2,16 @@
namespace LexiconBundle\Manager;
use JMS\DiExtraBundle\Annotation as DI;
use LexiconBundle\Entity\Language;
use LexiconBundle\Manager\BigramManager;
use LexiconBundle\Manager\LetterManager;
use LexiconBundle\Manager\WordManager;
use MagicWordBundle\Manager\Rules\WordLengthManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Stopwatch\Stopwatch;
/**
* @DI\Service("lexicon_manager.import")
*/
class ImportManager
{
private $params;
private $dir;
private $wm;
private $fm;
private $lm;
......@@ -23,23 +21,35 @@ class ImportManager
private $letterm;
private $bgm;
public function __construct(ParameterBagInterface $params, WordManager $wm, FeatureManager $fm, LanguageManager $lm, RootManager $rm, WordLengthManager $wlm, EntityManagerInterface $em, LetterManager $letterm, BigramManager $bgm)
/**
* @DI\InjectParams({
* "dir" = @DI\Inject("%languageDir%"),
* "em" = @DI\Inject("doctrine.orm.entity_manager"),
* "wm" = @DI\Inject("lexicon_manager.word"),
* "fm" = @DI\Inject("lexicon_manager.feature"),
* "lm" = @DI\Inject("lexicon_manager.language"),
* "rm" = @DI\Inject("lexicon_manager.root"),
* "bgm" = @DI\Inject("lexicon_manager.bigram"),
* "letterm" = @DI\Inject("lexicon_manager.letter"),
* "wlm" = @DI\Inject("mw_manager.wordLength"),
* })
*/
public function __construct($dir, $em, $wm, $fm, $lm, $rm, $wlm, $bgm, $letterm)
{
$this->params = $params;
$this->dir = $dir;
$this->em = $em;
$this->wm = $wm;
$this->fm = $fm;
$this->lm = $lm;
$this->rm = $rm;
$this->wlm = $wlm;
$this->em = $em;
$this->letterm = $letterm;
$this->bgm = $bgm;
$this->letterm = $letterm;
$this->wlm = $wlm;
}
public function importLexicon($pathLexiconDir)
{
$route = $this->params->get('projectDir');
$pathLexiconDir = $route.DIRECTORY_SEPARATOR."data/lexicons".DIRECTORY_SEPARATOR.$pathLexiconDir;
$pathLexiconDir = $this->dir.DIRECTORY_SEPARATOR."data/lexicons".DIRECTORY_SEPARATOR.$pathLexiconDir;
// Gestion des specs
$pathFileSpec = $pathLexiconDir.DIRECTORY_SEPARATOR."spec.txt";
......@@ -112,7 +122,6 @@ class ImportManager
{
$this->em->getConnection()->getConfiguration()->setSQLLogger(null);
$language = $specs["language"];
$weights = $specs["weights"];
$lengths = $specs["lengths"];
......@@ -143,7 +152,6 @@ class ImportManager
//$cleanWordValue = preg_replace("/\P{L}/", "", $cleanWordValue);#bug pour le russe
$cleanWordValue = mb_eregi_replace("/\P{L}/", "", $cleanWordValue);#fonctionne pour le russe
$string2print.=" / EREGI = ".$cleanWordValue."\n";
// file_put_contents("logcleanvalue.txt", $string2print, FILE_APPEND);
// Gestion de la root
$root = $this->rm->findOrCreate($language, $rootValue, $roots);
// Gestion des points
......@@ -192,7 +200,7 @@ class ImportManager
$event = $stopwatch->stop($stopwatchName);
$stopwatchName = uniqid();
echo "max memory > " . $event->getMemory()/1048576 . " MB \n";
echo "duration > " . $event->getDuration()/1000 . " seconds \n";
echo "duration > " . $event->getDuration()/1000 . " seconds \n\n";
$stopwatch->start($stopwatchName);
}
}
......
......@@ -4,12 +4,21 @@ namespace LexiconBundle\Manager;
use Doctrine\ORM\EntityManagerInterface;
use LexiconBundle\Entity\Language;
use JMS\DiExtraBundle\Annotation as DI;
/**
* @DI\Service("lexicon_manager.language")
*/
class LanguageManager
{
private $em;
public function __construct(EntityManagerInterface $em)
/**
* @DI\InjectParams({
* "em" = @DI\Inject("doctrine.orm.entity_manager"),
* })
*/
public function __construct($em)
{
$this->em = $em;
}
......
......@@ -5,12 +5,21 @@ namespace LexiconBundle\Manager;
use Doctrine\ORM\EntityManagerInterface;
use LexiconBundle\Entity\Letter;
use LexiconBundle\Entity\Language;
use JMS\DiExtraBundle\Annotation as DI;
/**
* @DI\Service("lexicon_manager.letter")
*/
class LetterManager
{
private $em;
public function __construct(EntityManagerInterface $em)
/**
* @DI\InjectParams({
* "em" = @DI\Inject("doctrine.orm.entity_manager"),
* })
*/
public function __construct($em)
{
$this->em = $em;
}
......@@ -18,7 +27,6 @@ class LetterManager
public function create(Language $language, $letters, $weights)
{
$string2print="Lettre Language= ".$language->getValue()."\n";
file_put_contents("logcleanvalue.txt", $string2print, FILE_APPEND);
foreach ($letters as $letterValue) {
if (ctype_alpha($letterValue)) {
$letter = new Letter();
......@@ -26,7 +34,6 @@ class LetterManager
$letter->setValue($letterValue);
$letter->setPoints(isset($weights[$letterValue]) ? $weights[$letterValue] : 1);
// $string2print="Lettre OK ctype_alpha = ".$letterValue."\n";
// file_put_contents("logcleanvalue.txt", $string2print, FILE_APPEND);
$this->em->persist($letter);
}
}
......
......@@ -5,12 +5,21 @@ namespace LexiconBundle\Manager;
use LexiconBundle\Entity\Language;
use LexiconBundle\Entity\Root;
use Doctrine\ORM\EntityManagerInterface;
use JMS\DiExtraBundle\Annotation as DI;
/**
* @DI\Service("lexicon_manager.root")
*/
class RootManager
{
private $em;
public function __construct(EntityManagerInterface $em)
/**
* @DI\InjectParams({
* "em" = @DI\Inject("doctrine.orm.entity_manager"),
* })
*/
public function __construct($em)
{
$this->em = $em;
}
......
......@@ -2,16 +2,24 @@
namespace LexiconBundle\Manager;
use Doctrine\ORM\EntityManagerInterface;
use LexiconBundle\Entity\Language;
use LexiconBundle\Entity\Word;
use LexiconBundle\Entity\WordStart;
use JMS\DiExtraBundle\Annotation as DI;
/**
* @DI\Service("lexicon_manager.word")
*/
class WordManager
{
private $em;
public function __construct(EntityManagerInterface $em)
/**
* @DI\InjectParams({
* "em" = @DI\Inject("doctrine.orm.entity_manager"),
* })
*/
public function __construct($em)
{
$this->em = $em;
}
......
......@@ -6,45 +6,6 @@ use LexiconBundle\Entity\Feature;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Symfony\Bridge\Doctrine\RegistryInterface;
/**
* @method Feature|null find($id, $lockMode = null, $lockVersion = null)
* @method Feature|null findOneBy(array $criteria, array $orderBy = null)
* @method Feature[] findAll()
* @method Feature[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class FeatureRepository extends ServiceEntityRepository
class FeatureRepository extends \Doctrine\ORM\EntityRepository
{
public function __construct(RegistryInterface $registry)
{
parent::__construct($registry, Feature::class);
}
// /**
// * @return Feature[] Returns an array of Feature objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('f')
->andWhere('f.exampleField = :val')
->setParameter('val', $value)
->orderBy('f.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/
/*
public function findOneBySomeField($value): ?Feature
{
return $this->createQueryBuilder('f')
->andWhere('f.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment