信息檢索與搜索引擎技術實驗向量空間模型_第1頁
信息檢索與搜索引擎技術實驗向量空間模型_第2頁
信息檢索與搜索引擎技術實驗向量空間模型_第3頁
信息檢索與搜索引擎技術實驗向量空間模型_第4頁
信息檢索與搜索引擎技術實驗向量空間模型_第5頁
已閱讀5頁,還剩8頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、昆明理工大學信息工程與自動化學院學生實驗報告 20212021學年第 1學期課程名稱:信息檢索與搜索引擎技術 開課實驗室:信自樓445 2021 年12月 23日年級、專業(yè)、班計科111學號202110405138成績實驗工程名稱向量空間模型指導教師李衛(wèi)疆教師評語該同學是否了解實驗原理:A.了解B.根本了解C.不了解該同學的實驗能力:A.強 B.中等 C.差 該同學的實驗是否到達要求:A.到達B.根本到達C.未到達實驗報告是否標準:A.標準B.根本標準C.不標準實驗過程是否詳細記錄:A.詳細B.一般 C.沒有 教師簽名: 年 月 日一、 上機目的及內(nèi)容:給定文檔語料: d1: 北京安立文高新技

2、術公司d2: 新一代的網(wǎng)絡訪問技術d3: 北京衛(wèi)星網(wǎng)絡d4: 是最先進的總線技術。d5: 北京升平衛(wèi)星技術的新技術有。設計一個針對這些文檔的信息檢索系統(tǒng)。具體要求是:1) 給出系統(tǒng)的有效詞聚集合說明取舍原因。2) 寫出d1和d2在VSM中的表示使用tf*idf,寫出各項的數(shù)字表達式,具體數(shù)值不必實際計算出來。3) 畫出系統(tǒng)的倒排文件示意圖。4) 按照向量夾角的余弦計算公式,給出針對查詢“技術的公司的前3個反應結果。二、 實驗原理給定文檔語料: d1: 北京安立文高新技術公司 d2: 新一代的網(wǎng)絡訪問技術d3: 北京衛(wèi)星網(wǎng)絡 d4: 是最先進的總線技術。d5: 北京升平衛(wèi)星技術的新技術有。設計一

3、個針對這些文檔的信息檢索系統(tǒng)。具體要求是:1) 給出系統(tǒng)的有效詞聚集合說明取舍原因。北京、安、立、文、高新、技術、公司、新、網(wǎng)絡、訪問、衛(wèi)星、有限、先進、總線、升、平的、是、最、有,這些詞作為停用詞不能參加系統(tǒng)的有效集合一、代,去除后并不影響原來句子語義的表達也不能算作系統(tǒng)的有效集合。2) 寫出d1和d2在VSM中的表示使用tf*idf,寫出各項的數(shù)字表達式,具體數(shù)值不必實際計算出來。 得到的矩陣:Termd1d2d3d4d5Term出現(xiàn)次數(shù)北京101013安100001立100001文100001高新100001技術110013公司101013新010012網(wǎng)絡011002訪問010001衛(wèi)

4、星001012有限001012先進000101總線000101升000011平000011TF×IDF=cikj=1tcij×logNnk說明:TF:表示詞項在該文檔或者查詢詞中出現(xiàn)的頻度。即該詞項出現(xiàn)次數(shù)除以該文檔的長度所有詞的個數(shù)cik:表示詞項k在Di中的出現(xiàn)次數(shù)。j=1tcij:表示該文檔的長度所有詞的個數(shù)IDF:表示詞項在文檔集合中的重要程度。一個詞項出現(xiàn)的文檔數(shù)越多,說明該詞項的區(qū)分度越差,其在文檔集合中的重要性就越低。N:表示集合中的文檔數(shù);nk:表示出現(xiàn)詞項k的文檔數(shù)。d1中各詞項的數(shù)字表達式“北京的TF×IDF=17×log53“安的T

5、F×IDF=17×log51“立的TF×IDF=17×log51“文的TF×IDF=17×log51“高新的TF×IDF=17×log51“技術的TF×IDF=17×log53“公司的TF×IDF=17×log53d2中各詞項的數(shù)字表達式:“新的TF×IDF=17×log52“網(wǎng)絡的TF×IDF=17×log52“訪問的TF×IDF=17×log51“技術的TF×IDF=17×log533) 畫出

6、系統(tǒng)的倒排文件示意圖。 4) 按照向量夾角的余弦計算公式,給出針對查詢“技術的公司的前3個反應結果。該局部由代碼實現(xiàn)。三、 實驗方法、步驟1 建立Java工程,2 建立DocumentStruct.java類文件并編輯3 建立TextVector.java類文件并編輯,如圖4-1,圖4-2所示圖4-1圖4-24 建立TF.java類文件并編輯,如圖圖4-7所示圖4-45 建立IDF.java類文件并編輯,如圖圖4-5所示圖4-56 建立CaculateSim.java類文件并編輯,如圖4-6所示圖4-67 建立MainApp.java類文件并編輯,圖4-7所示圖4-78 完成后的工程文件夾如圖

7、4-8所示圖4-89 運行結果如圖4-9所示-13-1. DocumentStruct.java代碼:packageacm.model;public class DocumentStruct publicDocumentStruct()this.documentID = 0;this.documentSimValue = 0;this.documentContent = "None"this.documentName = "None"publicDocumentStruct(int ID, double sim, String name, String

8、content)this.documentID = ID;this.documentSimValue = sim;this.documentName = name;this.documentContent = content;public String getDocumentContent() returndocumentContent;public void setDocumentContent(String documentContent) this.documentContent = documentContent;public String getDocumentName() retu

