quote($word);
$row=PDO_FetchOne($query);
/*
$Fetch = PDO_FetchAll($query);
$iFetch=count($Fetch);
$count_return+=$iFetch;
if($iFetch>0){
}
*/
if($row[0]==0){
return false;
}
else{
return true;
}
}
function myfunction($v1,$v2)
{
return $v1 . "+" . $v2;
}
function mySplit($strWord){
//echo("
".$strWord."
");
$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");
}
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);
}
}
}
//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");
}
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);
}
}
}
}
//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");
}
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);
}
}
}
}
}
return(FALSE);
}
switch($op){
case "pre"://预查询
PDO_Connect("sqlite:"._FILE_DB_REF_INDEX_);
echo "
";
$query = "select word,count from dict where \"eword\" like ".$PDO->quote($word.'%')." OR \"word\" like ".$PDO->quote($word.'%')." limit 0,20";
$Fetch = PDO_FetchAll($query);
$iFetch=count($Fetch);
if($iFetch>0){
for($i=0;$i<$iFetch;$i++){
$word=$Fetch[$i]["word"];
$count=$Fetch[$i]["count"];
echo "
";
}
}
echo "
";
break;
case "search":
echo "";
echo "";
//社区字典开始
PDO_Connect("sqlite:"._FILE_DB_WBW_);
$query = "select * from dict where \"pali\"= ".$PDO->quote($word)." limit 0,100";
$Fetch = PDO_FetchAll($query);
$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"];
}
/*
$mean=$Fetch[$i]["mean"];
echo "
";
echo "
{$word}
";
echo "
语法:{$Fetch[$i]["type"]}-{$Fetch[$i]["gramma"]}
";
if(strlen($Fetch[$i]["parent"])>0){
echo "
语基:{$Fetch[$i]["parent"]}
";
}
echo "
意思:{$Fetch[$i]["mean"]}
";
if(strlen($Fetch[$i]["note"]>0)){
echo "
注解:{$Fetch[$i]["note"]}
";
}
echo "
组分:{$Fetch[$i]["factors"]}
";
echo "
组分意思:{$Fetch[$i]["factormean"]}
";
echo "
贡献者:{$Fetch[$i]["creator"]}
";
echo "
收藏:{$Fetch[$i]["ref_counter"]}次
";
echo "
";
*/
}
echo "
";
echo "
社区字典
";
foreach($userdict as $key => $value){
echo "
{$key}:{$value["mean"]}
";
}
echo "
贡献者:";
foreach ($userlist as $key => $value) {
echo $key."[".$value."]";
}
echo "
";
echo "
";
}
//社区字典结束
PDO_Connect("sqlite:"._FILE_DB_REF_);
//直接查询
$query = "select dict.dict_id,dict.mean,info.shortname from dict LEFT JOIN info ON dict.dict_id = info.id where \"word\" = ".$PDO->quote($word)." limit 0,100";
$Fetch = PDO_FetchAll($query);
$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"];
$outXml = "
";
$outXml = $outXml."
";
$outXml = $outXml."
".$Fetch[$i]["shortname"]."
";
$outXml = $outXml."
".$mean."
";
$outXml = $outXml."
";
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){
if(isset($newWord[$base])){
$newWord[$base] .= "
".$case[$row][2];
}
else{
$newWord[$base] = $case[$row][2];
}
}
}
}
if(count($newWord)>0){
foreach($newWord as $x=>$x_value) {
$query = "select dict.dict_id,dict.mean,info.shortname from dict LEFT JOIN info ON dict.dict_id = info.id where \"word\" = ".$PDO->quote($x)." limit 0,30";
$Fetch = PDO_FetchAll($query);
$iFetch=count($Fetch);
$count_return+=$iFetch;
if($iFetch>0){
echo $x . ":
" . $x_value . "
";
for($i=0;$i<$iFetch;$i++){
$mean=$Fetch[$i]["mean"];
$dictid=$Fetch[$i]["dict_id"];
$dict_list[$dictid]=$Fetch[$i]["shortname"];
echo "
";
echo "
";
echo "
".$Fetch[$i]["shortname"]."
";
echo "
".$mean."
";
echo "
";
}
}
}
}
//去除尾查结束
//查连读词
if($count_return<2){
echo "Junction:
";
$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 "
$oneword + ";
}
echo "
";
}
}
}
//查内容
if($count_return<2){
$word1=$org_word;
$wordInMean="%$org_word%";
echo "include $org_word:
";
$query = "select dict.dict_id,dict.word,dict.mean,info.shortname from dict LEFT JOIN info ON dict.dict_id = info.id where \"mean\" like ".$PDO->quote($wordInMean)." limit 0,30";
$Fetch = PDO_FetchAll($query);
$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
$mid$end";
echo "
";
echo "
".$Fetch[$i]["word"]."
";
echo "
".$Fetch[$i]["shortname"]."
";
echo "
".$heigh_light_mean."
";
echo "
";
}
}
}
//拆复合词
$splitWord=$word;
$part=array();
if($count_return<2){
echo "Try to split comp:
";
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 "
";
foreach($dict_list as $x=>$x_value) {
echo "
";
}
echo "
";
$arrWords = countWordInPali($word,true);
$weight = 0;
foreach($arrWords as $oneword){
$weight += $oneword["count"] * $oneword["len"];
}
echo "
{$_local->gui->word_weight}:$weight {$_local->gui->characters}
";
echo "
{$_local->gui->real_declension}:".count($arrWords)." {$_local->gui->forms}
";
foreach($arrWords as $oneword){
if($oneword["bold"]>0){
echo "
{$oneword["word"]} {$oneword["count"]} {$_local->gui->times}
";
}
else{
echo "
{$oneword["word"]} {$oneword["count"]}{$_local->gui->times}
";
}
}
echo "
";
echo "
";
echo "
";
//参考字典查询结束
//用户词典
echo "";
echo "
{$_local->gui->undone_function}";
echo "
{$_local->gui->edit}
";
echo "
{$word}
";
if($iFetch>0){
echo "
";
}
else{
echo "
";
echo "
";
echo "
";
//查用户词典结束
break;
}
?>