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
f269fb82
Commit
f269fb82
authored
May 28, 2021
by
Arnaud Bey
Browse files
change the import method
parent
b491604e
Changes
2
Hide whitespace changes
Inline
Side-by-side
INSTALL.md
View file @
f269fb82
...
...
@@ -39,7 +39,7 @@ copy `lexicon.tsv` and `spec.txt` in a new folder in `application/data/lexicons`
(some ready to use scripts are available in the `script/` folder.)
```
sudo docker-compose exec apache bash
console lexicon:import
FOLDERNAME
console lexicon:import
```
Grid generation
...
...
application/src/LexiconBundle/Command/ImportLexiconCommand.php
View file @
f269fb82
...
...
@@ -3,10 +3,12 @@
namespace
LexiconBundle\Command
;
use
LexiconBundle\Manager\ImportManager
;
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\Bundle\FrameworkBundle\Command\ContainerAwareCommand
;
use
Symfony\Component\Console\Question\Question
;
use
Symfony\Component\Finder\Finder
;
class
ImportLexiconCommand
extends
ContainerAwareCommand
{
...
...
@@ -14,20 +16,29 @@ class ImportLexiconCommand extends ContainerAwareCommand
{
$this
->
setName
(
'lexicon:import'
)
->
setDescription
(
'Put your files, named exactly "lexicon.tsv" & "spec.txt" in a directory (ex:/euskara) in application/data/lexicons'
)
->
addArgument
(
'directory'
,
InputArgument
::
REQUIRED
,
'name of directory in application/data/lexicons'
);
->
setDescription
(
'Put your files, named exactly "lexicon.tsv" & "spec.txt" in a directory (ex:/euskara) in application/data/lexicons'
);
}
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
)
{
$pathLexiconDir
=
$input
->
getArgument
(
'directory'
);
$output
->
writeln
(
'Available directories in <comment>./data/lexicons/</comment>'
);
$finder
=
new
Finder
();
$dirs
=
$finder
->
directories
()
->
in
(
'./data/lexicons'
)
->
depth
(
'== 0'
);
$directories
=
[];
foreach
(
$dirs
as
$dir
)
{
$name
=
basename
(
$dir
);
$directories
[]
=
$name
;
$output
->
writeln
(
'* <comment>'
.
$name
.
'</comment>'
);
}
$helper
=
$this
->
getHelper
(
'question'
);
$dirName
=
new
Question
(
"Please enter the directory name
\n
"
);
$pathLexiconDir
=
$helper
->
ask
(
$input
,
$output
,
$dirName
);
if
(
$pathLexiconDir
)
{
if
(
in_array
(
$pathLexiconDir
,
$directories
)
)
{
echo
'You passed an argument: '
.
$pathLexiconDir
.
"
\n\n
"
;
$importManager
=
$this
->
getContainer
()
->
get
(
'lexicon_manager.import'
);
$importManager
->
importLexicon
(
$pathLexiconDir
);
}
else
{
echo
'Argument missing'
;
}
}
}
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