9、rndocumentName;public void setDocumentName(String documentName) this.documentName = documentName;public double getDocumentSimValue() returndocumentSimValue;public void setDocumentSimValue(double documentSimValue) this.documentSimValue = documentSimValue;publicintgetDocumentID() returndocumentID;publ

10、ic void setDocumentID(intdocumentID) this.documentID = documentID;publicDocumentStruct sortDocBySim(DocumentStruct docList)DocumentStruct temp;for(inti=0; i<docList.length-1; i+)for(int j=i; j<docList.length-1; j+)if(docListi.getDocumentSimValue() <docListj.getDocumentSimValue() )temp = doc

11、Listi;docListi = docListj;docListj = temp;returndocList;private String documentName;private String documentContent;private double documentSimValue;privateintdocumentID;2. TextVector.java代碼:packageacm.model;public class TextVector publicTextVector(int dimension, int termCount, intdocumentTermCount, i

12、ntdocumentCount, int documentContainTermCount)vectorWeight = new doubledimension;for(inti=0; i<dimension; i+)vectorWeighti = caculateWeight(termCounti, documentTermCount, documentCount, documentContainTermCounti);public double caculateWeight(inttermCount, intdocumentTermCount, intdocumentCount, i

13、ntdocumentContainTermCount)TF termTF = new TF(termCount, documentTermCount);IDF termIDF = new IDF(documentCount, documentContainTermCount);termTF.caculateTF();termIDF.caculateIDF();return(termTF.getTf()*termIDF.getIdf();public double getVectorWeight() returnvectorWeight;public void setVectorWeight(d

14、ouble vectorWeight) this.vectorWeight = vectorWeight;private double vectorWeight;3. TF.java代碼packageacm.model;public class TF public TF()tf = 0.0;termCount = 0;termInDocumentCount = 0;public TF(inttermCount, intdocumentTermCount)this.tf = 0.0;this.termCount = termCount;this.termInDocumentCount = doc

15、umentTermCount;public void caculateTF()if(termInDocumentCount = 0)System.out.println("請先設置文檔總數(shù)!");return;this.tf = (double)termCount / (double)termInDocumentCount;public double getTf() returntf;publicintgetTermCount() returntermCount;public void setTermCount(inttermCount) this.termCount =

16、termCount;publicintgetTermInDocumentCount() returntermInDocumentCount;public void setTermInDocumentCount(inttermInDocumentCount) this.termInDocumentCount = termInDocumentCount;private double tf;privateinttermCount;privateinttermInDocumentCount;4. IDF.java代碼packageacm.model;public class IDF public ID

17、F() idf = 0.0;documentContainTermCount = 0;documentCount = 0;public IDF(intdocumentCount, intdocumentContainTermCount)idf = 0.0;this.documentCount = documentCount;this.documentContainTermCount = documentContainTermCount;publicintgetDocumentCount() returndocumentCount;public void setDocumentCount(int

18、documentCount) this.documentCount = documentCount;publicintgetDocumentContainTermCount() returndocumentContainTermCount;public void setDocumentContainTermCount(intdocumentContainTermCount) this.documentContainTermCount = documentContainTermCount;public double getIdf() returnidf;public void caculateI

19、DF()if(documentContainTermCount = 0)System.out.println("請設置文檔的長度所有詞的個數(shù)!");return;this.idf = Math.log10(double)this.documentCount / (double)this.documentContainTermCount);private double idf;privateintdocumentCount;privateintdocumentContainTermCount;5. CaculateSim.java代碼packageacm.model;publ

20、ic class CaculateSim publicCaculateSim(TextVector vector1, TextVector vector2)doublesimDividend=0.0, simDivider=0.0;double tempVector1=0.0, tempVector2=0.0;for(inti=0; i<vector1.getVectorWeight().length; i+)simDividend += vector1.getVectorWeight()i * vector2.getVectorWeight()i;for(inti=0; i<ve

21、ctor1.getVectorWeight().length; i+)tempVector1 += Math.pow(vector1.getVectorWeight()i, 2.0);tempVector2 += Math.pow(vector2.getVectorWeight()i, 2.0);simDivider = Math.sqrt(tempVector1*tempVector2);this.sim = simDividend / simDivider;public double getSim() returnsim;private double sim;6. MainApp.java

22、代碼packageacm.model;public class MainApp public static void main(String args) intTermCount = 1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,1,0,1,1,1,0,0,0,0,0,0, 1,0,0,0,0,0,1,0,1,0,1,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0, 1,0,0,0,0,1,1,1,0,0,1,1,0,0,1,1, 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0;intdocument

23、TermCount = 7, 7, 5, 6, 11, 3;intdocumentContainTermCount = 3,1,1,1,1,4,4,2,2,1,2,2,1,1,1,1;DocumentStruct docList = new DocumentStruct6;String documentContent = "北京安立文高新技術公司","新一代的網(wǎng)絡訪問技術","北京衛(wèi)星網(wǎng)絡","是最先進的總線技術。","北京升平衛(wèi)星技術的新技術有。","技術的公司"TextVectorqueryVector = new Text

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論