|
@@ -28,31 +28,9 @@ function microtime_float()
|
|
|
|
|
|
|
|
$result = array();
|
|
$result = array();
|
|
|
$result["error"]="";
|
|
$result["error"]="";
|
|
|
|
|
+$_start=microtime(true);
|
|
|
|
|
+$result["time"][]=array("event"=>"begin","time"=>$_start);
|
|
|
|
|
|
|
|
-switch($op){
|
|
|
|
|
- case "pre"://预查询
|
|
|
|
|
- {
|
|
|
|
|
- $time_start = microtime_float();
|
|
|
|
|
-
|
|
|
|
|
- $searching=$arrWordList[count($arrWordList)-1];
|
|
|
|
|
- $dbfile = _FILE_DB_WORD_INDEX_;
|
|
|
|
|
- PDO_Connect("sqlite:".$dbfile);
|
|
|
|
|
-
|
|
|
|
|
- if(count($arrWordList)>1){
|
|
|
|
|
- //echo "<div>";
|
|
|
|
|
- foreach($arrWordList as $oneword){
|
|
|
|
|
- //echo $oneword."+";
|
|
|
|
|
- }
|
|
|
|
|
- //echo "</div>";
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- $query = "SELECT word,count,bold FROM wordindex WHERE word_en like ? OR word like ? limit 0,20";
|
|
|
|
|
- $Fetch = PDO_FetchAll($query,array("{$searching}%","{$searching}%"));
|
|
|
|
|
- echo json_encode($Fetch,JSON_UNESCAPED_UNICODE);
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- case "search":
|
|
|
|
|
- {
|
|
|
|
|
$_pagesize = 20;
|
|
$_pagesize = 20;
|
|
|
if(isset($_GET["page"])){
|
|
if(isset($_GET["page"])){
|
|
|
$_page = (int)$_GET["page"];
|
|
$_page = (int)$_GET["page"];
|
|
@@ -67,8 +45,20 @@ switch($op){
|
|
|
# 首先精确匹配
|
|
# 首先精确匹配
|
|
|
$words = implode(" ",$arrWordList);
|
|
$words = implode(" ",$arrWordList);
|
|
|
$query = "SELECT book,paragraph, text FROM pali_text WHERE text like ? LIMIT ? , ?";
|
|
$query = "SELECT book,paragraph, text FROM pali_text WHERE text like ? LIMIT ? , ?";
|
|
|
- $Fetch = PDO_FetchAll($query,array("%{$words}%",$_page*$_pagesize,$_pagesize));
|
|
|
|
|
- #然后查不精确的
|
|
|
|
|
|
|
+ $Fetch1 = PDO_FetchAll($query,array("%{$words}%",$_page*$_pagesize,$_pagesize));
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($Fetch1 as $key => $value) {
|
|
|
|
|
+ # code...
|
|
|
|
|
+ $newRecode["title"]="title";
|
|
|
|
|
+ $newRecode["path"] = _get_para_path($value["book"],$value["paragraph"]);
|
|
|
|
|
+ $newRecode["book"] = $value["book"];
|
|
|
|
|
+ $newRecode["para"] = $value["paragraph"];
|
|
|
|
|
+ $newRecode["palitext"] = $value["text"];
|
|
|
|
|
+ $newRecode["keyword"] = $arrWordList;
|
|
|
|
|
+ $newRecode["wt"] = 0;
|
|
|
|
|
+ $out_data[] = $newRecode;
|
|
|
|
|
+ }
|
|
|
|
|
+ #然后查分散的
|
|
|
$strQuery="";
|
|
$strQuery="";
|
|
|
foreach($arrWordList as $oneword){
|
|
foreach($arrWordList as $oneword){
|
|
|
$strQuery.="\"text\" like \"% {$oneword} %\" AND";
|
|
$strQuery.="\"text\" like \"% {$oneword} %\" AND";
|
|
@@ -76,25 +66,30 @@ switch($op){
|
|
|
$strQuery = substr($strQuery,0,-3);
|
|
$strQuery = substr($strQuery,0,-3);
|
|
|
|
|
|
|
|
$query = "SELECT book,paragraph, html FROM pali_text WHERE {$strQuery} LIMIT 0,20";
|
|
$query = "SELECT book,paragraph, html FROM pali_text WHERE {$strQuery} LIMIT 0,20";
|
|
|
- $Fetch = PDO_FetchAll($query);
|
|
|
|
|
|
|
+ $Fetch2 = PDO_FetchAll($query);
|
|
|
|
|
|
|
|
- $iFetch=count($Fetch);
|
|
|
|
|
- foreach($Fetch as $row){
|
|
|
|
|
- $html = $row["html"];
|
|
|
|
|
- foreach($arrWordList as $oneword){
|
|
|
|
|
- $html=str_replace($oneword,"<hl>{$oneword}</hl>",$html);
|
|
|
|
|
- }
|
|
|
|
|
- //echo "<div class='dict_word'>{$html}</div>";
|
|
|
|
|
|
|
+ foreach ($Fetch2 as $key => $value) {
|
|
|
|
|
+ # code...
|
|
|
|
|
+ $newRecode["title"]="title";
|
|
|
|
|
+ $newRecode["path"] = _get_para_path($value["book"],$value["paragraph"]);
|
|
|
|
|
+ $newRecode["book"] = $value["book"];
|
|
|
|
|
+ $newRecode["para"] = $value["paragraph"];
|
|
|
|
|
+ $newRecode["palitext"] = $value["text"];
|
|
|
|
|
+ $newRecode["keyword"] = $arrWordList;
|
|
|
|
|
+ $newRecode["wt"] = 0;
|
|
|
|
|
+ $out_data[] = $newRecode;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ $result["data"] = $out_data;
|
|
|
|
|
+ echo json_encode($result,JSON_UNESCAPED_UNICODE);
|
|
|
# 然后查特别不精确的
|
|
# 然后查特别不精确的
|
|
|
- return;
|
|
|
|
|
|
|
+ exit;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//计算某词在三藏中出现的次数
|
|
//计算某词在三藏中出现的次数
|
|
|
$time_start = microtime_float();
|
|
$time_start = microtime_float();
|
|
|
$arrRealWordList = countWordInPali($word);
|
|
$arrRealWordList = countWordInPali($word);
|
|
|
$countWord=count($arrRealWordList);
|
|
$countWord=count($arrRealWordList);
|
|
|
|
|
+ $result["time"][]=array("event"=>"计算某词在三藏中出现的次数","time"=>microtime(true)-$_start);
|
|
|
if($countWord==0){
|
|
if($countWord==0){
|
|
|
#没查到 模糊查询
|
|
#没查到 模糊查询
|
|
|
$dictFileName=_FILE_DB_PALITEXT_;
|
|
$dictFileName=_FILE_DB_PALITEXT_;
|
|
@@ -128,19 +123,8 @@ switch($op){
|
|
|
$aInputWordList["{$value}"] = true;
|
|
$aInputWordList["{$value}"] = true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- else{
|
|
|
|
|
- foreach ($aInputWordList as $key => $value) {
|
|
|
|
|
- //$aInputWordList[$key] = true;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
- /*
|
|
|
|
|
- else{
|
|
|
|
|
- foreach ($aInputWordList as $key => $value) {
|
|
|
|
|
- $aInputWordList[$key] = true;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- */
|
|
|
|
|
|
|
+
|
|
|
$strQueryWordId=mb_substr($strQueryWordId, 0,mb_strlen($strQueryWordId,"UTF-8")-1,"UTF-8");
|
|
$strQueryWordId=mb_substr($strQueryWordId, 0,mb_strlen($strQueryWordId,"UTF-8")-1,"UTF-8");
|
|
|
$strQueryWordId.=")";
|
|
$strQueryWordId.=")";
|
|
|
|
|
|
|
@@ -148,7 +132,7 @@ switch($op){
|
|
|
|
|
|
|
|
//显示单词列表
|
|
//显示单词列表
|
|
|
arsort($aShowWordList);
|
|
arsort($aShowWordList);
|
|
|
-
|
|
|
|
|
|
|
+ $result["time"][]=array("event"=>"单词列表排序结束","time"=>microtime(true)-$_start);
|
|
|
$out_case = array();
|
|
$out_case = array();
|
|
|
$word_count=0;
|
|
$word_count=0;
|
|
|
foreach($aShowWordList as $x=>$x_value) {
|
|
foreach($aShowWordList as $x=>$x_value) {
|
|
@@ -170,6 +154,7 @@ switch($op){
|
|
|
|
|
|
|
|
$result["book_list"]=$booklist;
|
|
$result["book_list"]=$booklist;
|
|
|
$result["book_tag"]=get_book_tag($strQueryWordId);
|
|
$result["book_tag"]=get_book_tag($strQueryWordId);
|
|
|
|
|
+ $result["time"][]=array("event"=>"查找书结束","time"=>microtime(true)-$_start);
|
|
|
|
|
|
|
|
$wordInBookCounter=0;
|
|
$wordInBookCounter=0;
|
|
|
$strFirstBookList="(";
|
|
$strFirstBookList="(";
|
|
@@ -208,16 +193,17 @@ switch($op){
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ $result["time"][]=array("event"=>"准备查询","time"=>microtime(true)-$_start);
|
|
|
//前20条记录
|
|
//前20条记录
|
|
|
$time_start=microtime_float();
|
|
$time_start=microtime_float();
|
|
|
$dictFileName=_FILE_DB_PALI_INDEX_;
|
|
$dictFileName=_FILE_DB_PALI_INDEX_;
|
|
|
PDO_Connect("sqlite:$dictFileName");
|
|
PDO_Connect("sqlite:$dictFileName");
|
|
|
$query = "SELECT count(*) from (SELECT book FROM word WHERE \"wordindex\" in $strQueryWordId $strQueryBookId group by book,paragraph) where 1 ";
|
|
$query = "SELECT count(*) from (SELECT book FROM word WHERE \"wordindex\" in $strQueryWordId $strQueryBookId group by book,paragraph) where 1 ";
|
|
|
$result["record_count"]= PDO_FetchOne($query);
|
|
$result["record_count"]= PDO_FetchOne($query);
|
|
|
|
|
+ $result["time"][]=array("event"=>"查询记录数","time"=>microtime(true)-$_start);
|
|
|
$query = "SELECT book,paragraph, wordindex, sum(weight) as wt FROM word WHERE \"wordindex\" in $strQueryWordId $strQueryBookId GROUP BY book,paragraph ORDER BY wt DESC LIMIT 0,20";
|
|
$query = "SELECT book,paragraph, wordindex, sum(weight) as wt FROM word WHERE \"wordindex\" in $strQueryWordId $strQueryBookId GROUP BY book,paragraph ORDER BY wt DESC LIMIT 0,20";
|
|
|
$Fetch = PDO_FetchAll($query);
|
|
$Fetch = PDO_FetchAll($query);
|
|
|
-
|
|
|
|
|
|
|
+ $result["time"][]=array("event"=>"查询结束","time"=>microtime(true)-$_start);
|
|
|
$out_data = array();
|
|
$out_data = array();
|
|
|
|
|
|
|
|
$queryTime=(microtime_float()-$time_start)*1000;
|
|
$queryTime=(microtime_float()-$time_start)*1000;
|
|
@@ -238,9 +224,6 @@ switch($op){
|
|
|
$c2=$bookInfo->c2;
|
|
$c2=$bookInfo->c2;
|
|
|
$c3=$bookInfo->c3;
|
|
$c3=$bookInfo->c3;
|
|
|
|
|
|
|
|
- //echo "<div class='dict_word' style='margin: 10px 0;padding: 5px;border-bottom: 1px solid var(--border-line-color);'>";
|
|
|
|
|
- //echo "<div style='font-size: 130%;font-weight: 700;'>$paliword</div>";
|
|
|
|
|
- //echo "<div class='dict_word'>";
|
|
|
|
|
$path_1 = $c1.">";
|
|
$path_1 = $c1.">";
|
|
|
if($c2 !== ""){
|
|
if($c2 !== ""){
|
|
|
$path_1=$path_1.$c2.">";
|
|
$path_1=$path_1.$c2.">";
|
|
@@ -277,117 +260,15 @@ switch($op){
|
|
|
$newRecode["book"] = $book;
|
|
$newRecode["book"] = $book;
|
|
|
$newRecode["para"] = $paragraph;
|
|
$newRecode["para"] = $paragraph;
|
|
|
$newRecode["palitext"] = $FetchPaliText[0]["html"];
|
|
$newRecode["palitext"] = $FetchPaliText[0]["html"];
|
|
|
- $newRecode["keyword"] = $paliword;
|
|
|
|
|
- $newRecode["wt"] = $Fetch[$i]["wt"];
|
|
|
|
|
-// echo "<div class='mean' style='font-size:120%'><a href='../reader/?view=para&book={$book}¶={$paragraph}' target='_blank'>$path</a></div>";
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $newRecode["keyword"] = array($paliword);
|
|
|
|
|
+ $newRecode["wt"] = $Fetch[$i]["wt"];
|
|
|
$out_data[] = $newRecode;
|
|
$out_data[] = $newRecode;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- $queryTime=(microtime_float()-$time_start)*1000;
|
|
|
|
|
|
|
+ $result["time"][]=array("event"=>"查询路径结束","time"=>microtime(true)-$_start);
|
|
|
$result["data"] = $out_data;
|
|
$result["data"] = $out_data;
|
|
|
echo json_encode($result,JSON_UNESCAPED_UNICODE);
|
|
echo json_encode($result,JSON_UNESCAPED_UNICODE);
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- case "update":
|
|
|
|
|
- $target=$_GET["target"];
|
|
|
|
|
- switch($target){
|
|
|
|
|
- case "bold";
|
|
|
|
|
- $wordlist=$_GET["wordlist"];
|
|
|
|
|
- $booklist=$_GET["booklist"];
|
|
|
|
|
- $aBookList=ltrim($booklist,"(");
|
|
|
|
|
- $aBookList=rtrim($aBookList,")");
|
|
|
|
|
- $aBookList=str_replace("'","",$aBookList);
|
|
|
|
|
- $aBookList=str_getcsv($aBookList);
|
|
|
|
|
- $arrBookType=json_decode(file_get_contents("../public/book_name/booktype.json"));
|
|
|
|
|
- //查找这些词出现在哪些书中
|
|
|
|
|
- $newBookList=render_book_list($wordlist,$aBookList);
|
|
|
|
|
-
|
|
|
|
|
- //前20条记录
|
|
|
|
|
- $time_start=microtime_float();
|
|
|
|
|
- $dictFileName=_FILE_DB_PALI_INDEX_;
|
|
|
|
|
- PDO_Connect("sqlite:$dictFileName");
|
|
|
|
|
-
|
|
|
|
|
- $query = "select * from word where \"wordindex\" in $wordlist and \"book\" in $booklist group by book,paragraph limit 0,20";
|
|
|
|
|
- $Fetch = PDO_FetchAll($query);
|
|
|
|
|
- $queryTime=(microtime_float()-$time_start)*1000;
|
|
|
|
|
- //echo "<div >搜索时间:$queryTime </div>";
|
|
|
|
|
- if($booklist=="()"){
|
|
|
|
|
- echo "<div >请选择书名</div>";
|
|
|
|
|
- }
|
|
|
|
|
- $iFetch=count($Fetch);
|
|
|
|
|
- if($iFetch>0){
|
|
|
|
|
- $dictFileName=_FILE_DB_PALITEXT_;
|
|
|
|
|
- PDO_Connect("sqlite:$dictFileName");
|
|
|
|
|
- for($i=0;$i<$iFetch;$i++){
|
|
|
|
|
- $paliword=$Fetch[$i]["wordindex"];
|
|
|
|
|
- //$paliword=$wordlist["{$paliwordid}"];
|
|
|
|
|
-
|
|
|
|
|
- $book=$Fetch[$i]["book"];
|
|
|
|
|
- $bookInfo = _get_book_info($book);
|
|
|
|
|
- $bookname=$bookInfo->title;
|
|
|
|
|
- $c1=$bookInfo->c1;
|
|
|
|
|
- $c2=$bookInfo->c2;
|
|
|
|
|
- $c3=$bookInfo->c3;
|
|
|
|
|
- $paragraph=$Fetch[$i]["paragraph"];
|
|
|
|
|
-
|
|
|
|
|
- $path_1 = $c1.">";
|
|
|
|
|
- if($c2 !== ""){
|
|
|
|
|
- $path_1=$path_1.$c2.">";
|
|
|
|
|
- }
|
|
|
|
|
- if($c3 !== ""){
|
|
|
|
|
- $path_1=$path_1.$c3.">";
|
|
|
|
|
- }
|
|
|
|
|
- $path_1=$path_1."《{$bookname}》>";
|
|
|
|
|
-
|
|
|
|
|
- echo "<div class='dict_word'>";
|
|
|
|
|
- echo "<div class='book' ><span style='font-size:110%;font-weight:700;'>《{$bookname}》</span> <tag>$c1</tag> <tag>$c2</tag> </div>";
|
|
|
|
|
- echo "<div class='mean'>$paliword</div>";
|
|
|
|
|
-
|
|
|
|
|
- $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$paragraph}' limit 0,20";
|
|
|
|
|
- $FetchPaliText = PDO_FetchAll($query);
|
|
|
|
|
- $countPaliText=count($FetchPaliText);
|
|
|
|
|
- if($countPaliText>0){
|
|
|
|
|
- for($iPali=0;$iPali<$countPaliText;$iPali++){
|
|
|
|
|
- $path="";
|
|
|
|
|
- $parent = $FetchPaliText[0]["parent"];
|
|
|
|
|
- $deep=0;
|
|
|
|
|
- $sFirstParentTitle="";
|
|
|
|
|
- while($parent>-1){
|
|
|
|
|
- $query = "select * from pali_text where \"book\" = '{$book}' and \"paragraph\" = '{$parent}' limit 0,1";
|
|
|
|
|
- $FetParent = PDO_FetchAll($query);
|
|
|
|
|
- if($sFirstParentTitle==""){
|
|
|
|
|
- $sFirstParentTitle = $FetParent[0]["toc"];
|
|
|
|
|
- }
|
|
|
|
|
- $path="{$FetParent[0]["toc"]}>{$path}";
|
|
|
|
|
- $parent = $FetParent[0]["parent"];
|
|
|
|
|
- $deep++;
|
|
|
|
|
- if($deep>5){
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- $path=$path."No. ".$paragraph;
|
|
|
|
|
- echo "<div class='mean' style='font-size:120%;'><a href='../reader/?view=para&book={$book}¶={$paragraph}' target='_blank' >$path</a></div>";
|
|
|
|
|
-
|
|
|
|
|
- if(substr($paliword,-1)=="n"){
|
|
|
|
|
- $paliword=substr($paliword,0,-1);
|
|
|
|
|
- }
|
|
|
|
|
- $light_text=str_replace($paliword,"<hl>{$paliword}</hl>",$FetchPaliText[$iPali]["html"]);
|
|
|
|
|
- echo "<div class='wizard_par_div'>{$light_text}</div>";
|
|
|
|
|
- echo "<div class='search_para_tools'></div>";
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- echo "</div>";
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- break;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
?>
|
|
?>
|