Ver Fonte

turbo split

visuddhinanda há 5 anos atrás
pai
commit
1468fbc70a

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 1
app/dict/README.md


+ 43 - 21
app/dict/comp_csv.php

@@ -4,10 +4,24 @@ require_once "../path.php";
 require_once "../dict/turbo_split.php";
 require_once "../redis/function.php";
 
+if (isset($argv[1])) {
+	$start = (int)$argv[1];
+}
+else{
+	$start=0;
+}
+
+if (isset($argv[2])) {
+	$end = (int)$argv[2];
+}
+else{
+	$end=1000000;
+}
+
 global $result;
 $myfile = fopen(_DIR_TEMP_ . "/comp.csv", "a");
 $filefail = fopen(_DIR_TEMP_ . "/comp_fail.txt", "a");
-$iMax = 10;
+$iMax = 2;//输出前三个结果
 /*
 $dns = "" . _FILE_DB_WORD_INDEX_;
 $dbh_word = new PDO($dns, "", "", array(PDO::ATTR_PERSISTENT => true));
@@ -26,8 +40,16 @@ if ($redis == false) {
 $i = null;
 $counter = 0;
 while ($words = $redis->sscan("pali_word", $i)) {
-    # code...
-
+	# code...
+	
+	if($counter<$start){
+		$counter+=10;
+		continue;
+	}
+	if($counter>$end){
+		echo "all done";
+		exit;
+	}
     foreach ($words as $key => $word) {
         # code...
         $arrword = split_diphthong($word);
@@ -37,16 +59,22 @@ while ($words = $redis->sscan("pali_word", $i)) {
 
         foreach ($arrword as $oneword) {
             $counter++;
-            $result = array(); //全局变量,递归程序的输出容器
+			$result = array(); //全局变量,递归程序的输出容器
+			mySplit2($oneword, 0, true, 0.5, 0.9, 0, true, false);
+			if(count($result)<2){
+				mySplit2($oneword, 0, $_express, 0.2, 0.9, 0, true, true);
+				if (isset($_POST["debug"])) {
+					echo "正切:" . count($result) . "\n";
+				}
+				if(count($result)<2){
+					mySplit2($oneword, 0, $_express, 0.2, 0.8, 0, false, true);
+					if (isset($_POST["debug"])) {
+						echo "反切:" . count($result) . "\n";
+					}					
+				}
+				
+			}
 
-            mySplit2($oneword, 0, $_express, 0, 0.01, 0.01, true, true);
-            if (isset($_POST["debug"])) {
-                echo "正切:" . count($result) . "\n";
-            }
-            mySplit2($oneword, 0, $_express, 0, 0.01, 0.01, false, true);
-            if (isset($_POST["debug"])) {
-                echo "反切:" . count($result) . "\n";
-            }
             /*
             #正向切分
             mySplit2($oneword, 0, false);
@@ -60,14 +88,9 @@ while ($words = $redis->sscan("pali_word", $i)) {
                 arsort($result); //按信心指数排序
                 $iCount = 0;
                 foreach ($result as $row => $value) {
-                    $iCount++;
-                    if ($value > 0.8) {
-                        fputcsv($myfile, array($oneword, $row, $value));
-                    } else {
-                        fputcsv($filefail, array($oneword, $row, $value));
-                    }
-
-                    if ($iCount >= $iMax) {
+					fputcsv($myfile, array($oneword, $row, $value));
+					$iCount++;
+                    if ($iCount > $iMax) {
                         break;
                     }
                 }
@@ -79,4 +102,3 @@ while ($words = $redis->sscan("pali_word", $i)) {
 
     }
 }
-while ($i = $words[0] != 0);

+ 17 - 12
app/dict/dict.js

@@ -23,14 +23,17 @@ function dict_search(word) {
 	$.get(
 		"dict_lookup.php",
 		{
-			op: "search",
 			word: word,
 		},
 		function (data, status) {
 			$("#dict_search_result").html(data);
-			$("#dict_list").html($("#dictlist").html());
-			$("#dictlist").html("");
+			$("#dict_list").append($("#dictlist"));
+			$("#search_result_shell").append($("#search_summary"));
 			guide_init();
+			let word_count = parseInt($("#word_count").val());
+			if (word_count < 3) {
+				trubo_split();
+			}
 		}
 	);
 }
@@ -131,15 +134,16 @@ function dict_input_keyup(e, obj) {
 
 function dict_input_split(word) {
 	if (word.indexOf("+") >= 0) {
-		var wordParts = word.split("+");
-		var strParts = "";
-		for (var i in wordParts) {
-			//strParts += "<div class='part_list'><a onclick='dict_search(\"" + wordParts[i] + "\")'>" + wordParts[i] + "</a></div>";
-			strParts += "<part><a onclick='dict_search(\"" + wordParts[i] + "\")'>" + wordParts[i] + "</a></part>";
+		let wordParts = word.split("+");
+		let strParts = "";
+		for (const iterator of wordParts) {
+			strParts += "<part><a onclick='dict_search(\"" + iterator + "\")'>" + iterator + "</a></part>";
 		}
-		strParts =
-			"<div class='dropdown_ctl'><div class='content'><div class='main_view' >" + strParts + "</div></div></div>";
-		$("#input_parts").html(strParts);
+		let html =
+			"点击查词<div class='dropdown_ctl'><div class='content'><div class='main_view' >" +
+			strParts +
+			"</div></div></div>";
+		$("#input_parts").html(html);
 	} else {
 		$("#input_parts").html("");
 	}
@@ -170,6 +174,7 @@ function cls_word_search_history() {
 
 function trubo_split() {
 	$("#pre_search_result").hide();
+	$("#input_parts").html("正在自动切分复合词……");
 	$.post(
 		"split.php",
 		{
@@ -181,7 +186,7 @@ function trubo_split() {
 				let html = "<div>";
 				if (result.length > 0) {
 					for (const part of result[0]["data"]) {
-						html += '<div class="dropdown_ctl">';
+						html += '自动拆分结果<div class="dropdown_ctl">';
 						html += '<div class="content">';
 						html +=
 							'<div class="main_view">' +

+ 298 - 331
app/dict/dict_lookup.php

@@ -8,10 +8,10 @@ require_once "../public/load_lang.php"; //语言文件
 require_once "../public/function.php";
 require_once "../search/word_function.php";
 require_once "../ucenter/active.php";
+require_once "../dict/p_ending.php";
 
 _load_book_index();
 
-$op = $_GET["op"];
 $word = mb_strtolower($_GET["word"], 'UTF-8');
 $org_word = $word;
 
@@ -20,368 +20,335 @@ $dict_list = array();
 
 $right_word_list = "";
 
-global $PDO;
-function isExsit($word)
-{
-    global $PDO;
-    $query = "SELECT count(*) as co from " . _TABLE_DICT_REF_ . " where word = ? ";
-    $row = PDO_FetchOne($query, array($word));
-    if ($row[0] == 0) {
-        return false;
-    } else {
-        return true;
-    }
-}
-
-function myfunction($v1, $v2)
-{
-    return $v1 . "+" . $v2;
-}
-
-function mySplit($strWord)
-{
-    //echo("<br>".$strWord."<br>");
-    $doubleword = "kkggccjjṭṭḍḍttddppbb";
-    $len = mb_strlen($strWord, "UTF-8");
-    if ($len > 5) {
-        for ($i = $len - 1; $i > 3; $i--) {
-            $str1 = mb_substr($strWord, 0, $i, "UTF-8");
-            $str2 = mb_substr($strWord, $i, null, "UTF-8");
-            //echo "$str1 + $str2 = ";
-            if (isExsit($str1)) {
-                //echo "match";
-                $left2 = mb_substr($str2, 0, 2, "UTF-8");
-                if (mb_strpos($doubleword, $left2, 0, "UTF-8") !== false) {
-                    $str2 = mb_substr($str2, 1, null, "UTF-8");
+        add_edit_event(_DICT_LOOKUP_, $word);
+		echo "<div id='dict_list_shell' onclick='setNaviVisibility()'>";
+		echo "<div id='dict_list' class='dict_list_off'></div>";
+		echo "</div>";
+		echo "<div id='dict_ref'>";
+		echo "<div id='search_result_shell'></div>";
+		echo "<div class='pali_spell'><a name='{word_$word}'></a>" . $word . "</div>";
+        $dict_list_a = [];
+        //社区字典开始
+        PDO_Connect("" . _FILE_DB_WBW_);
+        $query = "SELECT *  from " . _TABLE_DICT_REF_ . " where pali = ? limit 0,100";
+        $Fetch = PDO_FetchAll($query, array($word));
+        $iFetch = count($Fetch);
+        $count_return += $iFetch;
+        if ($iFetch > 0) {
+            $userlist = array();
+            foreach ($Fetch as $value) {
+                if (isset($userlist[$value["creator"]])) {
+                    $userlist[$value["creator"]] += 1;
+                } else {
+                    $userlist[$value["creator"]] = 1;
                 }
-                return array($str1, $str2);
-            } else {
-                $str1 = $str1 . "a";
-                if (isExsit($str1)) {
-                    //echo "match";
-                    $left2 = mb_substr($str2, 0, 2, "UTF-8");
-                    if (mb_strpos($doubleword, $left2, 0, "UTF-8") !== false) {
-                        $str2 = mb_substr($str2, 1, null, "UTF-8");
-                    }
-                    return array($str1, $str2);
+                $userwordcase = $value["type"] . "#" . $value["gramma"];
+                if (isset($userdict["{$userwordcase}"])) {
+                    $userdict["{$userwordcase}"]["mean"] .= $value["mean"] . ";";
+                    $userdict["{$userwordcase}"]["factors"] .= $value["factors"];
+                } else {
+                    $userdict["{$userwordcase}"]["mean"] = $value["mean"];
+                    $userdict["{$userwordcase}"]["factors"] = $value["factors"];
                 }
+
+            }
+            echo "<div class='dict_word'>";
+            echo "<div class='dict'>{$_local->gui->com_dict}</div><a name='net'></a>";
+            $dict_list_a[] = array("net", $_local->gui->com_dict);
+
+            foreach ($userdict as $key => $value) {
+                echo "<div class='mean'>{$key}:{$value["mean"]}</div>";
             }
+            echo "<div><span>{$_local->gui->contributor}:</span>";
+            foreach ($userlist as $key => $value) {
+                echo $key . "[" . $value . "]";
+            }
+            echo "</div>";
+            echo "</div>";
         }
-        //not found
-        if (mb_substr($strWord, 0, 1, "UTF-8") == "ā") {
-            $strWord = 'a' . mb_substr($strWord, 1, null, "UTF-8");
-            for ($i = $len - 1; $i > 3; $i--) {
-                $str1 = mb_substr($strWord, 0, $i, "UTF-8");
-                $str2 = mb_substr($strWord, $i, null, "UTF-8");
-                //echo "$str1 + $str2 = ";
-                if (isExsit($str1)) {
-                    //echo "match";
-                    $left2 = mb_substr($str2, 0, 2, "UTF-8");
-                    if (mb_strpos($doubleword, $left2, 0, "UTF-8") !== false) {
-                        $str2 = mb_substr($str2, 1, null, "UTF-8");
+        //社区字典结束
+
+        PDO_Connect("" . _FILE_DB_REF_);
+        //直接查询
+        $query = "SELECT dict.dict_id,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where word = ? limit 0,100";
+
+        $Fetch = PDO_FetchAll($query, array($word));
+        $iFetch = count($Fetch);
+        $count_return += $iFetch;
+        if ($iFetch > 0) {
+            for ($i = 0; $i < $iFetch; $i++) {
+                $mean = $Fetch[$i]["mean"];
+                $dictid = $Fetch[$i]["dict_id"];
+                $dict_list[$dictid] = $Fetch[$i]["shortname"];
+                $dict_list_a[] = array("ref_dict_$dictid", $Fetch[$i]["shortname"]);
+                $outXml = "<div class='dict_word'>";
+                $outXml = $outXml . "<a name='ref_dict_$dictid'></a>";
+                $outXml = $outXml . "<div class='dict'>" . $Fetch[$i]["shortname"] . "</div>";
+                $outXml = $outXml . "<div class='mean'>" . $mean . "</div>";
+                $outXml = $outXml . "</div>";
+                echo $outXml;
+            }
+		}
+		
+
+        //去格位除尾查
+        $newWord = array();
+        for ($row = 0; $row < count($case); $row++) {
+            $len = mb_strlen($case[$row][1], "UTF-8");
+            $end = mb_substr($word, 0 - $len, null, "UTF-8");
+            if ($end == $case[$row][1]) {
+                $base = mb_substr($word, 0, mb_strlen($word, "UTF-8") - $len, "UTF-8") . $case[$row][0];
+                if ($base != $word) {
+                    $thiscase = "";
+                    $arrCase = explode('$', $case[$row][2]);
+                    foreach ($arrCase as $value) {
+                        $caseid = "grammar_" . str_replace('.', '', $value);
+                        $thiscase .= "<guide gid='$caseid'>$value</guide>";
                     }
-                    return array($str1, $str2);
-                } else {
-                    $str1 = $str1 . "a";
-                    if (isExsit($str1)) {
-                        //echo "match";
-                        $left2 = mb_substr($str2, 0, 2, "UTF-8");
-                        if (mb_strpos($doubleword, $left2, 0, "UTF-8") !== false) {
-                            $str2 = mb_substr($str2, 1, null, "UTF-8");
-                        }
-                        return array($str1, $str2);
+
+                    if (isset($newWord[$base])) {
+                        $newWord[$base] .= "<br />" . $thiscase;
+                    } else {
+                        $newWord[$base] = $thiscase;
                     }
                 }
             }
         }
-        //not found
-        if (mb_substr($strWord, 0, 1, "UTF-8") == "e") {
-            $strWord = 'i' . mb_substr($strWord, 1, null, "UTF-8");
-            for ($i = $len - 1; $i > 3; $i--) {
-                $str1 = mb_substr($strWord, 0, $i, "UTF-8");
-                $str2 = mb_substr($strWord, $i, null, "UTF-8");
-                //echo "$str1 + $str2 = ";
-                if (isExsit($str1)) {
-                    //echo "match";
-                    $left2 = mb_substr($str2, 0, 2, "UTF-8");
-                    if (mb_strpos($doubleword, $left2, 0, "UTF-8") !== false) {
-                        $str2 = mb_substr($str2, 1, null, "UTF-8");
+
+		$base_list = array();
+        if (count($newWord) > 0) {
+            foreach ($newWord as $x => $x_value) {
+                $query = "SELECT dict.dict_id,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where word = ? limit 0,30";
+                $Fetch = PDO_FetchAll($query, array($x));
+                $iFetch = count($Fetch);
+                $count_return += $iFetch;
+                if ($iFetch > 0) {
+					$base_list[] = $x;
+                    $dict_list_a[] = array("word_$x", $x);
+                    echo "<div class='pali_spell'><a name='word_$x'></a>" . $x . "</div>";
+                    //语法信息
+                    foreach ($_local->grammastr as $gr) {
+                        $x_value = str_replace($gr->id, $gr->value, $x_value);
                     }
-                    return array($str1, $str2);
-                } else {
-                    $str1 = $str1 . "a";
-                    if (isExsit($str1)) {
-                        //echo "match";
-                        $left2 = mb_substr($str2, 0, 2, "UTF-8");
-                        if (mb_strpos($doubleword, $left2, 0, "UTF-8") !== false) {
-                            $str2 = mb_substr($str2, 1, null, "UTF-8");
-                        }
-                        return array($str1, $str2);
+                    echo "<div class='dict_find_gramma'>" . $x_value . "</div>";
+                    for ($i = 0; $i < $iFetch; $i++) {
+                        $mean = $Fetch[$i]["mean"];
+                        $dictid = $Fetch[$i]["dict_id"];
+                        $dict_list[$dictid] = $Fetch[$i]["shortname"];
+                        $dict_list_a[] = array("ref_dict_$dictid", $Fetch[$i]["shortname"]);
+                        echo "<div class='dict_word'>";
+                        echo "<a name='ref_dict_$dictid'></a>";
+                        echo "<div class='dict'>" . $Fetch[$i]["shortname"] . "</div>";
+                        echo "<div class='mean'>" . $mean . "</div>";
+                        echo "</div>";
                     }
                 }
             }
         }
-    }
-    return (false);
-}
+		//去除尾查结束
 
-add_edit_event(_DICT_LOOKUP_, $word);
-echo "<div id='dict_list_shell' onclick='setNaviVisibility()'><div id='dict_list' class='dict_list_off'></div></div>";
-echo "<div id='dict_ref'>";
-$dict_list_a = [];
-//社区字典开始
-PDO_Connect("" . _FILE_DB_WBW_);
-$query = "SELECT *  from " . _TABLE_DICT_REF_ . " where pali = ? limit 0,100";
-$Fetch = PDO_FetchAll($query, array($word));
-$iFetch = count($Fetch);
-$count_return += $iFetch;
-if ($iFetch > 0) {
-    $userlist = array();
-    foreach ($Fetch as $value) {
-        if (isset($userlist[$value["creator"]])) {
-            $userlist[$value["creator"]] += 1;
-        } else {
-            $userlist[$value["creator"]] = 1;
-        }
-        $userwordcase = $value["type"] . "#" . $value["gramma"];
-        if (isset($userdict["{$userwordcase}"])) {
-            $userdict["{$userwordcase}"]["mean"] .= $value["mean"] . ";";
-            $userdict["{$userwordcase}"]["factors"] .= $value["factors"];
-        } else {
-            $userdict["{$userwordcase}"]["mean"] = $value["mean"];
-            $userdict["{$userwordcase}"]["factors"] = $value["factors"];
-        }
+		//去分词除尾查
+        $arrBase = array();		
+		if (count($newWord) > 0) {
+			foreach ($newWord as $base => $grammar){
+				for ($row = 0; $row < count($p_ending); $row++) {
+					$len = mb_strlen($case[$row][1], "UTF-8");
+					$end = mb_substr($base, 0 - $len, null, "UTF-8");
+					if ($end == $p_ending[$row][1]) {
+						$newbase = mb_substr($base, 0, mb_strlen($base, "UTF-8") - $len, "UTF-8") . $p_ending[$row][0];
+						if ($newbase != $base) {
+							$thiscase = "";
+							$arrCase = explode('$', $p_ending[$row][2]);
+							foreach ($arrCase as $value) {
+								$caseid = "grammar_" . str_replace('.', '', $value);
+								$thiscase .= "<guide gid='$caseid'>$value</guide>";
+							}
 
-    }
-    echo "<div class='dict_word'>";
-    echo "<div class='dict'>{$_local->gui->com_dict}</div><a name='net'></a>";
-    $dict_list_a[] = array("net", $_local->gui->com_dict);
+							if (isset($arrBase[$newbase])) {
+								$arrBase[$newbase]['grammar'] .= "<br />" . $thiscase;
+							} else {
+								$arrBase[$newbase]['grammar'] = $thiscase;
+								$arrBase[$newbase]['parent'] = $base;
 
-    foreach ($userdict as $key => $value) {
-        echo "<div class='mean'>{$key}:{$value["mean"]}</div>";
-    }
-    echo "<div><span>{$_local->gui->contributor}:</span>";
-    foreach ($userlist as $key => $value) {
-        echo $key . "[" . $value . "]";
-    }
-    echo "</div>";
-    echo "</div>";
-}
-//社区字典结束
+							}
+						}
+					}
+				}
+			}
 
-PDO_Connect("" . _FILE_DB_REF_);
-//直接查询
-$query = "SELECT dict.dict_id,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where word = ? limit 0,100";
+			$base_list = array();
+			if (count($arrBase) > 0) {
+				foreach ($arrBase as $x => $x_value) {
+					$query = "SELECT dict.dict_id,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where word = ? limit 0,30";
+					$Fetch = PDO_FetchAll($query, array($x));
+					$iFetch = count($Fetch);
+					$count_return += $iFetch;
+					if ($iFetch > 0) {
+						$base_list[] = $x;
+						$dict_list_a[] = array("word_$x", $x);
+						echo "<div class='pali_spell'><a name='word_$x'></a>" . $x . "</div>";
+						echo "<div style='color:gray;'>{$x}->{$x_value["parent"]}->{$word}</div>";
+						//语法信息
+						foreach ($_local->grammastr as $gr) {
+							$x_value['grammar'] = str_replace($gr->id, $gr->value, $x_value['grammar']);
+						}
+						echo "<div class='dict_find_gramma'>" . $x_value['grammar'] . "</div>";
+						for ($i = 0; $i < $iFetch; $i++) {
+							$mean = $Fetch[$i]["mean"];
+							$dictid = $Fetch[$i]["dict_id"];
+							$dict_list[$dictid] = $Fetch[$i]["shortname"];
+							$dict_list_a[] = array("ref_dict_$dictid", $Fetch[$i]["shortname"]);
+							echo "<div class='dict_word'>";
+							echo "<a name='ref_dict_$dictid'></a>";
+							echo "<div class='dict'>" . $Fetch[$i]["shortname"] . "</div>";
+							echo "<div class='mean'>" . $mean . "</div>";
+							echo "</div>";
+						}
+					}
+				}
+			}
+		}
+		//去除尾查结束
 
-$Fetch = PDO_FetchAll($query, array($word));
-$iFetch = count($Fetch);
-$count_return += $iFetch;
-if ($iFetch > 0) {
-    for ($i = 0; $i < $iFetch; $i++) {
-        $mean = $Fetch[$i]["mean"];
-        $dictid = $Fetch[$i]["dict_id"];
-        $dict_list[$dictid] = $Fetch[$i]["shortname"];
-        $dict_list_a[] = array("ref_dict_$dictid", $Fetch[$i]["shortname"]);
-        $outXml = "<div class='dict_word'>";
-        $outXml = $outXml . "<a name='ref_dict_$dictid'></a>";
-        $outXml = $outXml . "<div class='dict'>" . $Fetch[$i]["shortname"] . "</div>";
-        $outXml = $outXml . "<div class='mean'>" . $mean . "</div>";
-        $outXml = $outXml . "</div>";
-        echo $outXml;
-    }
-}
-//去除尾查
-$newWord = array();
-for ($row = 0; $row < count($case); $row++) {
-    $len = mb_strlen($case[$row][1], "UTF-8");
-    $end = mb_substr($word, 0 - $len, null, "UTF-8");
-    if ($end == $case[$row][1]) {
-        $base = mb_substr($word, 0, mb_strlen($word, "UTF-8") - $len, "UTF-8") . $case[$row][0];
-        if ($base != $word) {
-            $thiscase = "";
-            $arrCase = explode('$', $case[$row][2]);
-            foreach ($arrCase as $value) {
-                $caseid = "grammar_" . str_replace('.', '', $value);
-                $thiscase .= "<guide gid='$caseid'>$value</guide>";
-            }
 
-            if (isset($newWord[$base])) {
-                $newWord[$base] .= "<br />" . $thiscase;
-            } else {
-                $newWord[$base] = $thiscase;
-            }
-        }
-    }
-}
+		echo "<div id='search_summary'>";
+		echo "查询{$word} 共{$count_return}条 ";
+		if(count($base_list)>0){
+			echo "找到可能的拼写: ";
+			foreach ($base_list as $key => $value) {
+				# code...
+				echo "<a>{$value}</a> ";
+			}
+		}
+		echo "</div>";
+		echo "<input type='hidden' id='word_count' value='{$count_return}' />";
 
-if (count($newWord) > 0) {
-    foreach ($newWord as $x => $x_value) {
-        $query = "SELECT dict.dict_id,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where word = ? limit 0,30";
-        $Fetch = PDO_FetchAll($query, array($x));
-        $iFetch = count($Fetch);
-        $count_return += $iFetch;
-        if ($iFetch > 0) {
-            $dict_list_a[] = array("word_$x", $x);
-            echo "<div style='font-size:120%;font-weight:700;'><a name='word_$x'></a>" . $x . "</div>";
-            //语法信息
-            foreach ($_local->grammastr as $gr) {
-                $x_value = str_replace($gr->id, $gr->value, $x_value);
+        //查连读词
+        if ($count_return < 2) {
+            echo "<div>Junction</div>";
+            $newWord = array();
+            for ($row = 0; $row < count($un); $row++) {
+                $len = mb_strlen($un[$row][1], "UTF-8");
+                $end = mb_substr($word, 0 - $len, null, "UTF-8");
+                if ($end == $un[$row][1]) {
+                    $base = mb_substr($word, 0, mb_strlen($word, "UTF-8") - $len, "UTF-8") . $un[$row][0];
+                    $arr_un = explode("+", $base);
+                    foreach ($arr_un as $oneword) {
+                        echo "<a onclick='dict_pre_word_click(\"$oneword\")'>$oneword</a> + ";
+                    }
+                    echo "<br />";
+                }
             }
-            echo "<div class='dict_find_gramma'>" . $x_value . "</div>";
-            for ($i = 0; $i < $iFetch; $i++) {
-                $mean = $Fetch[$i]["mean"];
-                $dictid = $Fetch[$i]["dict_id"];
-                $dict_list[$dictid] = $Fetch[$i]["shortname"];
-                $dict_list_a[] = array("ref_dict_$dictid", $Fetch[$i]["shortname"]);
-                echo "<div class='dict_word'>";
-                echo "<a name='ref_dict_$dictid'></a>";
-                echo "<div class='dict'>" . $Fetch[$i]["shortname"] . "</div>";
-                echo "<div class='mean'>" . $mean . "</div>";
-                echo "</div>";
+		}
+		
+		//拆复合词
+		echo "<div id='auto_split'></div>";
+
+/*
+        //查内容
+        if ($count_return < 2) {
+            $word1 = $org_word;
+            $wordInMean = "%$org_word%";
+            echo "包含 $org_word 的:<br />";
+            $query = "SELECT dict.dict_id,dict.word,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where mean like ? limit 0,30";
+            $Fetch = PDO_FetchAll($query, array($wordInMean));
+            $iFetch = count($Fetch);
+            $count_return += $iFetch;
+            if ($iFetch > 0) {
+                for ($i = 0; $i < $iFetch; $i++) {
+                    $mean = $Fetch[$i]["mean"];
+                    $pos = mb_stripos($mean, $word, 0, "UTF-8");
+                    if ($pos) {
+                        if ($pos > 20) {
+                            $start = $pos - 20;
+                        } else {
+                            $start = 0;
+                        }
+                        $newmean = mb_substr($mean, $start, 100, "UTF-8");
+                    } else {
+                        $newmean = $mean;
+                    }
+                    $pos = mb_stripos($newmean, $word1, 0, "UTF-8");
+                    $head = mb_substr($newmean, 0, $pos, "UTF-8");
+                    $mid = mb_substr($newmean, $pos, mb_strlen($word1, "UTF-8"), "UTF-8");
+                    $end = mb_substr($newmean, $pos + mb_strlen($word1, "UTF-8"), null, "UTF-8");
+                    $heigh_light_mean = "$head<hl>$mid</hl>$end";
+                    echo "<div class='dict_word'>";
+                    echo "<div class='pali'>" . $Fetch[$i]["word"] . "</div>";
+                    echo "<div class='dict'>" . $Fetch[$i]["shortname"] . "</div>";
+                    echo "<div class='mean'>" . $heigh_light_mean . "</div>";
+                    echo "</div>";
+                }
             }
         }
-    }
-}
-//去除尾查结束
-
-//查连读词
-if ($count_return < 2) {
-    echo "<div>Junction</div>";
-    $newWord = array();
-    for ($row = 0; $row < count($un); $row++) {
-        $len = mb_strlen($un[$row][1], "UTF-8");
-        $end = mb_substr($word, 0 - $len, null, "UTF-8");
-        if ($end == $un[$row][1]) {
-            $base = mb_substr($word, 0, mb_strlen($word, "UTF-8") - $len, "UTF-8") . $un[$row][0];
-            $arr_un = explode("+", $base);
-            foreach ($arr_un as $oneword) {
-                echo "<a onclick='dict_pre_word_click(\"$oneword\")'>$oneword</a> + ";
+*/
+        echo "<div id='dictlist'>";
+        foreach ($dict_list_a as $x_value) {
+            if (substr($x_value[0], 0, 4) == "word") {
+                echo "<div class='pali_spell'>";
+                echo "<a href='#{$x_value[0]}'>$x_value[1]</a></div>";
+            } else {
+                echo "<div><a href='#{$x_value[0]}'>$x_value[1]</a></div>";
             }
-            echo "<br />";
         }
