Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 00e88172 authored by Sylvain Hatier's avatar Sylvain Hatier Committed by Arnaud Bey
Browse files

Fix Bigram Min

parent c4b75b9f
......@@ -16,7 +16,8 @@ class GenerateGridCommand extends ContainerAwareCommand
->setDescription('generate grids')
->addArgument('languageName', InputArgument::REQUIRED)
->addArgument('number', InputArgument::REQUIRED)
->addArgument('threshold', InputArgument::OPTIONAL);
->addArgument('threshold', InputArgument::OPTIONAL)
->addArgument('minBigram', InputArgument::OPTIONAL);
}
protected function execute(InputInterface $input, OutputInterface $output)
......@@ -28,17 +29,19 @@ class GenerateGridCommand extends ContainerAwareCommand
$number = $input->getArgument('number');
$languageName = $input->getArgument('languageName');
$threshold = $input->getArgument('threshold');
$minBigram = $input->getArgument('minBigram');
$totalFormCount = 0;
$totalFormCountAll = 0;
$keptGrid = 0;
$allGrid = 0;
$best = 0;
$worst = 1000;
$minBigram = (!$minBigram) ? null : $minBigram;
while ($keptGrid < $number) {
$language = $em->getRepository('LexiconBundle:Language')->findOneByValue($languageName);
$timeStart = microtime(true);
$grid = $gridManager->generate($language, true);
$grid = $gridManager->generate($language, true, $minBigram);
$timeEnd = microtime(true);
$executionTime = round($timeEnd - $timeStart, 2);
$formCount = $grid->getFoundableForms()? count($grid->getFoundableForms()) : 0;
......
......@@ -45,11 +45,11 @@ class GridManager
}
public function generate(Language $language, $debug = false)
public function generate(Language $language, $debug = false, $minBigram = null)
{
$grid = $this->newGrid($language, 4);
$letters = $this->lottery($language, 4, $debug);
$minBigram = ($minBigram == null) ? $language->getMinBigram() : $minBigram;
$letters = $this->lottery($language, 4, $debug, $minBigram);
if ($debug === true) {
echo "\nletters: ";
......@@ -347,8 +347,10 @@ class GridManager
return;
}
public function lottery(Language $language, $side, $debug = false)
public function lottery(Language $language, $side, $debug = false, $minBigram = null)
{
$minBigram = ($minBigram == null) ? $language->getMinBigram() : $minBigram;
$fileBigrams = $language->getDirectory().DIRECTORY_SEPARATOR."bigrams.txt";
// On crée un tableau de bigrammes
// où chaque bigramme apparait autant de fois que son poids
......@@ -361,7 +363,6 @@ class GridManager
$string = $tab[0];
$freqBigramBi = $tab[1];
$poids = $tab[3];
$minBigram = $language->getMinBigram();
//si Freq du bigram et son inverse est < à min défini par user alors on le prend pas en compte
if ($freqBigramBi > $minBigram) {
$bigramLetters = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY);
......
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