word_list.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. //全文搜索
  3. require_once '../path.php';
  4. require_once '../public/casesuf.inc';
  5. require_once '../public/union.inc';
  6. require_once "../public/_pdo.php";
  7. require_once "../public/load_lang.php";//语言文件
  8. require_once "../public/function.php";
  9. require_once "../search/word_function.php";
  10. $resulte = array();
  11. if(isset($_GET["word"])){
  12. $word=mb_strtolower($_GET["word"],'UTF-8');
  13. }
  14. else{
  15. echo json_encode($resulte,JSON_UNESCAPED_UNICODE);
  16. exit;
  17. }
  18. _load_book_index();
  19. $count_return=0;
  20. $dict_list=array();
  21. //计算某词在三藏中出现的次数
  22. $arrRealWordList = countWordInPali($word);
  23. $countWord=count($arrRealWordList);
  24. if($countWord==0){
  25. echo "<p>没有查到。可能是拼写有问题。</p>";
  26. exit;
  27. }
  28. $strQueryWordId="(";//实际出现的单词id查询字串
  29. $aQueryWordList=array();//id 为键 拼写为值的数组
  30. $aShowWordList=array();//拼写为键 个数为值的数组
  31. $aShowWordIdList=array();//拼写为键 值Id的数组
  32. for($i=0;$i<$countWord;$i++){
  33. $value= $arrRealWordList[$i];
  34. $strQueryWordId.="'{$value["id"]}',";
  35. $aQueryWordList[$value["id"]]=$value["word"];
  36. $aShowWordList[$value["word"]]=$value["count"];
  37. $aShowWordIdList[$value["word"]]=$value["id"];
  38. }
  39. $strQueryWordId=mb_substr($strQueryWordId, 0,mb_strlen($strQueryWordId,"UTF-8")-1,"UTF-8");
  40. $strQueryWordId.=")";
  41. //显示单词列表
  42. arsort($aShowWordList);
  43. $i=0;
  44. $wordlist=array();
  45. $wordlist_index = array();
  46. $sutta = array();
  47. $vinaya = array();
  48. $abhidhamma = array();
  49. $anna = array();
  50. foreach($aShowWordList as $x=>$x_value) {
  51. $wordid=$aShowWordIdList[$x];
  52. $wordlist[] = $x;
  53. $wordlist_index[$x] = $i;
  54. $sutta[]=0;
  55. $vinaya[]=0;
  56. $abhidhamma[]=0;
  57. $anna[]=0;
  58. //echo $x.":".$x_value."<br />";
  59. $i++;
  60. }
  61. $resulte["wordlist"] = $wordlist;
  62. //查找这些词出现在哪些书中
  63. $arrBookType=json_decode(file_get_contents("../public/book_name/booktype.json"));
  64. $dictFileName=_FILE_DB_BOOK_WORD_;
  65. PDO_Connect("sqlite:$dictFileName");
  66. if(isset($booklist)){
  67. foreach($booklist as $oneBook){
  68. $aInputBook["{$oneBook}"]=1;
  69. }
  70. }
  71. $query = "select book, wordindex,count from bookword where \"wordindex\" in $strQueryWordId ";
  72. $Fetch = PDO_FetchAll($query);
  73. $iFetch=count($Fetch);
  74. $newBookList=array();
  75. $worddata = array();
  76. if($iFetch>0){
  77. for($i=0;$i<$iFetch;$i++){
  78. $book=$Fetch[$i]["book"];
  79. array_push($newBookList,array($book,$sum));
  80. $t1=$arrBookType[$book-1]->c1;
  81. $t2=$arrBookType[$book-1]->c2;
  82. switch($t1){
  83. case "sutta":
  84. $x = $aQueryWordList[$Fetch[$i]["wordindex"]];
  85. $sutta[$wordlist_index[$x]] += $Fetch[$i]["count"] ;
  86. break;
  87. case "vinaya":
  88. $x = $aQueryWordList[$Fetch[$i]["wordindex"]];
  89. $vinaya[$wordlist_index[$x]] += $Fetch[$i]["count"] ;
  90. break;
  91. case "abhidhamma":
  92. $x = $aQueryWordList[$Fetch[$i]["wordindex"]];
  93. $abhidhamma[$wordlist_index[$x]] += $Fetch[$i]["count"] ;
  94. break;
  95. case "anna":
  96. $x = $aQueryWordList[$Fetch[$i]["wordindex"]];
  97. $anna[$wordlist_index[$x]] += $Fetch[$i]["count"] ;
  98. break;
  99. }
  100. }
  101. }
  102. $worddata[] = array( "name" => "anna","anna" => $anna);
  103. $worddata[] = array( "name" => "abhidhamma","data" => $abhidhamma);
  104. $worddata[] = array( "name" => "vinaya","data" => $vinaya);
  105. $worddata[] = array( "name" => "sutta","data" => $sutta);
  106. $resulte["data"] = $worddata;
  107. echo json_encode($resulte,JSON_UNESCAPED_UNICODE);
  108. ?>