mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 05:23:21 +00:00
Context support in concept finding command
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Command\Thesaurus;
|
|||||||
|
|
||||||
use Alchemy\Phrasea\Command\Command;
|
use Alchemy\Phrasea\Command\Command;
|
||||||
use Alchemy\Phrasea\SearchEngine\Elastic\Indexer;
|
use Alchemy\Phrasea\SearchEngine\Elastic\Indexer;
|
||||||
|
use Alchemy\Phrasea\SearchEngine\Elastic\Thesaurus\Term;
|
||||||
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\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
@@ -30,6 +31,11 @@ class FindConceptsCommand extends Command
|
|||||||
InputArgument::REQUIRED,
|
InputArgument::REQUIRED,
|
||||||
'Reverse search a term to infer concepts'
|
'Reverse search a term to infer concepts'
|
||||||
)
|
)
|
||||||
|
->addArgument(
|
||||||
|
'context',
|
||||||
|
InputArgument::OPTIONAL,
|
||||||
|
'Restrict search to a specific term context'
|
||||||
|
)
|
||||||
->addOption(
|
->addOption(
|
||||||
'locale',
|
'locale',
|
||||||
null,
|
null,
|
||||||
@@ -48,16 +54,22 @@ class FindConceptsCommand extends Command
|
|||||||
protected function doExecute(InputInterface $input, OutputInterface $output)
|
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$term = $input->getArgument('term');
|
$term = $input->getArgument('term');
|
||||||
|
$context = $input->getArgument('context');
|
||||||
$raw = $input->getOption('raw');
|
$raw = $input->getOption('raw');
|
||||||
|
|
||||||
if (!$raw) {
|
if (!$raw) {
|
||||||
$output->writeln(sprintf('Finding linked concepts: <comment>%s</comment>', $term));
|
$message = sprintf('Finding linked concepts: <comment>%s</comment>', $term);
|
||||||
|
if ($context) {
|
||||||
|
$message .= sprintf(' (with context <comment>%s</comment>)', $context);
|
||||||
|
}
|
||||||
|
$output->writeln($message);
|
||||||
$output->writeln(str_repeat('-', 20));
|
$output->writeln(str_repeat('-', 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
$thesaurus = $this->container['thesaurus'];
|
$thesaurus = $this->container['thesaurus'];
|
||||||
|
$term = new Term($term, $context);
|
||||||
$locale = $input->getOption('locale');
|
$locale = $input->getOption('locale');
|
||||||
$concepts = $thesaurus->findConcepts($term, null, $locale);
|
$concepts = $thesaurus->findConcepts($term, $locale);
|
||||||
|
|
||||||
if (count($concepts)) {
|
if (count($concepts)) {
|
||||||
$output->writeln($concepts);
|
$output->writeln($concepts);
|
||||||
|
Reference in New Issue
Block a user