# HG changeset patch # User Zoe Hong # Date 1427380970 -3600 # Node ID 840cdb52f476af2a167494d185569c1bf3913892 # Parent 3e42a63de0ea8c5af5b29a006637f4333d3091b9 add book_meta into file diff -r 3e42a63de0ea -r 840cdb52f476 .DS_Store Binary file .DS_Store has changed diff -r 3e42a63de0ea -r 840cdb52f476 classes/basemodel.php --- a/classes/basemodel.php Thu Mar 19 09:53:26 2015 +0100 +++ b/classes/basemodel.php Thu Mar 26 15:42:50 2015 +0100 @@ -73,10 +73,10 @@ } protected function GetSectionsByID($section_id) { - $query = sprintf("SELECT * FROM `sections` WHERE `id`=\"%s\"", $section_id); + $query = sprintf("SELECT * FROM `sections_index` WHERE `id`=\"%s\"", $section_id); $result = mysql_query($query); if (!$result){ - echo json_encode("Failed during selecting sections table"); + echo json_encode("Failed during selecting sections_index table"); return; } return $result; diff -r 3e42a63de0ea -r 840cdb52f476 config/config.php --- a/config/config.php Thu Mar 19 09:53:26 2015 +0100 +++ b/config/config.php Thu Mar 26 15:42:50 2015 +0100 @@ -1,26 +1,27 @@ diff -r 3e42a63de0ea -r 840cdb52f476 data/parsing_files/294.txt --- a/data/parsing_files/294.txt Thu Mar 19 09:53:26 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,569 +0,0 @@ - - -2 - -31 -物產名稱 -product_name -rgb(227, 63, 227) - - -32 - -shu -rgb(143, 14, 143) - - -17 -無意義 -null -rgb(219, 219, 219) - - -34 -物產產地 -product_place -rgb(7, 64, 209) - - -26 -別名 -othername -rgb(141, 212, 224) - - -【880】高縣志卷之五十一 -物産志 物土之宜而布其利此先王因地之政也故周禮有土宜之 法以辨土物焉高之土瘠甚其所宜者皆無異物不過日用 所需耳然而民依可念則異物正不足貴而用物貴矣 -原志 -〈稻之屬〉〈稻之屬〉 -〈稻之屬〉 -〈稻之屬〉龍頭穀 -〈稻之屬〉飛蛾穀 -〈稻之屬〉淸香穀 -〈稻之屬〉花邊穀 -〈稻之屬〉桂楊早 -〈稻之屬〉白簾早 -〈稻之屬〉藍黏 -〈稻之屬〉青黏 -〈稻之屬〉白糯 -〈稻之屬〉紅糯 -【881】 -〈麥之屬〉 - -小麥 -大麥 -燕麥 -〈菽之屬〉 - -黃豆 -蠶豆 -菉豆 -刀豆 -黑豆 -豌豆 -白豆 -扁豆 -菉藍豆 -芭山豆 -靑皮豆 -四季豆 -龍爪豆 -紅茶豆 -米豆 -豇豆 -〈秫之屬〉 - -膏糧 -包穀 - -【882】高縣志卷之五十一 -物産志 -〈稻之屬〉 - -龍頭穀 -桂楊早 - - -清香穀 - - -飛蛾穀 -白簾早 - - -花邊穀 - - -〈麥之屬〉 - -小麥 -大麥 -燕麥 -〈菽之屬〉 - -黄豆 -蠶豆 -菉豆 -刀豆 -菉藍豆 -黑豆 -豌豆 -旬豆 -扁豆 -芭山豆 大小二種 -青皮豆 -龍瓜豆 -□豆 -四季豆 -紅茶豆 -□豆 -〈秫之屬〉 - -膏粮 -包穀 - -〈麻之屬〉 - -芝麻 -蘇麻 -黑芝麻 -苧麻 -薗麻 -紅麻 -〈黍之屬〉 - -狗尾粟 五穀米即黄苡 -毛稗 - -【883】 -〈蔬之屬〉 - -白菜 -山藥 -紅□ -蘿白 -筒蒿 -蘄菜 -萵莙 -莙薘 -葱□□ - - - - - - - -芋曹薯 - - - - -番薯 -茭笋 -蘆菔 -苦馬 -野莧 -菁菜 -大頭菜 -〈瓜之屬〉 - -黄瓜 -冬瓜 -南瓜 -西瓜 -北瓜 -苦瓜 -葫蘆 -木瓜 -絲瓜 -菜瓜 -瓠瓜 -線瓜 -〈果之屬〉 - - - - - - - - - - -香圓 -石榴 -金柑 -蜜蠟柑 -佛手橘 -紅花 -板荔 -㯕栗 -〈藥之屬〉 - -黄連 -五加皮 -草麻 -百合 -何苜烏 -金櫻 -益母草 -山藥 -姜黄 -金銀花 -紅花 -山蘿白 -黄瓜米 -菖蒲 - -紫蘇 -薄荷 -黄金 -麥冬 -倍子 -〈花之屬〉 - - - - - -翠屏松 -烟脂 -鳯仙 -海棠 -王簮 -薔薇 -梔子 -鷄冠 -山茶 -茉莉 - -芙蓉 -芍藥 -石榴 -金絲 -海梔 -棉花 -粟 -牡丹 -【884】 -〈麻之屬〉 - -芝麻 -蘇麻 -苧麻 -□麻 -紅麻 -黑芝麻 -〈黍之屬〉 - -狗尾粟 -毛稗 -粟子 -五穀米 -即意苡 -〈蔬之屬〉 - -白菜 -山藥 -紅苕 -蘿蔔 -筒蒿 -蘄菜 -萵苣 -莙薘 -番薯 -茭筍 -蘆菔 -苦蕒 -【885】 -野莧 -青茱 - -大頭菜 - - - - - - - - - - - - - -〈瓜之屬〉 - -黄瓜 -冬瓜 -南瓜 -西瓜 -北瓜 -苦瓜 -木瓜 -絲瓜 -菜瓜 -線瓜 -瓠瓜 -葫蘆 -【886】 -〈果之屬〉 - - - - - - - - - - -香圓 -石榴 -金柑 -蜜臘柑 -佛手橘 -花紅 -板栗 -㯕栗 -核桃 -〈藥之屬〉 - -黄連 -五加皮 -萆麻 -百合 -何首烏 -益母草 -金櫻 -山藥 -【887】 -薑黄 -金銀花 -紅花 -山蘿蔔 -黄瓜米 -菖蒲 -紫蘇 -薄荷 -黄荆 -麥冬 -倍子 - -〈花之屬〉 - - - - - - -牡丹 -海棠 -芙蓉 -芍藥 -鳯仙 -苿莉 -王簪 -海梔 -梔子 -烟脂 -薔藢 -雞冠 -山茶 -石榴 -金絲 -【888】 -棉花 -粟 -翠屏松 -〈木之屬〉 - - - - - - - -椿 - - -桐□ - -即榖木 -閏楠 - -桐子 - -青棡 -槿 -冬青 -白楊 -黄果 -烏柏 -㯕栗 - -水冬瓜 -鹿筋藤 -枇杷 -白果 -【889】 -〈竹之屬〉 - -竹 -苦竹 -方竹 -斑竹 -紫竹 -甜竹 -郎竹 -水竹 -〈草之屬〉 - - -蒲草 - -芭蕉 -馬鞭 -虎耳 -芣苢 -甘蔗 - - -〈畜之屬〉 - - - - -鳥猪 -【890】 - - - - - -鴿 - - -〈毛之屬〉 - - - -鹿 - - - - - - - - - - - -〈羽之屬〉 - - -鸕鷀 -黄連雞 -竹雞 -【891】 - - - - - - -鴒鶉 - - - -鸜鵒 -秦吉了 -雅箐雞 -子規 -畫眉 -野雞 -蒼鶴 -喜 -斑鳩 -〈鱗之屬〉 - - -細鱗 -油魚 - - -鯽魚 -白甲 -赬尾 -魚舅 -金魚 -白條 -【892】 -鱖魚 -桃花魚 -青魚 -青波 -〈介之屬〉 - - - - - -穿山甲 -〈蠱之屬〉 - - - - -土蜜 - -蝸牛 -蜘蛛 - - - - - - -蝙蝠 -蜥蜴 - -【893】 -山蠶 - -蜈蚣 -蜻蜓 - -蟋蟀 -促織 -蜚蠊 -〈石之屬〉 - -石炭 -煤炭 -草皮炭 -棡炭 -石灰 -〈貨之屬〉 - -棉花 -棉布 -苎布 -士紙 -桐油 -菜子 -瓜子 -巖蜜 -藍靛 - -落花生 - -【894】高縣志卷之五十二 -祥異志 明成化元年夏鼠災蔽山盈野嚙食稼穯草木皆盡大者徑 尺如小猪浹旬自滅不知所徃 萬歷元年四月初五日地震八月地震數日三十八年正月 -地震 國朝雍正十年産嘉禾米價每倉斗三分 乾隆八年二月彗星見於西北長丈餘十九年五月大水淹 至縣儀門倉厫亦侵 - - - \ No newline at end of file diff -r 3e42a63de0ea -r 840cdb52f476 data/wordlist/10.txt --- a/data/wordlist/10.txt Thu Mar 19 09:53:26 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -稻
\ No newline at end of file diff -r 3e42a63de0ea -r 840cdb52f476 models/extractapp.php --- a/models/extractapp.php Thu Mar 19 09:53:26 2015 +0100 +++ b/models/extractapp.php Thu Mar 26 15:42:50 2015 +0100 @@ -33,8 +33,9 @@ // get from URL with file_id $lg_text_url = $this->get_text_from_fileId_url.$this->file_id; //$lg_text = file_get_contents($lg_text_url); - // --- parsing meta data + // --- get/set text and parsing meta data from text file $lg_text = $this->ParseMetaData($lg_text_url); + // TODO: maybe need to check if the book_meta is updated. compare the book_meta in text file and from _post (most up-to-date) // ---- @@ -62,6 +63,14 @@ $lg_text_url = $this->get_text_from_sectionId_url.$section_id; $lg_text = file_get_contents($lg_text_url); + // TODO: get book_meta from $_postdata and set $this->book_meta: book_id,book_name,author,year,pagenumber + $book_meta = array(); + array_push($book_meta, array($this->book_id,$this->book_name,"","","")); // missing author,year,pagenumber + + $this->book_meta = $book_meta; + + + $stringInput = $lg_text; $stringInput = preg_replace("/<(.*?)>/u", "○", $stringInput); $stringInput = preg_replace("/ /u", "○", $stringInput); @@ -357,10 +366,11 @@ $book = $this->book_meta; foreach ($book as $b) { $text .= "\n"; - $text .= "".$b[0]."\n"; - $text .= "".$b[1]."\n"; - $text .= "".$b[2]."\n"; - $text .= "".$b[3]."\n"; + $text .= "".$b[0]."\n"; + $text .= "".$b[1]."\n"; + $text .= "".$b[2]."\n"; + $text .= "".$b[3]."\n"; + $text .= "".$b[4]."\n"; $text .= "\n"; } // taglist @@ -382,7 +392,6 @@ } public function SaveFullTextToLGService($_postdata) { // save tagged text (full text) by Jorge's API to lg service - // -------- if ($_postdata['text']){ $date = date('Y_m_d_H_i_s', time()); @@ -708,7 +717,7 @@ echo json_encode(mysql_error()); } $row = mysql_fetch_assoc($result); - $largest_id = $row['AUTO_INCREMENT']; + $largest_id = $row['AUTO_INCREMENT']-1; $topic_id = $_postdata['topic_id']; @@ -1217,12 +1226,11 @@ $this->taglist_infile = $taglistArray; } - // get book meta data + // get book meta data from file $book_meta = $xml->book; $book_metaArray = array(); foreach ($book_meta as $row) { - //array_push($book_metaArray, array('title'=>(string)$row->title,'author'=>(string)$row->author,'year'=>(string)$row->year,'pagenumber'=>(string)$row->pagenumber )); - array_push($book_metaArray, array((string)$row->title,(string)$row->author,(string)$row->year,(string)$row->pagenumber )); + array_push($book_metaArray, array((string)$row->id,(string)$row->name,(string)$row->author,(string)$row->year,(string)$row->pagenumber )); } if ($book_metaArray) { $this->book_meta = $book_metaArray; @@ -1275,6 +1283,17 @@ $stringInput = preg_replace("/【(.*?)】/u", "【\\1】", $stringInput); } + // get book_meta from books table + $book_meta = array(); + $books_result = $this->GetBooksByID($bookId); + while ($row = mysql_fetch_assoc($books_result)) { + array_push($book_meta, array($row['id'],$row['name'],$row['author'],(string)$row['start_year'],(string)$row['line'])); + // use 'start_year' as year, 'line' is pagenumber + } + + $this->book_meta = $book_meta; + + return $stringInput; } diff -r 3e42a63de0ea -r 840cdb52f476 models/home.php --- a/models/home.php Thu Mar 19 09:53:26 2015 +0100 +++ b/models/home.php Thu Mar 26 15:42:50 2015 +0100 @@ -7,11 +7,15 @@ public function Test() { - /* uncomment to do the merge - // merge books table with books_info table - $query = "SELECT books_info.volume, books_info.author, books_info.edition, books_info.books_id FROM books INNER JOIN books_info ON books.id=books_info.books_id"; - $result = mysql_query($query); + return; + } + public function MergeBooksInfoToBooks() { + /* uncomment to do the merge + // merge books table with books_info table + $query = "SELECT books_info.volume, books_info.author, books_info.edition, books_info.books_id FROM books INNER JOIN books_info ON books.id=books_info.books_id"; + + $result = mysql_query($query); if (!$result) { return json_encode("Failed during selecting books, books_info table."); } @@ -19,19 +23,20 @@ $result_alter = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { - // insert row into books_v1 table - echo $row['volume'].$row['author'].$row['edition'].$row['books_id']; + // insert row into books_v1 table + echo $row['volume'].$row['author'].$row['edition'].$row['books_id']; $query_update = "UPDATE books_v1 SET `volume`='".$row['volume']."', `author`='".$row['author']."',`edition`='".$row['edition']."' WHERE `id`='".$row['books_id']."'"; - + $result_update= mysql_query($query_update); if (!$result_update) { echo json_encode("error"); } } - */ + */ return; + } } diff -r 3e42a63de0ea -r 840cdb52f476 views/Extractapp/TaggingText.php --- a/views/Extractapp/TaggingText.php Thu Mar 19 09:53:26 2015 +0100 +++ b/views/Extractapp/TaggingText.php Thu Mar 26 15:42:50 2015 +0100 @@ -14,7 +14,6 @@ $taglist_infile = $viewmodel['taglist_infile']; $book_meta = $viewmodel['book_meta']; - ?>