項目 | 內容 |
---|---|
這個做業屬於哪一個課程 | http://www.cnblogs.com/nwnu-daizh/ |
這個做業的要求在哪裏 | https://www.cnblogs.com/nwnu-daizh/p/10569690.html |
課程學習目標 | 熟悉軟件開發總體流程,提高自身能力 |
本次做業在哪一個具體方面幫助咱們實現目標 | 第一次體驗一個完整的工程 |
a.需求分析.css
(1)程序可讀入任意英文文本文件,該文件中英文詞數大於等於1個。 (2)程序須要很壯健,能讀取容納英文原版《哈利波特》10萬詞以上的文章。 (3)指定單詞詞頻統計功能:用戶可輸入從該文本中想要查找詞頻的一個或任意多個英文單詞,運行程序的統計功能可顯示對應單詞在文本中出現的次數和柱狀圖。 (4)高頻詞統計功能:用戶從鍵盤輸入高頻詞輸出的個數k,運行程序統計功能,可按文本中詞頻數降序顯示前k個單詞的詞頻及單詞。 (5)統計該文本全部單詞數量及詞頻數,並能將單詞及詞頻數按字典順序輸出到文件result.txt。 (6)統計該文本行數及字符數; (7)各類統計功能均提供計時功能,顯示程序統計所消耗時間(單位:ms); (8)可處理任意用戶導入的任意英文文本; (9)人機交互界面要求GUI界面(WEB頁面、APP頁面均可);
b.核心功能代碼展現:展現核心功能代碼.html
public void SortWords() throws IOException{ System.out.println("已輸出到result2.txt中"); BufferedReader bufferedReader=new BufferedReader(new FileReader("src/Harrypotter.txt")); BufferedWriter bufferedWriter=new BufferedWriter(new FileWriter("src/result2.txt")); String s; while((s=bufferedReader.readLine())!=null){ Map<String, Integer> map=new TreeMap<String,Integer>(); String[] words=s.split("[【】、.。,\"!--;:?\'\\] ]"); for(int i=0;i<words.length;i++){ String key=words[i].toLowerCase(); if(key.length()>0){ if(!map.containsKey(key)){ map.put(key, 1); }else{ int value=map.get(key); value++; map.put(key, value); } } } Set<Map.Entry<String, Integer>> entrySet=map.entrySet(); for(Map.Entry<String, Integer> entery:entrySet){ bufferedWriter.write(entery.getKey()+"---"+entery.getValue()+"\r\n"); } bufferedWriter.newLine(); } bufferedReader.close(); bufferedWriter.close(); }
public Find(String[] word, Map<String, Integer> wordsCount) { super(); this.word = word; this.wordsCount = wordsCount; setTitle("繪製柱形圖"); setBounds(word.length, 200, 450, 450); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public Find() { } @Override public void paint(Graphics g) { int Width = getWidth(); int Height = getHeight(); int leftMargin = 50;// 柱形圖左邊界 int topMargin = 50;// 柱形圖上邊界 Graphics2D g2 = (Graphics2D) g; int ruler = Height - topMargin; int rulerStep = ruler / 20;// 將當前的高度評分爲20個單位 g2.setColor(Color.WHITE);// 繪製白色背景 g2.fillRect(0, 0, Width, Height);// 繪製矩形圖 g2.setColor(Color.LIGHT_GRAY); for (int i = 0; i < rulerStep; i++) { g2.drawString((400 - 20 * i) + "個", 8, topMargin + rulerStep * i);// 繪製Y軸上的數據 } g2.setColor(Color.BLUE); int m = 0; for (int i = 0; i < word.length; i++) { int value = wordsCount.get(word[i]); int step = (m + 1) * 40;// 設置每隔柱形圖的水平間隔爲40 g2.fillRoundRect(leftMargin + step * 2, Height - value, 40, value, 0, 0);// 繪製每一個柱狀條 g2.drawString(word[i], leftMargin + step * 2, Height - value - 5); // 標識每一個柱狀條 m++; } }
// Initializing counters int countWord = 0; int sentenceCount = 0; int characterCount = 0; int paragraphCount = 1; int whitespaceCount = 0; try { if (file.exists()) { FileReader fr = new FileReader(file); LineNumberReader lnr = new LineNumberReader(fr); int lineNum = 0; while (lnr.readLine() != null) { lineNum++; } System.out.println("該文本文檔的總行數爲 : " + lineNum); lnr.close(); } else { System.out.println("File does not exists!"); } } catch (IOException e) { e.printStackTrace(); } // Reading line by line from the // file until a null is returned while ((line = reader.readLine()) != null) { if (line.equals("")) { paragraphCount++; } if (!(line.equals(""))) { characterCount += line.length(); // \s+ is the space delimiter in java String[] wordList = line.split("/s+"); countWord += wordList.length; whitespaceCount += countWord - 1; // [!?.:]+ is the sentence delimiter in java String[] sentenceList = line.split("[!?.:]+"); sentenceCount += sentenceList.length; } }
c.程序運行:程序運行時每一個功能界面截圖.前端
人機交互界面首頁.
java
細節功能.
git
細節功能.
github
實現的功能.
eclipse
功能實現結果.
ide
d. 描述結對的過程.
函數
咱們兩在一塊兒行動四年,很是有默契。因爲平時的課業比較多,因此咱們儘可能在上課的時間多作一些,包括平時沒課的時候也一塊兒在機房自習作這個實驗。
e. 提供這次結對做業的PSP。.佈局
PSP2.1 | 任務內容 | 計劃共完成須要的時間(min) | 實際完成須要的時間(min) |
---|---|---|---|
Planning | 計劃 | 10 | 9 |
Estimate | 估計這個任務須要多少時間,並規劃大體工做步驟 | 三天 | 四天 |
Development | 開發 | 110 | 120 |
Analysis | 需求分析(包括學習新技術) | 40 | 100 |
Design Spec | 生成設計文檔 | 10 | 15 |
Design Review | 設計複審(和同窗審覈設計文檔) | 5 | 10 |
Coding Standard | 代碼規範(爲目前的開發制定合適的規範) | 10 | 15 |
Design | 具體設計 | 10 | 10 |
Coding | 具體編碼 | 150 | 240 |
Test | 測試(自我修改,修改代碼,提交修改) | 30 | 50 |
Reporting | 報告 | 20 | 180 |
Rostmortem & Process Improvement Plan | 過後總結,提出過程改進計劃 | 3 | 5 |
f. 小結感覺.
這個項目有不少功能都和上一個詞頻軟件功能相似,因此咱們首先對比了咱們兩我的的實驗二項目,取比較好的部分進行整合再開始這個項目。新增了四個功且補全了實驗二沒有實現柱狀圖的遺憾。咱們首先在eclipse中實現了柱形圖的功能,並完成了統計每行的每一個單詞的數量和統計該文本文檔的行數,前端頁面用sublime軟件寫的html頁面,採用了css和js佈局。因爲好久不接觸gui等人機交互頁面設計,因此很生疏,這個實驗室一點點從新撿起來的過程。在此次結對過程當中,咱們倆一塊兒合做,尤爲是做業截止的前一天,在機房呆了十個小時,終於將項目大概的樣子有了個形,我相信在從此的學習中咱們都會成爲對方的好搭檔。對於咱們來講,1+1必須是>2的,就算卡bug,也能互相鼓勵。
GitHub地址點擊☞此處