Просмотр исходного кода

Merge pull request #34 from visuddhinanda/master

Chart for corpus analysis 语料分析图表
Bhikkhu-Kosalla 5 лет назад
Родитель
Сommit
7da40d13bb

+ 90 - 0
app/dict/css/style_mobile.css

@@ -0,0 +1,90 @@
+:root{
+    --bgDisplay:block;
+}
+
+body {
+
+}
+
+.left_nav_bar{
+	display:none;
+}
+.right_nav_bar_off{
+	position: fixed;
+    top: 0;
+	width:100%;
+	height:100%;
+	background-color:white;
+	-webkit-transform:translateX(100%);
+	-moz-transform:translateX(100%);
+	transform:translateX(100%);
+    -webkit-transition-duration: 0.4s;
+    transition-duration: 0.4s;
+}
+
+.right_nav_bar_on{
+	position: fixed;
+    top: 0;
+	width:100%;
+	height:100%;
+	background-color:white;
+    -webkit-transform:translateX(0em);
+    -moz-transform:translateX:(0em);
+    transform:translateX:(0em);
+	-webkit-transition-duration: 0.4s;
+    transition-duration: 0.4s;
+	overflow-y: scroll;
+
+}
+
+#search_input{
+	display:none;
+}
+#tool_bar_right{
+	display:none;
+}
+#header_nav{
+	display:none;
+}
+#footer_nav{
+	display:flex;
+}
+#page_header_4{
+	display:flex;
+}
+.index_inner{
+	margin-top: 0; 
+}
+
+.book_block{
+    width: initial;
+    height: initial;
+    display: flex;
+    margin: 5px;
+    cursor: pointer;
+}
+
+.book_block_cover{
+	width:4em;
+	height:5em;
+	border: 5px solid #ddb483;
+}
+.book_block_info{
+    margin: 5px;
+}
+.book_block_title{
+
+}
+.book_block_detail{
+
+}
+
+#tool_bar_right{display:none;}
+
+#para_res_list_shell{
+
+}
+#para_res_list_header{
+	display:block;
+	padding: 8px;
+}

+ 5 - 0
app/dict/dict_lookup.php

@@ -359,13 +359,18 @@ switch($op){
 		  echo "<div><a href='#ref_dict_$x'>$x_value</a></div>";
 		}
 		echo "<div>";
+
 		$arrWords = countWordInPali($word,true);
 		$weight = 0;
 		foreach($arrWords as $oneword){
 			$weight += $oneword["count"] * $oneword["len"];
 		}
+		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);' 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 "<div>{$_local->gui->word_weight}:$weight {$_local->gui->characters}</div>";
 		echo "<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>";

+ 6 - 0
app/dict/index.php

@@ -114,8 +114,14 @@ require_once "../pcdl/html_head.php";
 			border-radius: 99px;
 			cursor: pointer;
 		}
+		#footer_nav {
+			display: none;
+		}
 
 	</style>
+	<!-- <link type="text/css" rel="stylesheet" href="css/style_mobile.css" media="screen and (max-width:767px)">-->
+	
+
 	<!-- tool bar begin-->
 	<div id='search_toolbar' class="search_toolbar">
 			<div style="display:flex;justify-content: space-between;">

+ 171 - 0
app/dict/word_statistics.php

