为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

敏感词汇分析

2012-07-01 18页 doc 257KB 248阅读

用户头像

is_892850

暂无简介

举报
敏感词汇分析 软 件 学 院 课程设计报告书 课程名称 面向对象程序设计 设计题目 敏感词汇分析程序 专业班级 软件工程10-02班 学 号 1020010209 姓 名 胡 广 亚 ...
敏感词汇分析
软 件 学 院 课程设计书 课程名称 面向对象程序设计 设计题目 敏感词汇分析程序 专业班级 软件工程10-02班 学 号 1020010209 姓 名 胡 广 亚 指导教师 李 建 东 2012年6月 目录 3 1 设计时间 3 2 设计目的 3 3设计任务 3 4 设计内容 3 4.1需求分析 3 4.1.1问题描述 3 4.1.2基本要求 3 4.2总体设计 4 4.2.1包的描述(无) 4 4.2.2 类的描述 4 4.2.3类之间的关系 5 4.3详细设计 5 4.3.1类图 6 4.3.2页面设计 6 4.4测试与分析 6 4.5 程序代码 6 5总结与展望 6 参考文献 6 课程设计成绩评定 if (accept(f) && state == JFileChooser.APPROVE_OPTION) {return true;} return false;} } class CFileChooseLis implements ActionListener { public CFileChooseLis(TextComponent rst) { t = rst;} TextComponent t; public void actionPerformed(ActionEvent e) { if (t == null) return; CFileChooser chooser = new CFileChooser(); if (chooser.choosedFile()) { File f = chooser.getSelectedFile(); t.setText(f.getAbsolutePath());} } } class CAnalyzeLis implements ActionListener { File analyzeF; File dictionaryF; TextComponent rst; Window window; public CAnalyzeLis(FileTextChecker w, TextComponent tcomp) { analyzeF = w.getAnalyzeFile(); dictionaryF = w.getDictionFile(); rst = tcomp; window = w; } // @Override public void actionPerformed(ActionEvent e) { ((FileTextChecker)window).initFile(); analyzeF = ((FileTextChecker)window).getAnalyzeFile(); dictionaryF = ((FileTextChecker)window).getDictionFile(); if (analyzeF == null) { JOptionPane.showMessageDialog(window, "未添加分析文档,点击“确定”重新添加."); return;} if (dictionaryF == null) { JOptionPane.showMessageDialog(window, "未添加敏感词汇库,点击“确定”重新添加."); return;} Set set = new TreeSet(); String text = null; Hashtable table = new Hashtable(); try { text = readTextFormFile(analyzeF); readWordFormFile(set, dictionaryF); Iterator t = set.iterator(); while (t.hasNext()) { String s = t.next(); if (s.length() >= 1) { String reg = s; Pattern pat = Pattern.compile(reg); Matcher mat = pat.matcher(text); while (mat.find()) { if (table.get(s) != null) { table.get(s).add(); } else { table.put(s, new IntString(1)); } } } } Iterator t2 = table.keySet().iterator(); StringBuffer result = new StringBuffer(); while (t2.hasNext()) { String r = t2.next(); result.append(r); result.append(" : "); result.append("" + table.get(r).getNumber()); result.append('\n');} rst.setText(result.toString());} catch (Exception ev) { ev.printStackTrace(); JOptionPane.showMessageDialog(window, "文件读取错误."); } } // static public static void readWordFormFile(Set s, File f) { if (s== null || f== null) return; BufferedReader br; String str; try { br = new BufferedReader( new FileReader(f)); while ((str = br.readLine()) != null) { s.add(str.trim()); } br.close(); } catch (Exception e) {} } public static String readTextFormFile(File f) { if (f== null) return null; StringBuffer bf = new StringBuffer(); BufferedReader br; String str; try { br = new BufferedReader( new FileReader(f)); while ((str = br.readLine()) != null) { bf.append(str); bf.append('\n'); } br.close(); return bf.toString(); } catch (Exception e) {} return null; } } 5总结与展望 通过本次课程设计的实践,我初步完成了一个关于敏感词汇分析的小应用程序。在课程设计过程中,我发现了我在Java编程方便存在的不足可一些收获。最大的收获就是自己通过学习,将所有的基础知识进行了一次大的综合的练习,把自己之前所学的内容穿到了一起,形成了一种知识体系。对于本次课程设计的成果,由于时间关系,同时也存在着一些功能上的不完善,比如次程序还可以在此基础上,开发出自动删除或屏蔽敏感词汇,开发出词汇自动统计功能,从而运用到更广泛的领域上去。总体来说,本次课程设计的意义重大,让我领悟了Java编程的主题思想和方法技巧,对我的学习是一种提高,也对我未来从事编程方面的研究起到了基础性的作用。 本次课程设计综合考察了我们对Java程序设计知识的掌握熟练程度和实际运用能力。其间,涉及到了Java 中的绝大多数的知识点,如Java图形用户界面设计、Java的异常处理机制、Java中的多线程程序设计、Java输入输出流等。 参考文献 [1] 刘万军,郑少京,王松波,梁清华等《Java6程序设计》,.第1版, 清华大学出版社,2009 [2] 李明洋,《Java技术应用原理》,第一版,电子科技大学出版社,2008 课程设计成绩评定 出勤 情况 缺勤次数: 课程 设计 评估 设计成绩 教师签字 主类 FileTextChecker IntString默认属性类,完成字符计数功能。 CFileChooser默认属性类,完成文本选择功能。 CFileChooseLis默认属性类,完成文本选择功能中的异常处理。 CAnalyzeLis默认属性类,完成敏感词汇的分析。 类:FileTextChecker IntString CFileChooser CFileChooseLis CAnalyzeLis 变量: FileTextChecker:b1, b2, b3, l1, l2, f1, f2, p1, p10, P11, p12, p13, p14, num IntString: num CFileChooser: state, f CFileChooseLis: f CAnalyzeLis: analyzeF, dictionaryF, rst, window 方法: 构造方法: FileTextChecker(),IntString(inti), CFileChooseLis(TextComponent rst) CAnalyzeLis(FileTextChecker w, TextComponent tcomp) 方法: iniFrame(),getAnalyzeFile(),getDictionFile(),initFile() getNumber(),add(),accept(File f), choosedFile() actionPerformed(ActionEvent,e) actionPerformed(ActionEvent e), readTextFormFile(File f)
/
本文档为【敏感词汇分析】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索