-    }
-}
+        echo "<div>";
 
-//查内容
-if ($count_return < 2) {
-    $word1 = $org_word;
-    $wordInMean = "%$org_word%";
-    echo "include $org_word:<br />";
-    $query = "SELECT dict.dict_id,dict.word,dict.mean,info.shortname from " . _TABLE_DICT_REF_ . " LEFT JOIN info ON dict.dict_id = info.id where mean like ? limit 0,30";
-    $Fetch = PDO_FetchAll($query, array($wordInMean));
-    $iFetch = count($Fetch);
-    $count_return += $iFetch;
-    if ($iFetch > 0) {
-        for ($i = 0; $i < $iFetch; $i++) {
-            $mean = $Fetch[$i]["mean"];
-            $pos = mb_stripos($mean, $word, 0, "UTF-8");
-            if ($pos) {
-                if ($pos > 20) {
-                    $start = $pos - 20;
-                } else {
-                    $start = 0;
-                }
-                $newmean = mb_substr($mean, $start, 100, "UTF-8");
+        $arrWords = countWordInPali($word, true);
+        $weight = 0;
+        foreach ($arrWords as $oneword) {
+            $weight += $oneword["count"] * $oneword["len"];
+        }
+        //echo "<div>{$_local->gui->word_weight}:$weight {$_local->gui->characters}</div>";
+        //echo "<div>{$_local->gui->real_declension}:".count($arrWords)." {$_local->gui->forms}</div>";
+        $right_word_list .= "<div>{$_local->gui->word_weight}:$weight {$_local->gui->characters}</div>";
+        $right_word_list .= "<div>{$_local->gui->real_declension}:" . count($arrWords) . " {$_local->gui->forms}</div>";
+        foreach ($arrWords as $oneword) {
+            if ($oneword["bold"] > 0) {
+                //echo "<div><b>{$oneword["word"]}</b> {$oneword["count"]} {$_local->gui->times}</div>";
+                $right_word_list .= "<div><b>{$oneword["word"]}</b> {$oneword["count"]} {$_local->gui->times}</div>";
             } else {
-                $newmean = $mean;
+                //echo "<div>{$oneword["word"]} {$oneword["count"]}{$_local->gui->times}</div>";
+                $right_word_list .= "<div>{$oneword["word"]} {$oneword["count"]}{$_local->gui->times}</div>";
             }
-            $pos = mb_stripos($newmean, $word1, 0, "UTF-8");
-            $head = mb_substr($newmean, 0, $pos, "UTF-8");
-            $mid = mb_substr($newmean, $pos, mb_strlen($word1, "UTF-8"), "UTF-8");
-            $end = mb_substr($newmean, $pos + mb_strlen($word1, "UTF-8"), null, "UTF-8");
-            $heigh_light_mean = "$head<hl>$mid</hl>$end";
-            echo "<div class='dict_word'>";
-            echo "<div class='pali'>" . $Fetch[$i]["word"] . "</div>";
-            echo "<div class='dict'>" . $Fetch[$i]["shortname"] . "</div>";
-            echo "<div class='mean'>" . $heigh_light_mean . "</div>";
-            echo "</div>";
         }
-    }
-}
-
-//拆复合词
+        echo "</div>";
+        echo "</div>";
+        echo "</div>";
+        //参考字典查询结束
 
-$splitWord = $word;
-$part = array();
-if ($count_return < 2) {
-    echo "Try to split comp:<br>";
-    while (($split = mySplit($splitWord)) !== false) {
-        array_push($part, $split[0]);
-        $splitWord = $split[1];
-    }
-    if (count($part) > 0) {
-        array_push($part, $splitWord);
-        $newPart = ltrim(array_reduce($part, "myfunction"), "+");
-        echo $newPart;
-    }
-}
+        //用户词典编辑窗口
+        echo "<div id='dict_user' >";
+        echo "<div><a href='word_statistics.php?word={$word}'>";
+        echo "<svg t='1596783175334' class='icon' style='font-size: xxx-large; fill: var(--link-hover-color); margin: 5px;' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='7755' width='200' height='200'><path d='M1019.904 450.56L536.576 557.056l417.792 208.896C999.424 692.224 1024 606.208 1024 512c0-20.48 0-40.96-4.096-61.44z m-12.288-61.44C958.464 184.32 786.432 28.672 573.44 4.096L446.464 512l561.152-122.88zM737.28 970.752c73.728-36.864 139.264-90.112 188.416-159.744L507.904 602.112l229.376 368.64zM512 0C229.376 0 0 229.376 0 512s229.376 512 512 512c61.44 0 118.784-12.288 172.032-28.672L385.024 512 512 0z' p-id='7756'></path></svg>";
+        echo "<span>{$_local->gui->click_to_chart}</span></a></div>";
+        echo $right_word_list;
+        echo "<div class='dict_word' ><b>{$_local->gui->undone_function}</b>";
+        echo "<div class='' onclick=\"dict_show_edit()\">{$_local->gui->edit}</div>";
+        echo "<div class='pali'>{$word}</div>";
 
-#词典列表
-echo "<div id='dictlist'>";
-foreach ($dict_list_a as $x_value) {
-    if (substr($x_value[0], 0, 4) == "word") {
-        echo "<div style='font-size:120%;font-weight:700;margin-top:15px;'>";
-        echo "<a href='#{$x_value[0]}'>$x_value[1]</a></div>";
-    } else {
-        echo "<div><a href='#{$x_value[0]}'>$x_value[1]</a></div>";
-    }
-}
-echo "<div>";
+        if ($iFetch > 0) {
+            echo "<div id='user_word_edit' style='display:none'>";
+        } else {
+            echo "<div id='user_word_edit'>";
+        }
+        echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->wordtype}</legend>";
+        echo "<select id=\"id_type\" name=\"type\" >";
+        foreach ($_local->type_str as $type) {
+            echo "<option value=\"{$type->id}\" >{$type->value}</option>";
+        }
+        echo "</select>";
+        echo "</fieldset>";
+        echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->gramma}</legend><input type='input' value=''/></fieldset>";
+        echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->parent}</legend><input type='input' value=''/></fieldset>";
+        echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->g_mean}</legend><input type='input' value=''/></fieldset>";
+        echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->note}</legend><textarea></textarea></fieldset>";
+        echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->factor}</legend><input type='input' value=''/></fieldset>";
+        echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->f_mean}</legend><input type='input' value=''/></fieldset>";
+        echo "<div class=''><button>{$_local->gui->add_to} {$_local->gui->my_dictionary}</button></div>";
+        echo "</div>";
+        echo "</div>";
+        echo "</div>";
+        //查用户词典结束
 
