示例#1
0
 /**
  * {@inheritdoc}
  */
 public function process($query)
 {
     $synonyms = [];
     $synonymsArray = $this->synonymsAnalyzer->getSynonymsForPhrase($query);
     if (count($synonymsArray) > 0) {
         foreach ($synonymsArray as $synonymPart) {
             $synonyms[] = implode(' ', $synonymPart);
         }
         $query = implode(' ', $synonyms);
     }
     return $query;
 }
 /**
  * @param string $phrase
  * @param array $expectedResult
  * @dataProvider loadProcessDataProvider
  */
 public function testProcess($query, $result, $newQuery)
 {
     $this->synonymAnalyzer->expects($this->once())->method('getSynonymsForPhrase')->with($this->equalTo($query))->will($this->returnValue($result));
     $result = $this->synonymPreprocessor->process($query);
     $this->assertEquals($result, $newQuery);
 }