Ejemplo n.º 1
0
function fill_index()
{
    for ($i = 0; $i < 10; $i++) {
        $index = new Zend_Search_Lucene('./data/index', true);
        $index->find("test");
        $doc = new Zend_Search_Lucene_Document();
        $doc->addField(Zend_Search_Lucene_Field::Text("test", getword()));
        $doc->addField(Zend_Search_Lucene_Field::UnStored("contents", getword()));
        $index->addDocument($doc);
        $index->commit();
        $index->getDirectory()->close();
        //comment this to see another bug :-|
    }
}
Ejemplo n.º 2
0
function getword($cellCnt, $charCount, $startChar, $explode_cell = array())
{
    // echo '<pre>';
    // 		print_r($explode_cell);
    $opt = array();
    $matrix_rel = unserialize(MATRIX_REL);
    // $_SESSION['word_cell'][] = $cellCnt;
    if ($charCount == 1) {
        foreach ($matrix_rel[$cellCnt] as $key => $value) {
            if (!in_array($value, $explode_cell)) {
                $tmp_array = $explode_cell;
                $tmp_array[] = $cellCnt;
                $tmp_array[] = $value;
                $tmp_word = $startChar . $_SESSION['matrix'][$value];
                // $tmp_score = getScore($tmp_array);
                // if(in_array(strtolower($tmp_word),$_SESSION['tmp_val'])){
                // 	if($tmp_score > $_SESSION['word_score'][$tmp_word]){
                // 		$_SESSION['word_score'][$tmp_word] =  $tmp_score;
                // 	}
                // }else{
                // 	$_SESSION['word_score'][$tmp_word] =  $tmp_score;
                // }
                $_SESSION['tmp_val'][$tmp_word] = strtolower($tmp_word);
                $_SESSION['final_word_cell'][$tmp_word] = $tmp_array;
                // $explode_cell = array();
                // echo '<br>';
            }
        }
    } else {
        for ($p = $charCount; $p >= 1; $p--) {
            $explode_cell[$cellCnt] = $cellCnt;
            foreach ($matrix_rel[$cellCnt] as $key => $value) {
                if (!in_array($value, $explode_cell)) {
                    // $explode_cell[$value] = $value;
                    $tmp_word = $startChar . $_SESSION['matrix'][$value];
                    $tmp_charCount = $charCount - 1;
                    getword($value, $tmp_charCount, $tmp_word, $explode_cell);
                    //
                }
            }
            // $explode_cell = array() ;
        }
    }
}
Ejemplo n.º 3
0
function getword($cellCnt, $charCount, $startChar)
{
    $opt = array();
    $matrix_rel = unserialize(MATRIX_REL);
    // print_r($matrix_rel);
    // echo "cellCnt======".$cellCnt.", charCount=====".$charCount.", startChar=====".$startChar.'<br>';
    if ($charCount == 1) {
        foreach ($matrix_rel[$cellCnt] as $key => $value) {
            $tmp_word = $startChar . $_SESSION['matrix'][$value];
            $_SESSION['tmp_val'][$tmp_word] = $tmp_word;
        }
    } else {
        for ($p = $charCount; $p >= 1; $p--) {
            foreach ($matrix_rel[$cellCnt] as $key => $value) {
                $tmp_word = $startChar . $_SESSION['matrix'][$value];
                $tmp_charCount = $charCount - 1;
                getword($value, $tmp_charCount, $tmp_word);
            }
        }
    }
    // return $opt;
    // echo "==================================================================<br>";
}
Ejemplo n.º 4
0
/** 
 * Searches the index and returns the matching entries in an array.
 *
 * Used in the entries screen/overview search.
 *
 * @param string $str Text/words to search for
 * @return array
 */