-#在巴利文献中出现的次数
-$arrWords = countWordInPali($word, true);
-$weight = 0;
-foreach ($arrWords as $oneword) {
-    $weight += $oneword["count"] * $oneword["len"];
-}
-//echo "<div>{$_local->gui->word_weight}:$weight {$_local->gui->characters}</div>";
-//echo "<div>{$_local->gui->real_declension}:".count($arrWords)." {$_local->gui->forms}</div>";
-$right_word_list .= "<div>{$_local->gui->word_weight}:$weight {$_local->gui->characters}</div>";
-$right_word_list .= "<div>{$_local->gui->real_declension}:" . count($arrWords) . " {$_local->gui->forms}</div>";
-foreach ($arrWords as $oneword) {
-    if ($oneword["bold"] > 0) {
-        //echo "<div><b>{$oneword["word"]}</b> {$oneword["count"]} {$_local->gui->times}</div>";
-        $right_word_list .= "<div><b>{$oneword["word"]}</b> {$oneword["count"]} {$_local->gui->times}</div>";
-    } else {
-        //echo "<div>{$oneword["word"]} {$oneword["count"]}{$_local->gui->times}</div>";
-        $right_word_list .= "<div>{$oneword["word"]} {$oneword["count"]}{$_local->gui->times}</div>";
-    }
-}
-echo "</div>";
-echo "</div>";
-echo "</div>";
-//参考字典查询结束
 
