项目 | 内容 |
---|---|
课程名称 | 2016级计算机科学与工程学院软件工程(西北师范大学) |
做业要求 | 实验三 软件工程我的项目 |
做业目的 | 1.掌握软件项目我的开发流程 2.掌握Github上发布软件项目的操做方法 |
(1)程序共有两个类。html
(2)数据结构:用HashMap<String, Integer>存储分词后的单词和对应的词频。
(3)整体流程图
java
文件的读入git
高频词统计
github
指定单词词频统计
数据结构
输入到result.txt
ide
一些错误处理
模块化
try { FileInputStream fis = new FileInputStream(filename); BufferedReader br = new BufferedReader(new InputStreamReader(fis)); String temp=""; String info=""; while((temp = br.readLine())!=null) { String[] str = temp.split("([^a-zA-Z])"); //过滤出只含有字母的 for(int i=0;i<str.length;i++) { String word = str[i].trim(); if(word.length()!=0) //去除长度为0的行 staff.put(word, staff.getOrDefault(word, 0)+1); } } br.close(); rank();//按值排序 System.out.println("文件读入成功!请继续..."); }catch(Exception e) { System.out.println("文件不存在!!!请从新确认!"); }
Set<Entry<String,Integer>> mapEntries = staff.entrySet();//该方法将键和值的映射关系做为对象存储到了Set集合中 List<Entry<String,Integer>> aList1 = new ArrayList<Entry<String,Integer>>(mapEntries); //按字典序排序 Collections.sort(aList1, new Comparator<Entry<String,Integer>>() { @Override public int compare(Entry<String, Integer> ele1, Entry<String, Integer> ele2) { return ele1.getKey().compareTo(ele2.getKey()); } }); PrintWriter out = null; try { out = new PrintWriter("result.txt"); out.println("total: "+aList.size()); //输出总词数 for(Entry<String,Integer> entry: aList1) { out.println(entry.getKey()+"\t"+entry.getValue()); } } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } out.close(); System.out.println("已写到result.txt 请继续..."); }
PSP | 任务内容 | 计划共完成须要的时间(min) | 实际完成须要的时间(min) |
---|---|---|---|
Planning | 计划 | 8 | 5 |
Estimate | 估计这个任务须要多少时间,并规划大体工做步骤 | 8 | 5 |
Development | 开发 | 170 | 220 |
Analysis | 需求分析(包括学习新技术) | 20 | 15 |
Design Spec | 生成设计文档 | 10 | 12 |
Design Review | 设计复审 | 11 | 13 |
Coding Standard | 代码规范(为目前的开发制定合适的规范) | 5 | 9 |
Design | 具体设计 | 10 | 12 |
Coding | 具体编码 | 70 | 130 |
Code Review | 代码复审 | 10 | 15 |
Test | 测试(自我测试,修改代码,提交修改) | 30 | 60 |
Reporting | 报告 | 15 | 20 |
Test Report | 测试报告 | 6 | 9 |
Size Measurement | 计算工做量 | 5 | 3 |
Postmortem & Process Improvement Plan | 过后总结,并提出过程改进计划 | 5 | 4 |