@@ -0,0 +1,171 @@
+<?PHP
+include "../pcdl/html_head.php";
+?>
+	<body>
+		<style type="text/css">
+
+            .highcharts-figure, .highcharts-data-table table {
+                flex:1;
+                min-width: 220px; 
+                max-width: 100%;
+                margin: 1em auto;
+            }
+
+            .highcharts-data-table table {
+                font-family: Verdana, sans-serif;
+                border-collapse: collapse;
+                border: 1px solid #EBEBEB;
+                margin: 10px auto;
+                text-align: center;
+                width: 100%;
+                max-width: 500px;
+            }
+            .highcharts-data-table caption {
+                padding: 1em 0;
+                font-size: 1.2em;
+                color: #555;
+            }
+            .highcharts-data-table th {
+                font-weight: 600;
+                padding: 0.5em;
+            }
+            .highcharts-data-table td, .highcharts-data-table th, .highcharts-data-table caption {
+                padding: 0.5em;
+            }
+            .highcharts-data-table thead tr, .highcharts-data-table tr:nth-child(even) {
+                background: #f8f8f8;
+            }
+            .highcharts-data-table tr:hover {
+                background: #f1f7ff;
+            }
+		</style>
+<script src="../public/js/highcharts/highcharts.js"></script>
+<script src="../public/js/highcharts/modules/sunburst.js"></script>
+<script src="../public/js/highcharts/modules/exporting.js"></script>
+<script src="../public/js/highcharts/modules/export-data.js"></script>
+<script src="../public/js/highcharts/modules/accessibility.js"></script>
+<?php
+    require_once("../pcdl/head_bar.php");
+?>
+<h2 style="text-align:center;"><?php echo $_GET["word"] ?></h2>
+<div style="display:flex;">
+<figure class="highcharts-figure">
+    <div id="container"></div>
+</figure>
+<figure class="highcharts-figure">
+    <div id="container_list" style="height:50em;"></div>
+</figure>
+</div>
+
+<script type="text/javascript">
+  $.get("../search/word_statistics.php",
+  {
+    word : "<?php echo $_GET["word"] ?>"
+  },
+  function(data,status){
+    let worddata =  JSON.parse(data);
+    // Splice in transparent for the center circle
+    Highcharts.getOptions().colors.splice(0, 0, 'transparent');
+
+    Highcharts.setOptions({
+            colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4']
+        });
+    Highcharts.chart('container', {
+        chart: {
+            height: '100%'
+        },
+
+        title: {
+            text: 'Distribution'
+        },
+        subtitle: {
+            text: ''
+        },
+        series: [{
+            type: "sunburst",
+            data: worddata,
+            allowDrillToNode: true,
+            cursor: 'pointer',
+            dataLabels: {
+                format: '{point.name}',
+                filter: {
+                    property: 'innerArcLength',
+                    operator: '>',
+                    value: 16
+                },
+                rotationMode: 'circular'
+            },
+            levels: [{
+                level: 1,
+                levelIsConstant: false,
+                dataLabels: {
+                    filter: {
+                        property: 'outerArcLength',
+                        operator: '>',
+                        value: 64
+                    }
+                }
+            }, {
+                level: 2,
+                colorByPoint: true
+            },
+            {
+                level: 3,
+                colorVariation: {
+                    key: 'brightness',
+                    to: -0.5
+                }
+            }, {
+                level: 4,
+                colorVariation: {
+                    key: 'brightness',
+                    to: 0.5
+                }
+            }]
+        }],
+        tooltip: {
+            headerFormat: "",
+            pointFormat: '三藏译文 <b>{point.name}</b> 为 <b>{point.value}</b>'
+        }
+    });
+  });
+
+  $.get("../search/word_list.php",
+  {
+    word : "<?php echo $_GET["word"] ?>"
+  },
+  function(data,status){
+    let worddata =  JSON.parse(data);
+    Highcharts.chart('container_list', {
+        chart: {
+            type: 'bar'
+        },
+        title: {
+            text: 'Declension List'
+        },
+        xAxis: {
+            categories: worddata.wordlist
+        },
+        yAxis: {
+            min: 0,
+            title: {
+                text: 'Frequency'
+            }
+        },
+        legend: {
+            reversed: true
+        },
+        plotOptions: {
+            series: {
+                stacking: 'normal'
+            }
+        },
+        series: worddata.data
+    });
+});
+		</script>
+
+
+<?php
+include "../pcdl/html_foot.php";
+?>

+ 2 - 2
app/pcdl/html_foot.php

@@ -45,9 +45,9 @@
 		</div>
 		<div class="nav_text btn_color">我的</div>
 	</div>
-</div>S
+</div>
 	
-<div class="foot_div">
+<div class="foot_div" style="text-align: center; font-size: x-large; font-weight: bold; color: #3333;">
 	<div>wikipali @2020</div>
 	<div>Powered by PCD Suite</div>
 </div>

