信息检索与搜索引擎技术实验正向最大匹配算法分词_第1页
信息检索与搜索引擎技术实验正向最大匹配算法分词_第2页
信息检索与搜索引擎技术实验正向最大匹配算法分词_第3页
信息检索与搜索引擎技术实验正向最大匹配算法分词_第4页
信息检索与搜索引擎技术实验正向最大匹配算法分词_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

昆明理工大学信息工程与自动化学院学生实验报告( 2014 2015 学年 第 1 学期 )课程名称:信息检索与搜索引擎技术 开课实验室:信自楼445 2014 年12月 9日年级、专业、班计科111学号201110405138姓名成绩实验项目名称正向最大匹配算法分词指导教师 李卫疆教师评语该同学是否了解实验原理: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软件四、 实验过程原始记录1. 建立Java项目FMMAlgorithm 2. 建立类FMM,3. 编写代码实现该类,如图4-3所示图4-34. 运行结果如图4-4所示图4-4-5-5. FMM.java代码如下:package model;import java.io.*;import java.util.*;public class FMM private String source;private String result;private String dictionaryPath;public FMM(String source) this.source = source;this.result = ;this.dictionaryPath = Dictionary.txt;public FMM(String source, String dictionaryPath) this.source = source;this.result = ;this.dictionaryPath = dictionaryPath;public String getSource() return source;public String getResult() return result;public ArrayList setDictionary() ArrayList dictionaryList = new ArrayList();try File dictionaryFile = new File(this.dictionaryPath);if(!dictionaryFile.exists()System.out.println(Cant Find Dictionary file!);return dictionaryList;Scanner input = new Scanner(dictionaryFile);while(input.hasNext()dictionaryList.add(input.nextLine();input.close(); catch (FileNotFoundException e) System.out.println(e.toString();return dictionaryList;public int dictionaryMaxLength()return dictionaryMaxLength(setDictionary();public int dictionaryMaxLength(ArrayList dictionaryList) int wordMaxLength = 0;for(int i=0; i dictionaryList.size(); i+)if(wordMaxLength dictionaryList.get(i).length()wordMaxLength = dictionaryList.get(i).length();return wordMaxLength;public String Left(String source, int length) return source.substring(0, length); public String Right(String source, int length) return source.substring(length);public void forwardMaximumMatch()forwardMaximumMatch(this.source);return;public void forwardMaximumMatch(String source)forwardMaximumMatch(source, setDictionary();return;public void forwardMaximumMatch(String source, ArrayList dictionaryList) String result=;String temp=;int wordMaxLength = dictionaryMaxLength(dictionaryList);while(!source.isEmpty()if(source.length() = wordMaxLength)temp = Left(source, wordMaxLength);elsetemp = Left(source, source.length();int matchLength = wordMaxLength;doif(!dictionaryList.contains(temp)temp = Left(temp, matchLength-1);matchLength-;elsebreak;while(temp.length() != 1);result += temp + /;if(source = Right(source, temp.length().isEmpty()result = result.substring(0, result.length()-1);this.result = result;return;public static void main(String args) String strSentence = 北京升平卫星技术有限公司的新技术有。,北京安立文高新技术公司,新一代的网络访问技术,北京卫星网络有限公司,是最先进的总线技术。;for(int i=0; istrSentence.length; i+)FMM test = new FMM(strSentencei);test.forwardMaximumMatch();System.out.println(语句+(i+1)+:);if(strSentencei.isEmpty()System.out.println(分词语句为空!未进行分词);elseSystem.out.println(分词前的语句: + strSentencei);S

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论