-//用户词典编辑窗口
-echo "<div id='dict_user' >";
-echo "<div><a href='word_statistics.php?word={$word}'>";
-echo "<svg t='1596783175334' class='icon' style='font-size: xxx-large; fill: var(--link-hover-color); margin: 5px;' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='7755' width='200' height='200'><path d='M1019.904 450.56L536.576 557.056l417.792 208.896C999.424 692.224 1024 606.208 1024 512c0-20.48 0-40.96-4.096-61.44z m-12.288-61.44C958.464 184.32 786.432 28.672 573.44 4.096L446.464 512l561.152-122.88zM737.28 970.752c73.728-36.864 139.264-90.112 188.416-159.744L507.904 602.112l229.376 368.64zM512 0C229.376 0 0 229.376 0 512s229.376 512 512 512c61.44 0 118.784-12.288 172.032-28.672L385.024 512 512 0z' p-id='7756'></path></svg>";
-echo "<br>{$_local->gui->click_to_chart}</a></div>";
-echo $right_word_list;
-echo "<div class='dict_word' ><b>{$_local->gui->undone_function}</b>";
-echo "<div class='' onclick=\"dict_show_edit()\">{$_local->gui->edit}</div>";
-echo "<div class='pali'>{$word}</div>";
 
-if ($iFetch > 0) {
-    echo "<div id='user_word_edit' style='display:none'>";
-} else {
-    echo "<div id='user_word_edit'>";
-}
-echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->wordtype}</legend>";
-echo "<select id=\"id_type\" name=\"type\" >";
-foreach ($_local->type_str as $type) {
-    echo "<option value=\"{$type->id}\" >{$type->value}</option>";
-}
-echo "</select>";
-echo "</fieldset>";
-echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->gramma}</legend><input type='input' value=''/></fieldset>";
-echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->parent}</legend><input type='input' value=''/></fieldset>";
-echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->g_mean}</legend><input type='input' value=''/></fieldset>";
-echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->note}</legend><textarea></textarea></fieldset>";
-echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->factor}</legend><input type='input' value=''/></fieldset>";
-echo "<fieldset class='broder-1 broder-r'><legend>{$_local->gui->f_mean}</legend><input type='input' value=''/></fieldset>";
-echo "<div class=''><button>{$_local->gui->add_to} {$_local->gui->my_dictionary}</button></div>";
-echo "</div>";
-echo "</div>";
-echo "</div>";
-//查用户词典结束

