連接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 |