第一次个人编程作业
https://github.com/xxxrt/SensitiveWord
一、PSP表格
| PSP2.1 | Personal Software Process Stages | 预估耗时(分钟) | 实际耗时(分钟) |
|---|---|---|---|
| Planning | 计划 | ||
| · Estimate | · 估计这个任务需要多少时间 | 360 | 480 |
| Development | 开发 | ||
| · Analysis | · 需求分析 (包括学习新技术) | 300 | 360 |
| · Design Spec | · 生成设计文档 | 30 | 30 |
| · Design Review | · 设计复审 | 15 | 15 |
| · Coding Standard | · 代码规范 (为目前的开发制定合适的规范) | 60 | 60 |
| · Design | · 具体设计 | 120 | 240 |
| · Coding | · 具体编码 | 300 | 480 |
| · Code Review | · 代码复审 | 180 | 240 |
| · Test | · 测试(自我测试,修改代码,提交修改) | 120 | 360 |
| Reporting | 报告 | ||
| · Test Repor | · 测试报告 | 20 | 20 |
| · Size Measurement | · 计算工作量 | 10 | 15 |
| · Postmortem & Process Improvement Plan | · 事后总结, 并提出过程改进计划 | 30 | 30 |
| · 合计 | 1325 | 2330 |
二、计算模块接口
(3.1)计算模块接口的设计与实现过程
对于敏感词的查找采用了DFA算法:DFA全称为:Deterministic Finite Automaton,即确定有穷自动机。其特征为:有一个有限状态集合和一些从一个状态通向另一个状态的边,每条边上标记有一个符号,其中一个状态是初态,某些状态是终态。但不同于不确定的有限自动机,DFA中不会有从同一状态出发的两条边标志有相同的符号。DFA算法的核心是建立了以敏感词为基础的许多敏感词树。
版权声明:本文为CSDN博主「我姓徐」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/xb565517830/article/details/117691306
该项目中我从第三方库中引用借鉴了了别人的写的两个类
来源分别是:
https://blog.csdn.net/yexiaomodemo/article/details/106292617
https://blog.csdn.net/weixin_34297300/article/details/94112292
(3.2)计算模块接口部分的性能改进



(3.3)计算模块部分单元测试展示。
public static void main(String[] args) throws IOException {
SensitiveWordFilter filter = new SensitiveWordFilter();
SensitiveWordInit init=new SensitiveWordInit();
init.path=args[0];
filter.setSensitiveWordMap(init.initKeyWord());
File file = new File(args[1]);//Text
int index=0;
int sum=0;
BufferedReader br = new BufferedReader(new FileReader(file));
String s = null;
BufferedWriter out = new BufferedWriter(new FileWriter(args[2]));
while((s = br.readLine())!=null){
index++;
String newString = s.replaceAll("[\pP\p{Punct}]", "");
newString=PinyinUtil.getPinyin(newString,"");
newString=newString.toLowerCase();
newString=newString.replaceAll(" ", "");
Set
int count=set.size();
int i=0;
sum+=set.size();
while(count !=0)
{
List
String newKey=res.get(i);
String str="Line" +index+":<"+SensitiveWordInit.ChineseMap.get(newKey)+ ">";
System.out.println(str);
out.write(str+"\r\n");
count--;
i++;
}
}
System.out.println("Total:"+sum+"\n");
out.write("Total:"+sum);
br.close();;
out.close();
}
(3.4)计算模块部分异常处理说明。
由于水平不够,最后并没有能够将敏感词出现的地方将其展示出来

三、心得
- 对于不同的题目,经常需要我们学习不同的语言和各种工具的应用,java就是为了此次作业去加强学习的(但是远远不够,借鉴了大量第三方资料)
- 我学会了一些在网上寻找答案和一些专业知识的技巧。
- 这次作业说实话并没有完成老师的要求,目前的水平还不够成为一个合格的计算机专业的学生,还需要加强代码能力。
浙公网安备 33010602011771号