示例#1
0
         printf("序  %s %s\n%s\n", XSUtil::fixWidth('搜索热门关键词(' . $type . ')', 40), XSUtil::fixWidth('次数', 10), XSUtil::fixWidth('', 56, '-'));
         foreach ($result as $word => $freq) {
             printf("%2d. %s %d\n", $i, XSUtil::fixWidth($word, 40), $freq);
             $i++;
         }
     }
 } elseif ($query !== null) {
     $query = XSUtil::convertIn($query);
     $limit = $limit === null ? 6 : intval($limit);
     $result = $log_ready ? $search->setFuzzy()->setLimit($limit)->search($query) : array();
     if (count($result) === 0) {
         echo "目前还没有与 " . $query . " 相关的搜索词。\n";
     } else {
         printf("序 %s %s\n%s\n", XSUtil::fixWidth("相关搜索词({$query})", 41), XSUtil::fixWidth('次数', 10), XSUtil::fixWidth('', 50, '-'));
         for ($i = 0, $total = count($result); $i < $total; $i++) {
             printf("%2d. %s %s\n", $i + 1, XSUtil::fixWidth($result[$i]->body, 40), $result[$i]->total);
         }
     }
 } else {
     // check clean
     if ($clean !== null) {
         echo "清空已有搜索日志数据 ...\n";
         $xs->index->setDb($db)->clean();
     }
     // import from file
     if ($import !== null) {
         if (!file_exists($import) || !($fd = @fopen($import, "r"))) {
             echo "要导入的文件 [{$import}] 不存在或无法读取!\n";
         } else {
             $search->setTimeout(0);
             echo "开始导入搜索日志文件 ...\n";
示例#2
0
function out_line()
{
    $args = func_get_args();
    if (count($args) == 4) {
        printf("| %s | %s | %s | %s |\n", XSUtil::fixWidth($args[0], 10), XSUtil::fixWidth($args[1], 10), XSUtil::fixWidth($args[2], 24), XSUtil::fixWidth($args[3], 30));
    } else {
        printf("+-%s-+-%s-+-%s-+-%s-+\n", XSUtil::fixWidth('', 10, '-'), XSUtil::fixWidth('', 10, '-'), XSUtil::fixWidth('', 24, '-'), XSUtil::fixWidth('', 30, '-'));
    }
}
示例#3
0
文件: Quest.php 项目: Kuner/xunsearch
     } else {
         $limit1 = intval(substr($limit, $pos + 1));
         $offset = intval($limit);
     }
     $synonyms = $search->getAllSynonyms($limit1, $offset, $synonyms === 'stemmed');
     if (count($synonyms) == 0) {
         echo "暂无相关的同义词记录";
         if ($offset != 0) {
             echo ",反正总数不超过 {$offset} 个";
         }
         echo "。\n";
     } else {
         $i = $offset + 1;
         printf("   %s %s\n%s\n", XSUtil::fixWidth('原词', 32), '同义词', XSUtil::fixWidth('', 56, '-'));
         foreach ($synonyms as $raw => $list) {
             printf("%4d. %s %s\n", $i++, XSUtil::fixWidth($raw, 29), implode(", ", $list));
         }
     }
 } elseif ($terms !== null) {
     $result = $search->terms($query);
     echo "列出" . $query . "的内部切分结果:\n";
     print_r($result);
 } elseif ($correct !== null) {
     $result = $search->getCorrectedQuery($query);
     if (count($result) === 0) {
         echo "目前对" . $query . "还没有更好的修正方案。\n";
     } else {
         echo "您可以试试找:" . implode(" ", $result) . "\n";
     }
 } elseif ($suggest !== null) {
     $result = $search->getExpandedQuery($query, $limit1);