版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
昆明理工大学信息工程与自动化学院学生实验报告〔2015—2016学年第1学期〕课程名称:信息检索与搜索引擎技术开课实验室:信自楼4442015年11月12日年级、专业、班计科122学号201210405204姓名邹华宇成绩实验工程名称正向最大匹配算法分词指导教师李卫疆教师评语该同学是否了解实验原理: A.了解□ B.根本了解□ C.不了解□该同学的实验能力: A.强□ B.中等□ C.差□该同学的实验是否到达要求: A.到达□ B.根本到达□ C.未到达□实验报告是否标准: A.标准□ B.根本标准□ C.不标准□实验过程是否详细记录: A.详细□ B.一般□ C.没有□教师签名:年月日一、上机目的及内容1、设计程序实现正向最大匹配算法。2、利用正向最大匹配算法将以下语句进行分词,输出分词后的结果。d1:北京安立文高新技术公司d2:新一代的网络访问技术d3:北京卫星网络d4:是最先进的总线技术d5:北京升平卫星技术的新技术有二、实验原理及根本技术路线图三、所用仪器、材料1台PC及Eclipse软件四、实验过程原始记录建立Java工程FMMAlgorithm建立类FMM,编写代码实现该类,如下图运行结果如图示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={"北京升平卫星技术的新技术有。。。", "北京安立文高新技术公司", "新一代的网络访问技术", "北京卫星网络", "是最先进的总线技术。。。" }; for(inti=0;i<strSentence.length;i++){ FMMtest=newFMM(strSentence[i]); test.forwardMaximumMatch(); System.out.println("语句"+(i+1)+":"); if(strSentence[i].isEmpty()) System.out.println("分词语句为空!未进行分词"); else{ System.out.println("分词前的语句:"+strSentence[i]); Sys
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年充电站建设代建管理流程与电力增容
- 2026年儿童青少年近视防控知识讲座总结
- 2026年保险经纪公司并购整合中的风险管理要点
- 2026年经济责任审计内容与方法
- 2026年新员工岗位安全操作规程培训
- 2026年妇科术后康复临床路径制定
- 2026年区块链技术在医疗数据共享中的进展
- 2026年眼科抗VEGF药物市场竞争趋势
- 2026年设计专业开源硬件资源应用课程
- 2026年超声科质量控制指标解读与自查改进培训
- 七子之歌澳门混声合唱谱
- 2018年四川省绵阳市中考地理试卷(解析版)
- 住院患者身体约束护理团标精神科保护性约束实施及解除专家共识
- 如何成为一个合格的面试官课件
- 小学五年级家长会语文老师的课件
- AI在药物研发中的应用
- 新人教版七至九年级英语单词表
- 关键施工技术、工艺与工程项目实施的重点、难点和解决方案
- 2023年环境卫生(正高)考试历年难点与易错点考核试题3答案解析
- 50套普通话测试题与答案
- GB/T 4325.23-2013钼化学分析方法第23部分:氧量和氮量的测定惰气熔融红外吸收法-热导法
评论
0/150
提交评论