昆明理工大學(xué)-正向最大匹配算法分詞_第1頁(yè)
昆明理工大學(xué)-正向最大匹配算法分詞_第2頁(yè)
昆明理工大學(xué)-正向最大匹配算法分詞_第3頁(yè)
昆明理工大學(xué)-正向最大匹配算法分詞_第4頁(yè)
昆明理工大學(xué)-正向最大匹配算法分詞_第5頁(yè)
已閱讀5頁(yè),還剩3頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

昆明理工大學(xué)信息工程與自動(dòng)化學(xué)院學(xué)生實(shí)驗(yàn)報(bào)告〔2015—2016學(xué)年第1學(xué)期〕課程名稱:信息檢索與搜索引擎技術(shù)開課實(shí)驗(yàn)室:信自樓4442015年11月12日年級(jí)、專業(yè)、班計(jì)科122學(xué)號(hào)201210405204姓名鄒華宇成績(jī)實(shí)驗(yàn)工程名稱正向最大匹配算法分詞指導(dǎo)教師李衛(wèi)疆教師評(píng)語(yǔ)該同學(xué)是否了解實(shí)驗(yàn)原理: A.了解□ B.根本了解□ C.不了解□該同學(xué)的實(shí)驗(yàn)?zāi)芰Γ? A.強(qiáng)□ B.中等□ C.差□該同學(xué)的實(shí)驗(yàn)是否到達(dá)要求: A.到達(dá)□ B.根本到達(dá)□ C.未到達(dá)□實(shí)驗(yàn)報(bào)告是否標(biāo)準(zhǔn): A.標(biāo)準(zhǔn)□ B.根本標(biāo)準(zhǔn)□ C.不標(biāo)準(zhǔn)□實(shí)驗(yàn)過(guò)程是否詳細(xì)記錄: A.詳細(xì)□ B.一般□ C.沒有□教師簽名:年月日一、上機(jī)目的及內(nèi)容1、設(shè)計(jì)程序?qū)崿F(xiàn)正向最大匹配算法。2、利用正向最大匹配算法將以下語(yǔ)句進(jìn)行分詞,輸出分詞后的結(jié)果。d1:北京安立文高新技術(shù)公司d2:新一代的網(wǎng)絡(luò)訪問(wèn)技術(shù)d3:北京衛(wèi)星網(wǎng)絡(luò)d4:是最先進(jìn)的總線技術(shù)d5:北京升平衛(wèi)星技術(shù)的新技術(shù)有二、實(shí)驗(yàn)原理及根本技術(shù)路線圖三、所用儀器、材料1臺(tái)PC及Eclipse軟件四、實(shí)驗(yàn)過(guò)程原始記錄建立Java工程FMMAlgorithm建立類FMM,編寫代碼實(shí)現(xiàn)該類,如下圖運(yùn)行結(jié)果如圖示FMM.java代碼如下:packagemodel;importjava.io.*;importjava.util.*;publicclassFMM{ privateStringsource; privateStringresult; privateStringdictionaryPath; publicFMM(Stringsource){ this.source=source; this.result=""; this.dictionaryPath="Dictionary.txt"; } publicFMM(Stringsource,StringdictionaryPath){ this.source=source; this.result=""; this.dictionaryPath=dictionaryPath; } publicStringgetSource(){ returnsource; } publicStringgetResult(){ returnresult; } publicArrayList<String>setDictionary(){ ArrayList<String>dictionaryList=newArrayList<String>(); try{ FiledictionaryFile=newFile(this.dictionaryPath); if(!dictionaryFile.exists()){ System.out.println("Can'tFindDictionaryfile!"); returndictionaryList; } Scannerinput=newScanner(dictionaryFile); while(input.hasNext()){ dictionaryList.add(input.nextLine()); } input.close(); }catch(FileNotFoundExceptione){ System.out.println(e.toString()); } returndictionaryList; } publicintdictionaryMaxLength(){ returndictionaryMaxLength(setDictionary()); } publicintdictionaryMaxLength(ArrayList<String>dictionaryList){ intwordMaxLength=0; for(inti=0;i<dictionaryList.size();i++){ if(wordMaxLength<dictionaryList.get(i).length()) wordMaxLength=dictionaryList.get(i).length(); } returnwordMaxLength; } publicStringLeft(Stringsource,intlength){ returnsource.substring(0,length); } publicStringRight(Stringsource,intlength){ returnsource.substring(length); } publicvoidforwardMaximumMatch(){ forwardMaximumMatch(this.source); return; } publicvoidforwardMaximumMatch(Stringsource){ forwardMaximumMatch(source,setDictionary()); return; } publicvoidforwardMaximumMatch(Stringsource,ArrayList<String>dictionaryList){ Stringresult=""; Stringtemp=""; intwordMaxLength=dictionaryMaxLength(dictionaryList); while(!source.isEmpty()){ if(source.length()>=wordMaxLength) temp=Left(source,wordMaxLength); else temp=Left(source,source.length()); intmatchLength=wordMaxLength; do{ if(!dictionaryList.contains(temp)){ temp=Left(temp,matchLength-1); matchLength--; }else break; }while(temp.length()!=1); result+=temp+"/"; if((source=Right(source,temp.length())).isEmpty()) result=result.substring(0,result.length()-1); } this.result=result; return; } publicstaticvoidmain(String[]args){ String[]strSentence={"北京升平衛(wèi)星技術(shù)的新技術(shù)有。。。", "北京安立文高新技術(shù)公司", "新一代的網(wǎng)絡(luò)訪問(wèn)技術(shù)", "北京衛(wèi)星網(wǎng)絡(luò)", "是最先進(jìn)的總線技術(shù)。。。" }; for(inti=0;i<strSentence.length;i++){ FMMtest=newFMM(strSentence[i]); test.forwardMaximumMatch(); System.out.println("語(yǔ)句"+(i+1)+":"); if(strSentence[i].isEmpty()) System.out.println("分詞語(yǔ)句為空!未進(jìn)行分詞"); else{ System.out.println("分詞前的語(yǔ)句:"+strSentence[i]); Sys

溫馨提示

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

評(píng)論

0/150

提交評(píng)論