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