+ 44 - 20
app/dict/dict_lookup_pre.php

@@ -2,33 +2,57 @@
 //查询参考字典
 require_once '../path.php';
 require_once '../public/_pdo.php';
+require_once '../redis/function.php';
+
+if (isset($_GET["language"])) {
+    $currLanguage = $_GET["language"];
+} else {
+    if (isset($_COOKIE["language"])) {
+        $currLanguage = $_COOKIE["language"];
+    } else {
+        $currLanguage = "en";
+    }
+}
+$currLanguage = explode("-", $currLanguage)[0];
 
-PDO_Connect("" . _FILE_DB_REF_INDEX_);
 if (isset($_GET["word"])) {
     $word = $_GET["word"];
 } else {
     echo json_encode(array(), JSON_UNESCAPED_UNICODE);
     exit;
 }
-$query = "SELECT word,count from " . _TABLE_REF_INDEX_ . " where eword like ?  OR word like ?  limit 0,20";
-$Fetch = PDO_FetchAll($query, array($word . '%', $word . '%'));
-
-PDO_Connect(_FILE_DB_REF_, _DB_USERNAME_, _DB_PASSWORD_);
-$query = "SELECT mean from " . _TABLE_DICT_REF_ . " where word = ? and language = ?  limit 0,1";
-foreach ($Fetch as $key => $value) {
-    # code...
-    $mean = PDO_FetchRow($query, array($value["word"], "zh"));
-    if ($mean) {
-        $Fetch[$key]["mean"] = $mean["mean"];
-    } else {
-        $mean = PDO_FetchRow($query, array($value["word"], "en"));
-        if ($mean) {
-            $Fetch[$key]["mean"] = $mean["mean"];
-        } else {
-            $Fetch[$key]["mean"] = "";
-        }
-
-    }
+/*
+$redis = redis_connect();
+if($redis!==false){
+	$redis->hexist()
+}
+else
+*/
+{
+	PDO_Connect(_FILE_DB_REF_INDEX_);
+	$query = "SELECT word,count from " . _TABLE_REF_INDEX_ . " where eword like ?  OR word like ?  limit 0,15";
+	$Fetch = PDO_FetchAll($query, array($word . '%', $word . '%'));
 
+	PDO_Connect(_FILE_DB_REF_, _DB_USERNAME_, _DB_PASSWORD_);
+	$query = "SELECT mean from " . _TABLE_DICT_REF_ . " where word = ? and language = ?  limit 0,1";
+	foreach ($Fetch as $key => $value) {
+		# code...
+		$mean = PDO_FetchRow($query, array($value["word"], $currLanguage));
+		if ($mean) {
+			$Fetch[$key]["mean"] = $mean["mean"];
+		} else {
+			if ($currLanguage != "en") {
+				$mean = PDO_FetchRow($query, array($value["word"], "en"));
+				if ($mean) {
+					$Fetch[$key]["mean"] = $mean["mean"];
+				} else {
+					$Fetch[$key]["mean"] = "";
+				}
+			} else {
+				$Fetch[$key]["mean"] = "";
+			}
+		}
+	}
 }
+
 echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);