+ 2 - 2
app/public/lang/zh-cn.json

@@ -429,8 +429,8 @@
 		"forms": "种形式",
 		"add_to": "添加到",
 		"undone_function": "未完成功能",
-		"": "",
-		"": "",
+		"click_to_chart": "点击查看统计图表",
+		"frequency": "词频",
 		"": ""
 	},
 	"grammastr": [

+ 131 - 0
app/search/word_list.php

@@ -0,0 +1,131 @@
+<?php
+//全文搜索
+require_once '../path.php';
+require_once '../public/casesuf.inc';
+require_once '../public/union.inc';
+require_once "../public/_pdo.php";
+require_once "../public/load_lang.php";//语言文件
+require_once "../public/function.php";
+require_once "../search/word_function.php";
+
+    $resulte = array();
+
+    if(isset($_GET["word"])){
+        $word=mb_strtolower($_GET["word"],'UTF-8'); 
+    }
+    else{
+        echo json_encode($resulte,JSON_UNESCAPED_UNICODE);
+        exit;
+    }
+    _load_book_index();
+
+    $count_return=0;
+    $dict_list=array();
+
+
+
+	//计算某词在三藏中出现的次数		
+    $arrRealWordList = countWordInPali($word);
+
+    $countWord=count($arrRealWordList);
+    if($countWord==0){
+        echo "<p>没有查到。可能是拼写有问题。</p>";
+        exit;
+    }
+    $strQueryWordId="(";//实际出现的单词id查询字串
+    $aQueryWordList=array();//id 为键 拼写为值的数组
+    $aShowWordList=array();//拼写为键 个数为值的数组
+    $aShowWordIdList=array();//拼写为键 值Id的数组
+    for($i=0;$i<$countWord;$i++){
+        $value= $arrRealWordList[$i];
+        $strQueryWordId.="'{$value["id"]}',";
+        $aQueryWordList[$value["id"]]=$value["word"];
+        $aShowWordList[$value["word"]]=$value["count"];
+        $aShowWordIdList[$value["word"]]=$value["id"];
+    }
+    $strQueryWordId=mb_substr($strQueryWordId, 0,mb_strlen($strQueryWordId,"UTF-8")-1,"UTF-8");
+    $strQueryWordId.=")";
+    
+            
+    
+    //显示单词列表
+
+    arsort($aShowWordList);
+    $i=0;
+    $wordlist=array();
+    $wordlist_index = array();
+
+    $sutta = array();
+    $vinaya = array();
+    $abhidhamma = array();
+    $anna = array();
+
+    foreach($aShowWordList as $x=>$x_value) {
+        $wordid=$aShowWordIdList[$x];
+        $wordlist[] = $x;
+        $wordlist_index[$x] = $i;
+        $sutta[]=0;
+        $vinaya[]=0;
+        $abhidhamma[]=0;
+        $anna[]=0;
+        //echo $x.":".$x_value."<br />";
+        $i++;
+    }
+    $resulte["wordlist"] = $wordlist;
+
+    	//查找这些词出现在哪些书中
+	$arrBookType=json_decode(file_get_contents("../public/book_name/booktype.json"));
+	$dictFileName=_FILE_DB_BOOK_WORD_;
+	PDO_Connect("sqlite:$dictFileName");	
+	if(isset($booklist)){
+		foreach($booklist as $oneBook){
+			$aInputBook["{$oneBook}"]=1;
+		}
+	}
+	$query = "select book, wordindex,count from bookword where \"wordindex\" in $strQueryWordId ";
+	$Fetch = PDO_FetchAll($query);
+	$iFetch=count($Fetch);
+    $newBookList=array();
+
+    $worddata = array();
+
+	if($iFetch>0){
+		for($i=0;$i<$iFetch;$i++){
+			$book=$Fetch[$i]["book"];
+
+			array_push($newBookList,array($book,$sum));
+			$t1=$arrBookType[$book-1]->c1;
+            $t2=$arrBookType[$book-1]->c2;
+            switch($t1){
+                case "sutta":
+                    $x =  $aQueryWordList[$Fetch[$i]["wordindex"]];
+                    $sutta[$wordlist_index[$x]] += $Fetch[$i]["count"] ;
+                break;
+                case "vinaya":
+                    $x =  $aQueryWordList[$Fetch[$i]["wordindex"]];
+                    $vinaya[$wordlist_index[$x]] += $Fetch[$i]["count"] ;
+                break;
+                case "abhidhamma":
+                    $x =  $aQueryWordList[$Fetch[$i]["wordindex"]];
+                    $abhidhamma[$wordlist_index[$x]] += $Fetch[$i]["count"] ;
+                break;
+                case "anna":
+                    $x =  $aQueryWordList[$Fetch[$i]["wordindex"]];
+                    $anna[$wordlist_index[$x]] += $Fetch[$i]["count"] ;
+                break;
+            }
+
+        }
+    }
+    $worddata[] = array( "name" => "anna","anna" => $anna);  
+    $worddata[] = array( "name" => "abhidhamma","data" => $abhidhamma);      
+    $worddata[] = array( "name" => "vinaya","data" => $vinaya);    
+    $worddata[] = array( "name" => "sutta","data" => $sutta);
+
+
+
+    $resulte["data"] = $worddata;
+
+    echo json_encode($resulte,JSON_UNESCAPED_UNICODE);
+
+?>

+ 113 - 0
app/search/word_statistics.php

@@ -0,0 +1,113 @@
+<?php
+//全文搜索
+require_once '../path.php';
+require_once '../public/casesuf.inc';
+require_once '../public/union.inc';
+require_once "../public/_pdo.php";
+require_once "../public/load_lang.php";//语言文件
+require_once "../public/function.php";
+require_once "../search/word_function.php";
+
+    $resulte = array();
+    $resulte[] = array("id"=>"0.0", 'parent' => '',  'name' => '全部'  );
+
+    $resulte[] = array("id"=>"sutta", 'parent' => '0.0',  'name' => '经藏'  );
+    $resulte[] = array("id"=>"vinaya", 'parent' => '0.0',  'name' => '律藏'  );
+    $resulte[] = array("id"=>"abhidhamma", 'parent' => '0.0',  'name' => '论藏'  );
+    $resulte[] = array("id"=>"anna", 'parent' => '0.0',  'name' => '其他'  );
+
+    $resulte[] = array("id"=>"sutta.mula", 'parent' => 'sutta',  'name' => '根本'  );
+    $resulte[] = array("id"=>"sutta.atthakattha", 'parent' => 'sutta',  'name' => '义注'  );
+    $resulte[] = array("id"=>"sutta.tika", 'parent' => 'sutta',  'name' => '复注'  );
+    $resulte[] = array("id"=>"sutta.anna", 'parent' => 'sutta',  'name' => '其他'  );
+
+    $resulte[] = array("id"=>"vinaya.mula", 'parent' => 'vinaya',  'name' => '根本'  );
+    $resulte[] = array("id"=>"vinaya.atthakattha", 'parent' => 'vinaya',  'name' => '义注'  );
+    $resulte[] = array("id"=>"vinaya.tika", 'parent' => 'vinaya',  'name' => '复注'  );
+    $resulte[] = array("id"=>"vinaya.anna", 'parent' => 'vinaya',  'name' => '其他'  );
+
+    $resulte[] = array("id"=>"abhidhamma.mula", 'parent' => 'abhidhamma',  'name' => '根本'  );
+    $resulte[] = array("id"=>"abhidhamma.atthakattha", 'parent' => 'abhidhamma',  'name' => '义注'  );
+    $resulte[] = array("id"=>"abhidhamma.tika", 'parent' => 'abhidhamma',  'name' => '复注'  );
+    $resulte[] = array("id"=>"abhidhamma.anna", 'parent' => 'abhidhamma',  'name' => '其他'  );
+
+    $resulte[] = array("id"=>"anna.atthakattha", 'parent' => 'anna',  'name' => '义注'  );
+    $resulte[] = array("id"=>"anna.tika", 'parent' => 'anna',  'name' => '复注'  );
+    $resulte[] = array("id"=>"anna.anna2", 'parent' => 'anna',  'name' => '其他'  );
+
+    if(isset($_GET["word"])){
+        $word=mb_strtolower($_GET["word"],'UTF-8'); 
+    }
+    else{
+        echo json_encode($resulte,JSON_UNESCAPED_UNICODE);
+        exit;
+    }
+    _load_book_index();
+
+    $count_return=0;
+    $dict_list=array();
+
+
+
+	//计算某词在三藏中出现的次数		
+    $arrRealWordList = countWordInPali($word);
+    $countWord=count($arrRealWordList);
+    if($countWord==0){
+        echo "<p>没有查到。可能是拼写有问题。</p>";
+        exit;
+    }
+    $strQueryWordId="(";//实际出现的单词id查询字串
+    $aQueryWordList=array();//id 为键 拼写为值的数组
+    $aShowWordList=array();//拼写为键 个数为值的数组
+    $aShowWordIdList=array();//拼写为键 值Id的数组
+    for($i=0;$i<$countWord;$i++){
+        $value= $arrRealWordList[$i];
+        $strQueryWordId.="'{$value["id"]}',";
+        $aQueryWordList["{$value["id"]}"]=$value["word"];
+        $aShowWordList[$value["word"]]=$value["count"];
+        $aShowWordIdList[$value["word"]]=$value["id"];
+    }
+    $strQueryWordId=mb_substr($strQueryWordId, 0,mb_strlen($strQueryWordId,"UTF-8")-1,"UTF-8");
+    $strQueryWordId.=")";
+    
+            
+    
+    //显示单词列表
+
+    arsort($aShowWordList);
+    $i=0;
+    foreach($aShowWordList as $x=>$x_value) {
+        $wordid=$aShowWordIdList[$x];
+        //echo $x.":".$x_value."<br />";
+        $i++;
+    }
+
+    	//查找这些词出现在哪些书中
+	$arrBookType=json_decode(file_get_contents("../public/book_name/booktype.json"));
+	$dictFileName=_FILE_DB_BOOK_WORD_;
+	PDO_Connect("sqlite:$dictFileName");	
+	if(isset($booklist)){
+		foreach($booklist as $oneBook){
+			$aInputBook["{$oneBook}"]=1;
+		}
+	}
+	$query = "select book,sum(count) as co from bookword where \"wordindex\" in $strQueryWordId group by book order by co DESC";
+	$Fetch = PDO_FetchAll($query);
+	$iFetch=count($Fetch);
+	$newBookList=array();
+	if($iFetch>0){
+		for($i=0;$i<$iFetch;$i++){
+			$book=$Fetch[$i]["book"];
+            $sum=$Fetch[$i]["co"];
+            $sum = $sum + 1;
+            $sum--;
+			array_push($newBookList,array($book,$sum));
+			$t1=$arrBookType[$book-1]->c1;
+            $t2=$arrBookType[$book-1]->c2;
+            $resulte[] = array("id"=>"book".$book, 'parent' => $t1.'.'.$t2,  'name' => _get_book_info($book)->title, 'value' => $sum  );
+        }
+    }
+
+    echo json_encode($resulte,JSON_UNESCAPED_UNICODE);
+
+?>

+ 4 - 4
app/ucenter/index.php

@@ -310,10 +310,10 @@ require_once "../public/function.php";
 		<div id = "login_form_div" class="fun_block" >
 		
 		<?php
-					$host = $_SERVER['HTTP_HOST'];
-					if(strpos ($host,"wikipali.org") !== FALSE){
-						echo "网站正处于开发阶段。目前不支持注册。";
-					}
+		$host = $_SERVER['HTTP_HOST'];
+		if(strpos ($host,"wikipali.org") !== FALSE){
+			echo "网站正处于开发阶段。目前不支持注册。";
+		}
 		if(isset($error_comm)){
 			echo '<div class="form_error">';
 			echo $error_comm;