Exemplo n.º 1
0
 /**
  * @param $queryString
  * @param $simType  String ["innerProduct","$cosine","jaccard"]
  * @param $sortBy   String ["similarity","time"]
  * @return array : list of result
  */
 public function search($queryString, $simType, $sortBy, $topN, &$actualResultCount)
 {
     $resList = "";
     //simVal(similarity Value), title, url, time, abstract}
     $wordSplit = new WordSplit($queryString);
     $queryTermArray = $wordSplit->send_post();
     $termsDocList = $this->SelDocByQueryTerm($queryTermArray);
     $resList = $this->formDocsVectorList($termsDocList);
     $this->assignSimValue($queryTermArray, $resList, $simType);
     $this->sortResultList($resList, $sortBy);
     $actualResultCount = count($resList);
     $resList = $this->getTopNResult($resList, $topN);
     //get True content of topN resList
     $docmentContent = new DocumentContent($resList);
     $resList = $docmentContent->getDocumentContents();
     return $resList;
 }
Exemplo n.º 2
0
function computeTheSimValue()
{
    //分词,得到词项
    $sentence = $_POST["Query1"];
    $wordSplit = new WordSplit($sentence);
    $result1 = $wordSplit->send_post();
    echo '<div class="resultArea col-md-12" style="font-size: 30px;color: #ff0025">';
    echo 'Query1 : ' . $sentence . '<br />';
    $sentence = $_POST["Query2"];
    $wordSplit = new WordSplit($sentence);
    $result2 = $wordSplit->send_post();
    echo 'Query2 : ' . $sentence . '<br />';
    echo '</div>';
    $simcal = new SimCalculator();
    $innerProduct = "";
    $cosine = "";
    $jaccard = "";
    $simcal->getSimWithTwoTermArrays($result1, $result2, $innerProduct, $cosine, $jaccard);
    echo '<div class="resultArea col-md-12" style="font-size: 30px;color: #ff0025">';
    //打印结果
    echo '<table class="table table-condensed">';
    echo '<tr>';
    echo '<th> Compute Type </th> <th> Value </th>';
    echo '</tr>';
    echo '<tr>';
    echo '<th> InnerProduct </th> <th>' . $innerProduct . ' </th>';
    echo '</tr>';
    echo '<tr>';
    echo '<th> Cosine </th> <th>' . $cosine . ' </th>';
    echo '</tr>';
    echo '<tr>';
    echo '<th> Jaccard </th> <th>' . $jaccard . ' </th>';
    echo '</tr>';
    echo '</table>';
    echo '</div>';
}