连接html
一、程序可读入文本文件,且文本文件大小不定,文件路径为相对路径 二、指定单词词频统计功能,可多个输入而且输出柱状图 三、统计该文本全部单词数量及词频数,并能将单词及词频数按字典顺序输出到文件result.txt。 四、可按文本中词频数降序显示前k个单词的词频及单词 五、使用java开发,且jdk环境为jdk8u161,jre环境为jre8u161
·基本功能: 一、指定单词词频统计功能 二、高频词统计功能 三、统计该文本全部单词数量及词频数 ·拓展功能: 无
主程序(包括全部函数)
单词类,存储单词和出现次数
一、lass SortByWord implements Comparator 按字典排序 二、public static void sr()输入词汇统计 三、public static void pxs()高频词汇统计
开始执行
部分功能展现
result.txt部份内容展现
java
try { if(file.exists()) { file.createNewFile(); } Scanner fl=new Scanner(file); while(fl.hasNext()) { word=fl.nextLine(); words=word.split("\"|,|!|\\?|“|”|\\.|…|`|\\(|\\)|-|—|‘|’|&|\\'|:|;|\n|\\,| "); for(int i=0;i<words.length;i++) { add(words[i]); sumnu++; }
Collections.sort(sum, new SortByWord()); File file=new File("result.txt"); try { if(file.exists()) { file.createNewFile(); } FileWriter fop = new FileWriter(file.getAbsoluteFile()); for(Word s : sum ) { fop.write(s.getWord()+":"+s.getNumber()+"\n"); } fop.close(); }catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("写入结束");
根据分析所获得的要求。操做的对象为单词,建立单词类并给予咱们所须要使用的属性。主类、设计到文件的处理及其全部函数的统一调配。根据所需功能建立不一样的函数,以次来实现不一样模块的划分。
PSP2.1 | 计划共完成须要的时间(min) | 实际完成须要的时间(min) |
---|---|---|
Planning | 10 | 5 |
Estimate | 5 | 1 |
Development | 225 | 181 |
Analysis | 30 | 10 |
Design Spec | 20 | 10 |
Design Review | 0 | 0 |
Coding Standard | 30 | 5 |
Design | 10 | 5 |
Coding | 60 | 100 |
Code Review | 10 | 5 |
Test | 20 | 30 |
Reporting | 10 | 5 |
Test Report | 0 | 0 |
Size Measurement | 0 | 0 |
Postmortem & Process Improvement Plan | 20 | 5 |