【正文】
具進行開發(fā)(本系 統(tǒng)選擇了 Microsoft Visual Studio .NET 2020 作為開發(fā)平臺,開發(fā)語言選擇了 C;數(shù)據(jù)庫采用 Microsoft SQL Server 2020) 。 中國網(wǎng)民對智能化搜索需求 也是顯而易見的。 中文的 意思多種多樣 , 是很難用程序處理的 。但是翻譯僅僅是學(xué)術(shù)方面的應(yīng)用,更重要的是 Google 建立起來的海量搜索歷史記錄。 無論搜索技術(shù)本身還是搜索范圍與深度 , Google 搜索 總是所有搜索引擎的 目標(biāo) 。也是目前最為 流行的基于 Java開源全文檢索工具包。 Asynchronous update。 論文詳細說明了系統(tǒng)開發(fā)的背景,開發(fā)環(huán)境,系統(tǒng)的需求分析,以及功能的設(shè)計與實現(xiàn)。 畢業(yè)設(shè)計 ( 論文 ) 基于 Ajax+Lucene 構(gòu)建搜索引擎的設(shè)計與實現(xiàn) 論文作者姓名: 申請學(xué)位專業(yè): 申請學(xué)位類別: 指導(dǎo)教師姓名(職稱): 論文提交日期: 基于 Ajax+Lucene 構(gòu)建搜索引擎的設(shè)計與實現(xiàn) 摘 要 通過搜索引擎從 互聯(lián)網(wǎng)上 獲取有用信息 已經(jīng)成為 人們生活的重要組成部分, Lucene 是構(gòu)建搜索引擎的其中一種方式 。同時講述了 搜索引擎的原理, 系統(tǒng) 功能 ,并 探討使用 Ajax 與服務(wù)器進行數(shù)據(jù)異步 交互,從而 改善現(xiàn)有的 Web 應(yīng)用模式。 Ajax。 Lucene 是 Java世界中常用的索引 API,使用它提供的方法可以為文本資料創(chuàng)建索引,并提供檢索。 Google 專業(yè)領(lǐng)域搜索方面 做的成效是有目共睹 的 。如果把這些海量搜索歷史記錄當(dāng)作是詞典的話,那么如果與搜索技術(shù)的結(jié)合發(fā)展成為低層次的只能搜索,那么應(yīng)用就將大大加強與廣泛。 目前國內(nèi)外都在做中文引擎,門戶網(wǎng)站、非門戶網(wǎng)站也都在進軍搜索業(yè),成立搜索門戶 。 這也意味著搜索不再是簡單的技術(shù)或者是網(wǎng)絡(luò)導(dǎo)航而已,而是會成為普通人生活中必備的工具之一。由于 Lucene不是完整的搜索引擎程序 , 只為搜索引擎應(yīng)用提供了工具包 , 在 平臺中,可使用 這個對 Lucene 兼容的庫 。當(dāng)用戶查找某個關(guān)鍵詞的時候,所有在頁面內(nèi)容中包含了該關(guān)鍵詞的網(wǎng)頁都將作為搜索結(jié)果被搜出來。 從搜索來源的角度,全文搜索引擎又可細分為兩種,一種是擁有自己的檢索程序( Indexer),俗稱 “ 蜘蛛 ”( Spider) 程序或 “ 機器人 ” ( Robot)程序,并自建網(wǎng)頁數(shù)據(jù)庫,搜索結(jié)果直接從自身的數(shù)據(jù)庫中調(diào)用;另一種則是租用其他引擎的數(shù)據(jù)庫,并按自定的格式排列搜索結(jié)果 。 全文搜索引擎的 “ 網(wǎng)絡(luò)蜘蛛 ” 能夠掃描一定地址范圍內(nèi)的網(wǎng)站,并沿著網(wǎng)絡(luò)上的鏈接從一個網(wǎng)頁到另一個網(wǎng)頁,從一個網(wǎng)站到另一個網(wǎng)站采集網(wǎng)頁資料。不同的搜索引擎,網(wǎng)頁索引數(shù)據(jù)庫不同 , 搜索結(jié)果也就不盡相同。最后,由頁面生成系統(tǒng)將搜索結(jié)果的鏈接地址和頁面內(nèi)容摘要等內(nèi)容組織起來返回給用戶。 Lucene 能夠 為文本類型的數(shù)據(jù)建立索引,所以你只要能把你要索引的數(shù)據(jù)格式轉(zhuǎn)化的文本的, Lucene 就能對你的文檔進行索引和搜索。為什么索引這么重要呢,試想你現(xiàn)在要在大量的文檔中搜索含有某個關(guān)鍵詞的文檔,那么如果不建立索引的話你就需要把這些文檔順序的讀入內(nèi)存,然后檢查這個文章中是不是含有要查找的關(guān)鍵詞,這樣的話就會耗費非常多的時間,想想搜索引擎可是在毫秒級的時間內(nèi)查找出要搜索的結(jié)果的。這樣在用戶輸入查詢條件的時候,就能非??斓牡玫剿阉鹘Y(jié)果。 Ajax 技術(shù) Ajax 全稱為 “Asynchronous JavaScript and XML”(異步 JavaScript 和 XML),是指一種創(chuàng)建交互式網(wǎng)頁應(yīng)用的網(wǎng)頁開發(fā)技術(shù)。后來這個技術(shù)被上述的規(guī)范命名為 XMLHttpRequest。XMLHttpRequest 的出現(xiàn)為 Web 開發(fā)提供了一種全新的可能性,甚至整個改變了人們對于 Web 應(yīng)用由什么來組成的看法。每個頁面上面都包括有一 些使用 JavaScript開發(fā) 的 Ajax 組件。 3. 系統(tǒng) 僅由少量頁面組成。 本設(shè)計要實現(xiàn)的功能: 1. 能夠?qū)?Inter 上的網(wǎng)頁 內(nèi)容、標(biāo)題、鏈接等信息按鏈?zhǔn)绞占?。 5. 對收集到的數(shù)據(jù)進行關(guān)鍵詞的檢索。 9. 邏輯搜索功能比如“中國” AND“北京” AND NOT(“海淀區(qū)” AND“中關(guān)村”)。 搜索時響應(yīng)時間應(yīng)不超過 3 秒,無論搜索的記錄多少。 輸出: Web 頁面上顯示搜索信息。 搜索引擎模型 模型包括 爬蟲、索引生成、查詢以及系統(tǒng)配置部分 。 如圖 4 所示。 輸 入 一 個 U R L結(jié) 果 列 表 啟 動 爬 蟲 程 序 使 用 L u c e n e . n e t 文 檔 類建 立 文 檔 索 引不 斷 的 抓 取 網(wǎng) 頁寫 入 數(shù) 據(jù) 庫去 掉 多 余 標(biāo) 簽獲 取 有 效 記 錄 頁 面 上 輸 入 關(guān) 鍵 字使 用 L u c e n e . n e t 搜 索 類是 否 成 功YA J A X 圖 功能流程圖 第 9 頁 共 19 頁 圖 模塊圖 該系統(tǒng)用 3 個模塊來實現(xiàn)搜索引擎的主要功能。當(dāng)在獲取 URL 時存在這樣的問題就是在實際應(yīng)用中主要以絕對地址和相對地址來表現(xiàn)。因為抓取的網(wǎng)頁含有 HTML 標(biāo)簽、 Javascript 等, 對搜索多余的信息,如果抓取到的網(wǎng)頁不經(jīng)過處理就會使搜索變得不夠 精確。一個Document 對象由多個 Field 對象組成的。針對不同的語言和應(yīng)用需要選擇適合的 Analyzer。在用 Lucene的搜索引擎中,用到了 Lucene 提供的方法,可從所建立的索引文檔中獲得結(jié)果。 關(guān)鍵代碼詳解 代碼結(jié)構(gòu) 如圖 6: 寫入 讀取 生成 引用 檢索 圖 6 代碼結(jié)構(gòu) 在網(wǎng)頁爬蟲 Console 端應(yīng)用程序里輸入一個有效的 URL后這部份就開始從第一個 URL 開始遍歷相關(guān)的鏈接并把相關(guān)的信息寫入到網(wǎng)頁數(shù)據(jù)存儲數(shù)據(jù)庫里,然后就由索引生成程序讀取網(wǎng)頁數(shù)據(jù)存儲數(shù)據(jù)庫,對每條記錄生成索引記錄,存放于生成的索引庫文件里。下面對各部分關(guān)鍵代碼 進行詳解。再下步就是對獲取到的標(biāo)題、網(wǎng)頁內(nèi)容、鏈接等信息調(diào)用數(shù)據(jù)庫操作通用類 DAI 保存到數(shù)據(jù)庫里,這就實現(xiàn)了一個網(wǎng)頁的抓取。 String mata=。 Client=new ()。 return。 urlList = GetHttpUrl(PageString)。 //得到去了 HTML標(biāo)簽的網(wǎng)頁文本 URL=url。amp。+Content+39。+mata+39。 } urlArr=().Split(39。i。 ()。 在創(chuàng)建索引庫時,會合并多個 Segments 文件。 (iDexDir,true)。 int docNum = ()。 } 使用 Lucene 提供的方法對數(shù) 據(jù)庫中的每條記錄建立索引實現(xiàn)如下: 第 13 頁 共 19 頁 Document doc = new Document()。 ((mata,row[mata].ToString()))。 (doc)。在程序中注冊后,在 html 里就可以使用 Javascript 來調(diào)用后臺的程序。 (trtd結(jié)果數(shù) :+result+ 所用時間 :+t+毫秒 /td/tr)。 Document doc = (i)。 (tda href=+(Url)++(title)+/a/td)。 (/tr)。 圖 10 search1 當(dāng)在表單中輸入信息時,結(jié)果以列表形式顯示, 其中 關(guān)鍵字顯示為紅色 ,網(wǎng)頁的 title 顯示為藍色,其他信息包括搜集信息時的日期,內(nèi)容。比較搜索引擎的實現(xiàn)方法,選擇適用于 .Net 平臺的語言和相關(guān)技術(shù)。 3. 用模塊的形式分步展示搜索引擎的原理。比如爬蟲抓取十幾億網(wǎng)頁前后的程序處理。相比之下,本系統(tǒng)的檢索能力就很有限制。 [3] 吳財軍 .C#經(jīng)典范例 50講 [M].北京 :北京希望電子出版社 ,2020。 [7] Paul Nielsen[美 ].Microsoft SQL Server 2020寶典 [M].劉瑞 ,陳微 ,閆繼忠 ,劉文 [譯 ].北京 :中國鐵道出版社 ,2020。除非另有說明,本文的工作是原始性工作。 ( 4)學(xué)校可允許學(xué)位論文被查閱或借閱。 the fly sat upon the axletree of the chariot wheel, and said. What a dust do I raise? So are there some vain persons, that whatsoever goeths indeed! They could tell us something worth hearing, if they only knew how to talk. It39。t know what that is! The journey of the witches on broomsticks is well enough known that journey is taken on St. John39。 for all bravery stands upon parisons. They must needs be violent, to make good their own vaunts. Neithe r can they be secret, and therefore not effectual。 as if a man that negotiates between two princes, to draw them to join in a war against the third, doth extol the forces of either of them above measure, the one to the other: and sometimes, he that deals between man and man, raiseth his own credit with both by pretending greater interest than he hath in either. And in these, and the like kinds, it often falls out that somewhat is produced of nothing: for lies are sufficient to breed opinion, and opinion brings on substance. In military manders and soldiers, vainglory is an essential point。 and virtue was never so beholding to human nature, as it received his due at the second hand. Neither had the fame of Cicero, Seneca, Plinius Secundus, borne her age so well, if it had not been joined with some vanity in themselves: like unto varnish, that makes sealings not only shine, but last But all this while, when I speak of vainglory, I mean not of that property, that Tacitus doth attribute to Mucianus。 In mending another, you do your self right。 the idols of parasites。 for these are the offences which are and have been, and willever be, the source of all the aforesaid evils. The greatest of themare excesses and insolences of youth, and are offences against thegreatest when they are done against religion。 and the f ifth kind is when the violation ofthe civil rights of an individual demands reparation. There shouldbe a mon law embracing all these cases. For we have already said ingeneral terms what shall be the punishment of sacrilege, whetherfraudulent or violent, and now we have to determine what is to bethe punishmen