+ 9 - 1
app/dict/index.php

@@ -95,13 +95,14 @@ if (!(isset($_GET["builtin"]) && $_GET["builtin"] == 'true')) {
 		/*for word split part */
 		.dropdown_ctl {
 			display: inline-block;
-			margin-right: 0.7em;
+			margin: 0 0.7em;
 		}
 
 		.dropdown_ctl>.content {
 			display: flex;
 			border: 1px solid var(--border-line-color);
 			border-radius: 99px;
+			line-height: 2em;
 		}
 
 		.dropdown_ctl>.menu {
@@ -248,6 +249,13 @@ if (!(isset($_GET["builtin"]) && $_GET["builtin"] == 'true')) {
 		.dict_word_list:hover{
 			color: var(--link-hover-color);
 		}
+
+		.pali_spell{
+			font-size:200%;
+			font-weight:700;
+			margin-top:15px;
+			padding-bottom:0
+		}
 	</style>
 	<link type="text/css" rel="stylesheet" href="./css/style.css" >
 	<link type="text/css" rel="stylesheet" href="./css/style_mobile.css" media="screen and (max-width:800px)">

+ 19 - 0
app/dict/p_ending.php

@@ -0,0 +1,19 @@
+<?php
+global $p_ending;
+$p_ending = array(
+array("ti","māna",".ti.$.prp."),
+array("ti","anta",".ti.$.prp."),
+array("ti","ta",".ti.pp."),
+array("ti","na",".ti.$.pp."),
+array("ati","eyya",".ti.$.fpp."),
+array("eti","eyya",".ti.$.fpp."),
+array("oti","eyya",".ti.$.fpp."),
+array("ti","tabba",".ti.$.fpp."),
+array("ati","itabba",".ti.$.fpp."),
+array("eti","itabba",".ti.$.fpp."),
+array("oti","itabba",".ti.$.fpp."),
+array("ati","aniya",".ti.$.fpp."),
+array("eti","aniya",".ti.$.fpp."),
+array("oti","aniya",".ti.$.fpp.")
+)
+?>

+ 8 - 3
app/dict/split.php

@@ -82,11 +82,16 @@ foreach ($arrWords as $currword) {
     foreach ($arrword as $oneword) {
         $result = array(); //全局变量,递归程序的输出容器
 
-        mySplit2($oneword, 0, $_express, 0, 0.1, 0.01, true, true);
+        mySplit2($oneword, 0, false, 0, 0.5, 0.8, true, false);
+		if(count($result) < 3){
+			mySplit2($oneword, 0, $_express, 0, 0.2, 0.8, true, true);
+		}
         if (isset($_POST["debug"])) {
             echo "正切:" . count($result) . "\n";
-        }
-        mySplit2($oneword, 0, $_express, 0, 0.1, 0.01, false, true);
+		}
+		if(count($result) < 3){
+			mySplit2($oneword, 0, $_express, 0, 0.2, 0.8, false, true);
+		}
         if (isset($_POST["debug"])) {
             echo "反切:" . count($result) . "\n";
         }

+ 40 - 27
app/dict/turbo_split.php

@@ -14,6 +14,8 @@ global $path;
 global $confidence;
 global $result;
 global $part;
+define("MAX_RESULT",100);
+
 $part = array();
 
 $path[] = array("", 0);
@@ -175,7 +177,7 @@ function dict_lookup($word)
     $stmt->execute(array($search));
     $row = $stmt->fetch(PDO::FETCH_NUM);
     if ($row) {
-        return $row[0];
+        return array($row[0],0);
     } else {
         //去除尾查
         $newWord = array();
@@ -185,12 +187,13 @@ function dict_lookup($word)
             if ($end == $case[$row][1]) {
                 $base = mb_substr($word, 0, mb_strlen($word, "UTF-8") - $len, "UTF-8") . $case[$row][0];
                 if ($base != $word) {
-                    $newWord[$base] = 1;
+                    $newWord[$base] = mb_strlen($case[$row][1],"UTF-8");
                 }
             }
         }
         #找到最高频的base
-        $base_weight = 0;
+		$base_weight = 0;
+		$len = 0;
         foreach ($newWord as $x => $x_value) {
             $query = "SELECT weight from part where word = ? ";
             $stmt = $dbh->prepare($query);
@@ -198,11 +201,12 @@ function dict_lookup($word)
             $row = $stmt->fetch(PDO::FETCH_NUM);
             if ($row) {
                 if ($row[0] > $base_weight) {
-                    $base_weight = $row[0];
+					$base_weight = $row[0];
+					$len=$x_value;
                 }
             }
         }
-        return $base_weight;
+        return array($base_weight,$len);
     }
 }
 
@@ -227,21 +231,24 @@ function isExsit($word, $adj_len = 0)
     $isFound = false;
     $count = 0;
     if (isset($part["{$word}"])) {
-        if ($part["{$word}"] > 0) {
+		$word_count = $part["{$word}"][0];
+		$case_len = $part["{$word}"][1];
+        if ($word_count > 0) {
             $isFound = true;
-            $count = $part["{$word}"] + 1;
+            $count = $word_count + 1;
         }
     } else {
         $db = dict_lookup($word);
-
+		$word_count = $db[0];
+		$case_len = $db[1];
         //加入查询缓存
         $part["{$word}"] = $db;
-        if ($db > 0) {
+        if ($word_count > 0) {
             if (isset($_POST["debug"])) {
-                echo "查到:{$word}:{$db}个\n";
+                echo "查到:{$word}:{$word_count}个\n";
             }
             $isFound = true;
-            $count = $db + 1;
+            $count = $word_count + 1;
         }
     }
 //fomular of confidence value 信心值计算公式
@@ -253,8 +260,8 @@ function isExsit($word, $adj_len = 0)
             $len_correct = 1.2;
             $count2 = 1.1 + pow($count, 1.18);
             $conf_num = pow(1 / $count2, pow(($len - 0.5), $len_correct));
-            $cf = round(1 / (1 + 640 * $conf_num), 9);
-
+            //$cf = round(1 / (1 + 640 * $conf_num), 9);
+			$cf = round((1-0.02*$case_len) / (1 + 640 * $conf_num), 9);
             $confidence["{$word}"] = $cf;
             if (isset($_POST["debug"])) {
                 echo "信心指数:{$word}:{$cf}\n";
@@ -301,12 +308,14 @@ function mySplit2($strWord, $deep = 0, $express = false, $adj_len = 0, $c_thresh
         $cf += (0 - $len) / ($len + 150);
         $word .= "{$strWord}";
         if ($forward == true) {
-            $result[$word] = $cf;
+			$result[$word] = $cf;
+			return;
         } else {
             $reverseWord = word_reverse($word);
-            $result[$reverseWord] = $cf;
+			$result[$reverseWord] = $cf;
+			return;
         }
-        return;
+        
     }
     //直接找到
     $confidence = isExsit($strWord, $adj_len);
@@ -387,7 +396,7 @@ function mySplit2($strWord, $deep = 0, $express = false, $adj_len = 0, $c_thresh
         }
 
     }
-
+	$word = "";
     if (count($output) > 0) {
         foreach ($output as $part) {
             $checked = $part[0];
@@ -413,13 +422,15 @@ function mySplit2($strWord, $deep = 0, $express = false, $adj_len = 0, $c_thresh
                 } else {
                     $word .= $checked;
                 }
-                $cf = $cf + $part[2] * 0.1;
+                $cf = $cf * $part[2];
                 if ($cf > $w_threshhold) {
                     if ($forward == true) {
-                        $result[$word] = $cf;
+						$result[$word] = $cf;
+						return;
                     } else {
                         $reverseWord = word_reverse($word);
                         $result[$reverseWord] = $cf;
+						return;
                     }
                 }
             } else {
@@ -441,26 +452,28 @@ function mySplit2($strWord, $deep = 0, $express = false, $adj_len = 0, $c_thresh
         }
         $len = pow(mb_strlen($strWord, "UTF-8"), 3);
         if ($forward) {
-            $cf += (0 - $len) / ($len + 150);
-        } else {
-            $cf += (0 - $len) / ($len + 5);
+            $cf =(1-$cf) * $len / ($len + 150);
+        } else 
+			$cf =(1-$cf) * $len / ($len + 5);
         }
         if (isset($_POST["debug"])) {
-            $word .= $strWord . "(0)";
+            $word = $word.$strWord . "(0)";
         } else {
-            $word .= $strWord;
+            $word = $word .$strWord;
         }
 
         if ($cf > $w_threshhold) {
             if ($forward == true) {
-                $result[$word] = $cf;
+				$result[$word] = $cf;
+				return;
             } else {
                 $reverseWord = word_reverse($word);
-                $result[$reverseWord] = $cf;
+				$result[$reverseWord] = $cf;
+				return;
             }
         }
     }
-}
+
 
 function word_reverse($word)
 {

Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff