软工作业

这个作业属于哪个课程 https://edu.cnblogs.com/campus/zswxy/computer-science-class4-2018/
这个作业要求在哪里 https://edu.cnblogs.com/campus/zswxy/computer-science-class4-2018/homework/11880
这个作业的目标 <编程进行词频的统计>
学号 <20188515>
一、码云地址
https://gitee.com/unbetter/project-java/tree/master/20188515
二、思路描述
先读取文件的信息,再检查文件中字符数和检查单词总数,接着统计有效行数,最后输出统计内容到指定的输出文件中
三、设计与实现过程
1.检查文件中字符数
`


while((ch=(char)br.read())!=(char)-1)
        {
            if(ch<=127)//保证读取的字符为ASCLL码
            {
                countChar++;
            }
        }       `

2.检查单词总数
`

String[] strs=words.split("[^a-zA-Z0-9]");
            String regexs = "^[a-zA-Z]{4,}.*";
            for(int i=0;i<strs.length;i++)
            {
                if(strs[i].matches(regexs))
                {
                    countWord++;
                }
            } `

3.统计有效行数
`

for (int i=0;i<c.length;i++)
            {
                if (c[i]!='\n' && c[i]!='\r' && c[i]!='\t')
                {
                    countLine++;
                    break;
                }
            }`

4.统计出现频率最高的10个单词的出现次数
`

  for (int i = 0; i < strs.length; i++) {
            if (strs[i].matches(regexs)) {
                if (!map.containsKey(strs[i].toLowerCase())) {            
                    map.put(strs[i].toLowerCase(), 1);
                } else {
                    int num = map.get(strs[i].toLowerCase());
                    map.put(strs[i].toLowerCase(), num + 1);
                }
            }
        }`

5.输出统计内容到指定的输出文件中
`

   StringBuilder str = new StringBuilder();
        str.append("characters: "+countChar+"\n" + "words: "+countWord+"\n" +"lines: "+countLine+"\n"s);
        for(int i = 0;i<(list.size()<10 ? list.size():10);i++){
            str.append(list.get(i).getKey()+": "+list.get(i).getValue()+"\n");
        }`

image
四、心路历程与收获
通过这次作业感到自己有很多的不足之处,所以以后还需努力学习,对技术的用法还掌握还不熟悉。在写作业的时候,感觉非常的难,还是学的不透彻。
五、PSP表格
| PSP2.1 | Personal Software Process Stages | 预估耗时(分钟) | 实际耗时(分钟) |
| ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ | ------------ |
| Planning | 计划 | 20 | 30 |
| Estimate | 估计这个任务需要多少时间 | 1000 | 1050 |
| Development | 开发 | 200 | 200 |
| Analysis | 需求分析 (包括学习新技术) | 210 | 180 |
| Design Spec | 生成设计文档 | 60 | 30 |
| Design Review | 设计复审 | 30 | 10 |
| Coding Standar | 代码规范 (为目前的开发制定合适的规范) | 10 | 10 |
| Design | 具体设计 | 50 | 60 |
| Coding | 具体编码 | 100 | 90 |
| Code Review | 代码复审 | 20 | 60 |
| Test | 测试(自我测试,修改代码,提交修改) | 20 | 40 |
| Reporting | 报告 | 20 | 40 |
| Test Repor | 测试报告 | 20 | 15 |
| Size Measurement | 计算工作量 | 10 | 10 |
| Postmortem & Process Improvement Plan | 事后总结, 并提出过程改进计划 | 30 | 20 |
| 合计 | | 1800 | 1815 |

posted @ 2021-04-02 13:26  LUM哟  阅读(67)  评论(0编辑  收藏  举报