/**
  * @param string[] $propertyIdList - A list of property-id-strings
  * @param int $limit
  * @param float $minProbability
  * @param string $context
  * @return Suggestion[]
  */
 public function generateSuggestionsByPropertyList(array $propertyIdList, $limit, $minProbability, $context)
 {
     $propertyIds = array();
     foreach ($propertyIdList as $stringId) {
         $propertyIds[] = new PropertyId($stringId);
     }
     $suggestions = $this->suggester->suggestByPropertyIds($propertyIds, $limit, $minProbability, $context);
     return $suggestions;
 }
 public function __construct(ApiMain $main, $name, $prefix = '')
 {
     parent::__construct($main, $name, $prefix);
     global $wgPropertySuggesterDeprecatedIds;
     global $wgPropertySuggesterMinProbability;
     global $wgPropertySuggesterClassifyingPropertyIds;
     global $wgPropertySuggesterInitialSuggestions;
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $store = $wikibaseRepo->getStore();
     $this->termIndex = $store->getTermIndex();
     $this->entityLookup = $store->getEntityLookup();
     $this->entityTitleLookup = $wikibaseRepo->getEntityTitleLookup();
     $this->languageCodes = $wikibaseRepo->getTermsLanguages()->getLanguages();
     $this->suggester = new SimpleSuggester(wfGetLB());
     $this->suggester->setDeprecatedPropertyIds($wgPropertySuggesterDeprecatedIds);
     $this->suggester->setClassifyingPropertyIds($wgPropertySuggesterClassifyingPropertyIds);
     $this->suggester->setInitialSuggestions($wgPropertySuggesterInitialSuggestions);
     $this->paramsParser = new SuggesterParamsParser(500, $wgPropertySuggesterMinProbability);
 }
 public function testGenerateSuggestionsWithItem()
 {
     $itemId = new ItemId('Q42');
     $item = new Item($itemId);
     $snak = new PropertySomeValueSnak(new PropertyId('P12'));
     $guid = 'claim0';
     $item->getStatements()->addNewStatement($snak, null, null, $guid);
     $this->lookup->expects($this->once())->method('getEntity')->with($this->equalTo($itemId))->will($this->returnValue($item));
     $this->suggester->expects($this->any())->method('suggestByItem')->with($this->equalTo($item))->will($this->returnValue(array('foo')));
     $result3 = $this->suggestionGenerator->generateSuggestionsByItem('Q42', 100, 0.0, 'item');
     $this->assertEquals($result3, array('foo'));
 }