Exemplo n.º 1
0
 private function getPrunedConcepts()
 {
     if ($this->pruned_concepts === null) {
         $this->pruned_concepts = Concept::pruneNarrowConcepts($this->concepts);
     }
     return $this->pruned_concepts;
 }
Exemplo n.º 2
0
 public function testNarrowConceptPruning()
 {
     $concepts = [new Concept('/foo'), new Concept('/fooo'), new Concept('/foo/baz'), new Concept('/bar/baz'), new Concept('/bar')];
     $pruned = Concept::pruneNarrowConcepts($concepts);
     $expected = [new Concept('/bar'), new Concept('/foo'), new Concept('/fooo')];
     $this->assertEquals($expected, $pruned);
 }
Exemplo n.º 3
0
 protected function doExecute(InputInterface $input, OutputInterface $output)
 {
     $term = $input->getArgument('term');
     $context = $input->getArgument('context');
     $raw = $input->getOption('raw');
     if (!$raw) {
         $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');
     $strict = $input->getOption('strict');
     $concepts = $thesaurus->findConcepts($term, $locale, null, $strict);
     if ($input->getOption('broad')) {
         $concepts = Concept::pruneNarrowConcepts($concepts);
     }
     if (count($concepts)) {
         $output->writeln($concepts);
     } elseif (!$raw) {
         $output->writeln('No concept found');
     }
 }