Forráskód Böngészése

升级相似句库 经验值统计

visuddhinanda 5 éve
szülő
commit
349890912f

+ 2 - 1
app/dict/split.php

@@ -435,7 +435,7 @@ function mySplit2($strWord,$deep,$express=false,$adj_len=0,$c_threshhold=0.8){
 					$str1=mb_substr($strWord,0,$i-$row["len"],"UTF-8").$row["a"];
 					$str2=$row["b"].mb_substr($strWord,$i,NULL,"UTF-8");
 					$confidence=isExsit($str1,$adj_len);
-					if($confidence >= $c_threshhold){
+					if($confidence > $c_threshhold){
 						$output[] = array($str1,$str2,$confidence,$row["adj_len"]);
 						if($express){
 							break;
@@ -446,6 +446,7 @@ function mySplit2($strWord,$deep,$express=false,$adj_len=0,$c_threshhold=0.8){
 			}
 		}
 	}
+
 	if(count($output)>0){
 		foreach($output as $part){
 			$path[$deep][0]=$part[0];

+ 51 - 0
app/install/db_insert_sim.php

@@ -0,0 +1,51 @@
+<?php 
+/*
+用相似句导入数据库
+*/
+
+?>
+<?php
+require_once '../public/_pdo.php';
+require_once '../path.php';
+
+$filelist=array();
+$fileNums=0;
+$log="";
+echo "start\n";
+
+$db_file = _DIR_PALICANON_."/pali_sim.db3";
+PDO_Connect("sqlite:$db_file");
+
+// 开始一个事务,关闭自动提交
+$PDO->beginTransaction();
+$query="INSERT INTO sent_sim ('sent1','sent2','sim') VALUES (? , ? , ?)";
+$stmt = $PDO->prepare($query);
+
+// 打开文件并读取数据
+$count = 0;
+if(($fp=fopen(_DIR_TMP_."/pali_simsent/sim.csv", "r"))!==FALSE){
+	while(($data=fgetcsv($fp,0,','))!==FALSE){
+		$stmt->execute($data);
+		$count++;
+		if($count%1000000==0){
+			echo $count."\n";
+		}
+	}
+	fclose($fp);
+}
+else{
+	echo "can not open csv file. ";
+}
+
+// 提交更改 
+$PDO->commit();
+if (!$stmt || ($stmt && $stmt->errorCode() != 0)) {
+	$error = PDO_ErrorInfo();
+	
+	echo " error, $error[2] \r\n";
+}
+else{
+	echo "updata $count recorders.";
+}
+
+?>

+ 18 - 8
app/pali_sent/get_sim.php

@@ -6,31 +6,41 @@ require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once "../public/function.php";
 
-$sim = $_POST["sim"];
+//获取相似句子列表
 
-$simList = json_decode($sim);
+if(isset($_POST["sent_id"])){
+	$dns = "sqlite:"._FILE_DB_PALI_SENTENCE_SIM_;
+	$dbh_sim = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+	$dbh_sim->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); 
+	$query="SELECT sent2 FROM sent_sim WHERE  sent1 = ? limit 0 , 10";
+	$stmt = $dbh_sim->prepare($query);
+	$stmt->execute(array($_POST["sent_id"]));
+	$simList = $stmt->fetchAll(PDO::FETCH_ASSOC);
+}
+else{
+	$sim = $_POST["sim"];
+	$simList = json_decode($sim);
+
+}
 $output = array();
 
 $dns = "sqlite:"._FILE_DB_PALI_SENTENCE_;
 $dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
 $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
 
-$query="SELECT * FROM pali_sent WHERE  id = ?   ";
+$query="SELECT * FROM pali_sent WHERE  id = ? ";
 $stmt = $dbh->prepare($query);
 $count = 0;
 foreach ($simList as  $value) {
     # code...
-    $stmt->execute(array($value));
+    $stmt->execute(array($value["sent2"]));
 	$Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
 	if($Fetch){
 		$sent = $Fetch;
 		$sent["path"]=_get_para_path($Fetch["book"],$Fetch["paragraph"]);
 		$output[] = $sent;  
 	}
-	$count++;
-	if($count>15){
-		break;
-	}
+
 }
 
 echo json_encode($output, JSON_UNESCAPED_UNICODE);

+ 5 - 1
app/path.php

@@ -13,7 +13,8 @@ define("_FILE_DB_RESRES_INDEX_"  , __DIR__."/../tmp/appdata/palicanon/res.db3");
 define("_FILE_DB_PALITEXT_" , __DIR__."/../tmp/appdata/palicanon/pali_text.db3");
 define("_FILE_DB_STATISTICS_" , __DIR__."/../tmp/appdata/palicanon/word_statistics.db3");
 define("_FILE_DB_PALI_SENTENCE_" , __DIR__."/../tmp/appdata/palicanon/pali_sent.db3");
-define("_FILE_DB_PALI_SENTENCE_SIM_" , __DIR__."/../tmp/appdata/palicanon/pali_sent_sim.db3");
+define("_FILE_DB_PALI_SENTENCE_SIM_" , __DIR__."/../tmp/appdata/palicanon/pali_sim.db3");
+//define("_FILE_DB_PALI_SENTENCE_SIM_" , __DIR__."/../tmp/appdata/palicanon/pali_sent_sim.db3");
 define("_FILE_DB_INDEX_"  , __DIR__."/../tmp/appdata/palicanon/index.db3");
 define("_FILE_DB_WORD_INDEX_"  , __DIR__."/../tmp/appdata/palicanon/wordindex.db3");
 define("_FILE_DB_PALI_INDEX_"  , __DIR__."/../tmp/appdata/palicanon/paliindex.db3");
@@ -29,6 +30,8 @@ define("_DIR_CSV_PALI_CANON_WORD_INDEX_" , __DIR__."/../paliword/index");
 define("_DIR_PALI_CSV_" , __DIR__."/../tmp/palicsv");
 define("_DIR_LOG_" , __DIR__."/../tmp/log");
 define("_DIR_TEMP_" , __DIR__."/../tmp/temp");
+define("_DIR_TMP_" , __DIR__."/../tmp");
+
 
 //dictionary
 define("_DIR_DICT_" , __DIR__."/../tmp/appdata/dict");
@@ -74,5 +77,6 @@ define("_FILE_DB_USER_DICT_"  , __DIR__."/../tmp/user/udict.db3");
 define("_FILE_DB_USER_ARTICLE_"  , __DIR__."/../tmp/user/article.db3");
 define("_FILE_DB_HOSTSETTING_"  , __DIR__."/../tmp/user/hostsetting.db3");
 define("_FILE_DB_USER_SENTENCE_HISTORAY_"  , __DIR__."/../tmp/user/usent_historay.db3");
+define("_FILE_DB_USER_ACTIVE_"  , __DIR__."/../tmp/user/user_active.db3");
 
 ?>

+ 2 - 2
app/reader/get_path.php

@@ -1,6 +1,6 @@
 <?php
 require_once "../public/function.php";
-
+/*
 $dns = "sqlite:"._FILE_DB_PALITEXT_;
 $dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
 $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
@@ -39,6 +39,6 @@ $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
 	  }
   }
   $dbh = null;
-  
+*/
 echo _get_para_path($_GET["book"],$_GET["para"]);
 ?>

+ 3 - 7
app/term/note.js

@@ -492,11 +492,11 @@ function note_json_html(in_json) {
 	output += "<span class='other_bar' >";
 	output +=
 		"<span class='similar_sent_span' onclick=\"note_show_pali_sim('" +
-		in_json.id +
+		in_json.pali_sent_id +
 		"')\">" +
 		gLocal.gui.similar_sentences +
 		"</span>";
-	output += "<span class='similar_sent_num'>" + in_json.sim.length + "</span>";
+	output += "<span class='similar_sent_num'>" + in_json.sim + "</span>";
 	output += "</span>";
 	output += "</div>";
 	output += "<div class='other_tran'>";
@@ -932,11 +932,7 @@ function setVisibility(key, value) {
 }
 
 function note_show_pali_sim(SentId) {
-	for (const iterator of _arrData) {
-		if (iterator.id == SentId) {
-			pali_sim_dlg_open(SentId, iterator.sim);
-		}
-	}
+	pali_sim_dlg_open(SentId, 0, 20);
 }
 
 function set_pali_script(pos, script) {

+ 4 - 3
app/term/note.php

@@ -85,15 +85,15 @@ foreach ($_data as $key => $value) {
 		$palitext="";
 		$pali_text_id = 0;
 	}
-	$query="SELECT sim_sents FROM 'pali_sent_sim' WHERE id = ?  ";
+	$query="SELECT count FROM 'sent_sim_index' WHERE sent_id = ? ";
 	$sth = $db_pali_sent_sim->prepare($query);
 	$sth->execute(array($pali_text_id));
 	$row = $sth->fetch(PDO::FETCH_ASSOC);
 	if($row){
-		$pali_sim= explode(",",$row["sim_sents"]) ;
+		$pali_sim= $row["count"];//explode(",",$row["sim_sents"]) ;
 	}
 	else{
-		$pali_sim=array();
+		$pali_sim=0;
 	}
 		//查询相似句
 
@@ -184,6 +184,7 @@ foreach ($_data as $key => $value) {
 
 	$output[]=array("id"=>$id,
 							   "palitext"=>$palitext,
+							   "pali_sent_id"=>$pali_text_id,
 							   "tran"=>$tran,
 							   "translation"=>$translation,
 							   "ref"=>$para_path,

+ 4 - 3
app/term/pali_sim_sent.js

@@ -14,13 +14,14 @@ function pali_sim_dlg_init(title = "Sim") {
 		],
 	});
 }
-function pali_sim_dlg_open(id, sim_id) {
+function pali_sim_dlg_open(id, start, length) {
 	{
 		$.post(
 			"../pali_sent/get_sim.php",
 			{
-				id: id,
-				sim: JSON.stringify(sim_id),
+				sent_id: id,
+				start: start,
+				length: length,
 			},
 			function (data) {
 				let sents = JSON.parse(data);

+ 58 - 0
app/ucenter/active.php

@@ -0,0 +1,58 @@
+<?php 
+//统计用户经验值
+require_once '../path.php';
+require_once "../public/_pdo.php";
+require_once "../public/function.php";
+
+define("MAX_INTERVAL",600000);
+
+if(isset($_COOKIE["userid"])){
+	$dns = "sqlite:"._FILE_DB_USER_ACTIVE_;
+    $dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
+	$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);  
+	// 查询上次编辑活跃结束时间
+	$query = "SELECT id, end, start,hit  FROM edit WHERE user_id = ? order by end DESC";
+	$stmt = $dbh->prepare($query);
+	$stmt->execute(array($_COOKIE["userid"]));
+	$row = $stmt->fetch(PDO::FETCH_ASSOC);
+	$new_record = false;
+	$currTime = mTime();
+    if ($row) {
+		//找到,判断是否超时,超时新建,未超时修改
+		$endtime = (int)$row["end"];
+		$id = (int)$row["id"];
+		$start_time = (int)$row["start"];
+		$hit = (int)$row["hit"];
+		if($currTime-$endtime>MAX_INTERVAL){
+			//超时新建
+			$new_record = true;
+		}
+		else{
+			//未超时修改
+			$new_record = false;
+		}
+    } else {
+		//没找到,新建
+        $new_record = true;
+	}
+
+	if($new_record){
+		$query="INSERT INTO edit ( user_id, start , end  , duration , hit )  VALUES  ( ? , ? , ? , ? , ? ) ";
+		$sth = $dbh->prepare($query);
+		$sth->execute(array($_COOKIE["userid"] , $currTime , $currTime , 10000,1) );
+		if (!$sth || ($sth && $sth->errorCode() != 0)) {
+			$error = $dbh->errorInfo();
+		}
+	}
+	else{
+
+		$query="UPDATE edit SET end = ? , duration = ? , hit = ? WHERE id = ? ";
+		$sth = $dbh->prepare($query);
+		$sth->execute( array($currTime,($currTime-$start_time), ($hit+1),$id));
+		if (!$sth || ($sth && $sth->errorCode() != 0)) {
+			$error = $dbh->errorInfo();
+		}
+	}
+}
+
+?>

+ 3 - 0
app/ucenter/active_analysis.php

@@ -0,0 +1,3 @@
+<?php
+
+?>

+ 1 - 0
app/uwbw/update.php

@@ -5,6 +5,7 @@ get xml doc from db
 require_once "../path.php";
 require_once "../public/_pdo.php";
 require_once "../public/function.php";
+require_once "../ucenter/active.php";
 
 
 $aData=json_decode($_POST["data"]);

+ 3 - 79
documents/users_guide/zh-cn/dict_search_input.md

@@ -2,7 +2,7 @@
 
 输入框中支持用**加号**分隔单词中各个组成部分。
 
-- 如:输入 citta+kamma
+-   如:输入 citta+kamma
 
 其组分将在输入框下方显示,点击搜索框下方的**组分**查询每个组分的意思。
 
@@ -10,81 +10,5 @@
 
 词典列表下方的**拼写列表**中,穷举了一切存在的**变化形式**以及在语料库中的出现频率。
 
-## 语法缩略语表
-| 巴利        | 英           | 中文     | 全                          |
-| :---------- | :----------- | :------- | :-------------------------- |
-| na          | nt.          | 中       | neuter                      |
-| pu          | m.           | 阳       | masculine                   |
-| thī         | f.           | 阴       | feminine                    |
-| eka         | u            | 单       | singular                    |
-| bahu        | pl.          | 复       | plural                      |
-| paccatta    | nom.         | 主       | nominative                  |
-| upayoga     | acc.         | 宾       | accusative                  |
-| karaṇa      | inst.        | 具       | instrumental                |
-| sampadāna   | dat.         | 目的     | dative                      |
-| nissakka    | abl.         | 源       | ablative                    |
-| sāmi        | gen.         | 属       | genitive                    |
-| bhumma      | loc.         | 处       | locative                    |
-| āmantana    | voc.         | 呼       | vocative                    |
-| āṇatti      | imp.         | 命令     | imperative                  |
-| parikappa   | cond.        | 条件     | conditional                 |
-| parikappa   | opt.         | 潜       | optative (potential)        |
-| paccuppanna | pres.        | 现       | present tense               |
-| atīta       | aor.         | 过       | past tense                  |
-| anāgata     | fut.         | 将       | future tense                |
-| amha        | 1p.          | 第一     | 1st person                  |
-| tumha       | 2p.          | 第二     | 2nd person                  |
-| ta          | 3p.          | 第三     | 3rd perspm                  |
-|             | Ger.         | 连续     |                             |
-|             | Abs.         | 绝对     | absolutive                  |
-|             | Inf.         | 不定     | infinitive                  |
-|             | prp.         | 现分     | present participle          |
-|             | pp.          | 过分     | past participle             |
-|             | fpp.         | 未被分   | passive future participle   |
-|             | Grd.         | 义务     |                             |
-| nāma        | n.           | 名       | noun                        |
-| kriyā       | v.           | 动       | verb                        |
-| kriyā:bya   | v.ind.       | 动不变   | verb indeclinable           |
-| bya         | ind.         | 不变     | indeclinable                |
-| karaṇattha  | adv.         | 副       | adverb                      |
-| ti          | adj.         | 形       | adjective                   |
-| ti          | n.a.         | 三性     | of the three gender         |
-|             | num.         | 数       | numerals                    |
-|             | pron.        | 代       | pronoun                     |
-|             | v:base.      | 动原型   | verb : root                 |
-|             | n.a:base.    | 三性词干 |                             |
-|             | adj:base.    | 形词干   |                             |
-|             | n:base.      | 名词干   |                             |
-|             | pron:base.   | 代词干   |                             |
-|             | num:base.    | 数词干   | numerals : root             |
-|             | conj.        | 连       | cojunction                  |
-|             | prep.        | 介       | preposition                 |
-|             | interj.      | 感叹     | interjection                |
-| samāsa.     | comp.        | 复合     |                             |
-|             | prefix.      | 前缀     | prefix                      |
-|             | part         | 待定片段 |                             |
-| dhātu       | root.        | 词根     |                             |
-|             | suffix.      | 后缀     |                             |
-| vibhatti    | case end.    | 语尾     |                             |
-| sandhi      | slur.        | 连读     |                             |
-|             | note.        | 原版注释 | note from original article  |
-|             | pf.          | 完成     | perfect tense               |
-|             | act.         | 主动     | active                      |
-|             | prpa.        | 主动现分 | active present participle   |
-|             | prpp.        | 现分     | passive  present participle |
-|             | ppa.         | 主过分   | active past participle      |
-|             | ppp.         | 被过分   | passive  past participle    |
-|             | futp.        | 未分     | future participle           |
-|             | fpa.         | 未主分   | active future participle    |
-|             | Pass.        | 被动     | passive                     |
-|             | Caus.        | 使役     |                             |
-|             | desid.       | 意欲     |                             |
-|             | intens.      | 强意     | intensive                   |
-|             | denom.       | 名动     | demonstrative               |
-|             | pron.per.    | 人代     | personal pronoun            |
-|             | pron.demon.  | 指代     | demonstrative pronoun       |
-|             | pron.rel.    | 关代     | relative pronoun            |
-|             | pron.interr. | 疑代     | interrogative pronoun       |
-|             | pron.indef.  | 不定代   | indefinite pronoun          |
-| attano      | med.         | 返照     |                             |
-| attano      | refl.        | 返照     | reflexive                   |
+nama
+后缀