Commit 1558116c authored by Arnaud Bey's avatar Arnaud Bey
Browse files

grid generation cmd now ask for langauuge ID

parent db4a455d
...@@ -36,7 +36,6 @@ class DeleteLexiconCommand extends ContainerAwareCommand ...@@ -36,7 +36,6 @@ class DeleteLexiconCommand extends ContainerAwareCommand
$em = $this->getContainer()->get('doctrine')->getEntityManager('default'); $em = $this->getContainer()->get('doctrine')->getEntityManager('default');
$helper = $this->getHelper('question'); $helper = $this->getHelper('question');
$question = new Question("Please enter the ID of the lexicon \n"); $question = new Question("Please enter the ID of the lexicon \n");
$languages = $em->getRepository(Language::class)->findAll(); $languages = $em->getRepository(Language::class)->findAll();
foreach ($languages as $language) { foreach ($languages as $language) {
......
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
namespace MagicWordBundle\Command; namespace MagicWordBundle\Command;
use LexiconBundle\Entity\Language;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
class GenerateGridCommand extends ContainerAwareCommand class GenerateGridCommand extends ContainerAwareCommand
{ {
...@@ -14,7 +16,6 @@ class GenerateGridCommand extends ContainerAwareCommand ...@@ -14,7 +16,6 @@ class GenerateGridCommand extends ContainerAwareCommand
$this $this
->setName('magicword:generate-grid') ->setName('magicword:generate-grid')
->setDescription('generate grids') ->setDescription('generate grids')
->addArgument('languageName', InputArgument::REQUIRED)
->addArgument('number', InputArgument::REQUIRED) ->addArgument('number', InputArgument::REQUIRED)
->addArgument('threshold', InputArgument::OPTIONAL) ->addArgument('threshold', InputArgument::OPTIONAL)
->addArgument('minBigram', InputArgument::OPTIONAL); ->addArgument('minBigram', InputArgument::OPTIONAL);
...@@ -22,12 +23,19 @@ class GenerateGridCommand extends ContainerAwareCommand ...@@ -22,12 +23,19 @@ class GenerateGridCommand extends ContainerAwareCommand
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
$output->writeln('<info>################### GO! ####################################################</info>');
$em = $this->getContainer()->get('doctrine')->getEntityManager('default'); $em = $this->getContainer()->get('doctrine')->getEntityManager('default');
$helper = $this->getHelper('question');
$gridManager = $this->getContainer()->get('mw_manager.grid'); $gridManager = $this->getContainer()->get('mw_manager.grid');
$question = new Question("Please enter the ID of a lexicon \n");
$languages = $em->getRepository(Language::class)->findAll();
foreach ($languages as $language) {
$output->writeln('<comment>'.$language->getId()." > ".$language->getValue().'</comment>');
}
$idLexicon = $helper->ask($input, $output, $question);
$number = $input->getArgument('number'); $number = $input->getArgument('number');
$languageName = $input->getArgument('languageName');
$threshold = $input->getArgument('threshold'); $threshold = $input->getArgument('threshold');
$minBigram = $input->getArgument('minBigram'); $minBigram = $input->getArgument('minBigram');
$totalFormCount = 0; $totalFormCount = 0;
...@@ -39,7 +47,8 @@ class GenerateGridCommand extends ContainerAwareCommand ...@@ -39,7 +47,8 @@ class GenerateGridCommand extends ContainerAwareCommand
$minBigram = (!$minBigram) ? null : $minBigram; $minBigram = (!$minBigram) ? null : $minBigram;
while ($keptGrid < $number) { while ($keptGrid < $number) {
$language = $em->getRepository('LexiconBundle:Language')->findOneByValue($languageName); $language = $em->getRepository('LexiconBundle:Language')->find($idLexicon);
$languageName = $language->getValue();
$timeStart = microtime(true); $timeStart = microtime(true);
$grid = $gridManager->generate($language, true, $minBigram); $grid = $gridManager->generate($language, true, $minBigram);
$timeEnd = microtime(true); $timeEnd = microtime(true);
...@@ -71,6 +80,8 @@ class GenerateGridCommand extends ContainerAwareCommand ...@@ -71,6 +80,8 @@ class GenerateGridCommand extends ContainerAwareCommand
$allGrid++; $allGrid++;
$averageAll = round($totalFormCountAll / $allGrid); $averageAll = round($totalFormCountAll / $allGrid);
$output->writeln('Average form count for all '.$allGrid.' grids : <error>'.$averageAll.'</error>'); $output->writeln('Average form count for all '.$allGrid.' grids : <error>'.$averageAll.'</error>');
$output->writeln('Best grid : <error>'.$best.'</error>');
$output->writeln('Worst grid : <error>'.$worst.'</error>');
$output->writeln(''); $output->writeln('');
} }
......
Markdown is supported
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