function search_entries($str)
{
    global $index_file, $matches, $db, $search_all;
    $search_all = true;
    $str = transliterate_accents(trim($str));
    $words = explode(" ", $str);
    foreach ($words as $key => $val) {
        if (trim($val) == "") {
            unset($words[$key]);
        } else {
            $words[$key] = trim($val);
        }
    }
    if (count($words) > 0) {
        foreach ($words as $word) {
            if (file_exists("db/search/" . $word[0] . ".php")) {
                $index_file[$word[0]] = load_serialize("db/search/" . $word[0] . ".php");
            }
        }
    }
    foreach ($words as $word) {
        $res = getword($word);
        if ($res) {
            $found_words[] = $word;
        }
    }
    // mix 'n match.. If the result set for 'AND' is empty, just lump
    // them together, so we have an 'OR'..
    if (count($matches) == 1) {
        $result = $matches[0];
    } else {
        if (count($matches) == 2) {
            list($word1, $word2) = $matches;
            $result = array_intersect($word1, $word2);
            if (count($result) == 0) {
                $result = array_merge($word1, $word2);
            }
        } else {
            if (count($matches) == 3) {
                list($word1, $word2, $word3) = $matches;
                $result = array_intersect($word1, $word2, $word3);
                if (count($result) == 0) {
                    $result = array_merge($word1, $word2, $word3);
                }
            } else {
                if (count($matches) > 3) {
                    list($word1, $word2, $word3, $word4) = $matches;
                    $result = array_intersect($word1, $word2, $word3, $word4);
                    if (count($result) == 0) {
                        $result = array_merge($word1, $word2, $word3, $word4);
                    }
                }
            }
        }
    }
    if (isset($found_words) && count($found_words) > 0) {
        $db = new db();
        foreach ($result as $hit) {
            $entry = $db->read_entry($hit);
            if ($entry['title'] == "") {
                $entry['title'] = substr(strip_tags($entry['introduction']), 0, 50);
            }
            unset($entry['comments']);
            unset($entry['introduction']);
            unset($entry['body']);
            $output[] = $entry;
        }
        return $output;
    } else {
        return array();
    }
}
Ejemplo n.º 5
0
         $log .= '<span class="yellow">你所在的位置并非医院,不能静养!</span><br>';
     } else {
         $state = substr($command, 4, 1);
         $mode = 'rest';
     }
 } elseif ($command == 'itemmain') {
     $mode = $itemcmd;
 } elseif ($command == 'song') {
     $sname = trim(trim($art, '【'), '】');
     include_once GAME_ROOT . './include/game/song.inc.php';
     //$log.=$sname;
     sing($sname);
 } elseif ($command == 'special') {
     if ($sp_cmd == 'sp_word') {
         include_once GAME_ROOT . './include/game/special.func.php';
         getword();
         $mode = $sp_cmd;
     } elseif ($sp_cmd == 'sp_adtsk') {
         include_once GAME_ROOT . './include/game/special.func.php';
         adtsk();
         $mode = 'command';
     } elseif ($sp_cmd == 'sp_trapadtsk') {
         $position = 0;
         if ($club == 7) {
             foreach (array(1, 2, 3, 4, 5, 6) as $imn) {
                 if (strpos(${'itmk' . $imn}, 'B') === 0 && ${'itme' . $imn} > 0) {
                     $position = $imn;
                     break;
                 }
             }
             if (!$position) {
Ejemplo n.º 6
0
<?php

include 'tiku.php';
$tiku_l = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20);
//与题库对应
$word = array();
//单词列表
$timu = array();
//出题列表
gettimu($tiku_l, $word, 15);
//从题库连接获得15题序号
gettimu($word, $timu, 10);
//从单词序号获得10题题目序号
//echo '<pre>';
$wo = getword($word, $tiku);
$list = getti($timu, $tiku);
$body = file_get_contents('index.tpl');
$body = str_replace('{word}', $wo, $body);
$body = str_replace('{list}', $list, $body);
//$body=str_replace('{fw}',$fw,$body);
//echo $body;
$fw = file_get_contents('index.txt');
//echo $fw;
$fw += 1;
$fp = fopen('index.txt', "w+");
fwrite($fp, '' . $fw . '');
fclose($fp);
$body = str_replace('{fw}', $fw, $body);
echo $body;
/*
Ejemplo n.º 7
0
         $tmp_char = 'char_' . $i;
         $tmp_base = 'base_' . $i;
         $tmp_spl = 'charSpl_' . $i;
         if (isset(${$tmp_char}) && !empty(${$tmp_char})) {
             $_SESSION['matrix'][$i] = ${$tmp_char};
         }
         $_SESSION['word_base_score'][$i] = isset(${$tmp_base}) && !empty(${$tmp_base}) ? ${$tmp_base} : 1;
         $_SESSION['word_spl_score'][$i] = isset(${$tmp_spl}) && !empty(${$tmp_spl}) ? ${$tmp_spl} : "";
     }
     print_r($_SESSION['matrix']);
     $_SESSION['tmp_val'] = $_SESSION['final_word_cell'] = $_SESSION['final_opt'] = $_SESSION['word_score'] = array();
     break;
 case 'getWord':
     // $_SESSION['word_cell'] = array();
     for ($j = 1; $j <= 5; $j++) {
         getword($cellCnt, $j, $_SESSION['matrix'][$cellCnt]);
     }
     echo "done";
     break;
 case 'getWordWithScore':
     // print_r($_SESSION['tmp_val']);
     $dataFile = 'master';
     $dataFile_records = file($dataFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
     $match = array_intersect($_SESSION['tmp_val'], $dataFile_records);
     $match_score = array();
     foreach ($match as $tmpK => $tmpV) {
         $tmpScore = getScore($_SESSION['final_word_cell'][$tmpK]);
         $match_score[] = array("word" => $tmpK, "score" => $tmpScore);
         $_SESSION['final_opt'][$tmpK] = $tmpScore;
     }
     echo json_encode($_SESSION['final_opt']);