Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mathieu Loiseau
MagicWord
Commits
1558116c
Commit
1558116c
authored
May 29, 2019
by
Arnaud Bey
Browse files
grid generation cmd now ask for langauuge ID
parent
db4a455d
Changes
2
Hide whitespace changes
Inline
Side-by-side
application/src/LexiconBundle/Command/DeleteLexiconCommand.php
View file @
1558116c
...
...
@@ -36,7 +36,6 @@ class DeleteLexiconCommand extends ContainerAwareCommand
$em
=
$this
->
getContainer
()
->
get
(
'doctrine'
)
->
getEntityManager
(
'default'
);
$helper
=
$this
->
getHelper
(
'question'
);
$question
=
new
Question
(
"Please enter the ID of the lexicon
\n
"
);
$languages
=
$em
->
getRepository
(
Language
::
class
)
->
findAll
();
foreach
(
$languages
as
$language
)
{
...
...
application/src/MagicWordBundle/Command/GenerateGridCommand.php
View file @
1558116c
...
...
@@ -2,10 +2,12 @@
namespace
MagicWordBundle\Command
;
use
LexiconBundle\Entity\Language
;
use
Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
;
use
Symfony\Component\Console\Input\InputArgument
;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Output\OutputInterface
;
use
Symfony\Component\Console\Question\Question
;
class
GenerateGridCommand
extends
ContainerAwareCommand
{
...
...
@@ -14,7 +16,6 @@ class GenerateGridCommand extends ContainerAwareCommand
$this
->
setName
(
'magicword:generate-grid'
)
->
setDescription
(
'generate grids'
)
->
addArgument
(
'languageName'
,
InputArgument
::
REQUIRED
)
->
addArgument
(
'number'
,
InputArgument
::
REQUIRED
)
->
addArgument
(
'threshold'
,
InputArgument
::
OPTIONAL
)
->
addArgument
(
'minBigram'
,
InputArgument
::
OPTIONAL
);
...
...
@@ -22,12 +23,19 @@ class GenerateGridCommand extends ContainerAwareCommand
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
$output
->
writeln
(
'<info>################### GO! ####################################################</info>'
);
$em
=
$this
->
getContainer
()
->
get
(
'doctrine'
)
->
getEntityManager
(
'default'
);
$helper
=
$this
->
getHelper
(
'question'
);
$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'
);
$languageName
=
$input
->
getArgument
(
'languageName'
);
$threshold
=
$input
->
getArgument
(
'threshold'
);
$minBigram
=
$input
->
getArgument
(
'minBigram'
);
$totalFormCount
=
0
;
...
...
@@ -39,7 +47,8 @@ class GenerateGridCommand extends ContainerAwareCommand
$minBigram
=
(
!
$minBigram
)
?
null
:
$minBigram
;
while
(
$keptGrid
<
$number
)
{
$language
=
$em
->
getRepository
(
'LexiconBundle:Language'
)
->
findOneByValue
(
$languageName
);
$language
=
$em
->
getRepository
(
'LexiconBundle:Language'
)
->
find
(
$idLexicon
);
$languageName
=
$language
->
getValue
();
$timeStart
=
microtime
(
true
);
$grid
=
$gridManager
->
generate
(
$language
,
true
,
$minBigram
);
$timeEnd
=
microtime
(
true
);
...
...
@@ -71,6 +80,8 @@ class GenerateGridCommand extends ContainerAwareCommand
$allGrid
++
;
$averageAll
=
round
(
$totalFormCountAll
/
$allGrid
);
$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
(
''
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment