个人项目
这个作业属于哪个课程 | <软件工程2024 (广东工业大学)> |
---|---|
这个作业要求在哪里 | <个人项目> |
这个作业的目标 | <学会如何制作一个个人项目> |
一、PSP表格
PSP2.1 | Personal Software Process Stages | 预估时间(分钟) | 实际时间(分钟) |
---|---|---|---|
Planning | 计划 | ||
- Estimate | - 估计这个任务需要多少时间 | 10 | 20 |
Development | 开发 | ||
- Analysis | - 需要多少时间 | 60 | 180 |
- Design Spec | - 生成设计文档 | 60 | 60 |
-Design Review | - 设计复审 | 30 | 45 |
- Coding Standard | - 代码规范 (为目前的开发制定合适的规范) | 180 | 200 |
- Design | - 具体设计 | 120 | 120 |
- Coding | - 具体编码 | 120 | 120 |
- Code Review | - 代码复审 | 30 | 30 |
- Test | - 测试(自我测试,修改代码,提交修改) | 45 | 60 |
Reposrting | 报告 | ||
- Test Repor | - 测试报告 | 60 | 60 |
- Size Measurement | - 计算工作量 | 60 | 60 |
Postmortem & Process Improvement Plan | 事后总结。并提出过程改进计划 | 60 | 60 |
Total | 总计 | 835 | 1015 |
二、计算模块接口的设计与实现过程
1、流程
- 读取txt文件内容转化为String类型字符串
- 取出所有关键词
- 计算出simhash值
- 计算出海明距离求出相似度
- 将结果写入指定文件
2、类
- main:main方法所在的类
- hamming:计算海明距离
- simhash:计算simhash的值
- txtio:txt文档的读入与写出
- ShortStringException:处理文本内容过短
3、关键算法
三、计算模块接口部分的性能改进
- Jprofile截图
- 性能分析图
- 消耗最大的函数
对于如何改进让程序更优暂时没有思路
- 性能分析图
四、计算模块部分单元测试展示
1、部分代码
···
public class maintest {
@Test
public void origAndAllTest(){
String[] str = new String[6];
str[0] = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig.txt");
str[1] = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig_0.8_add.txt");
str[2] = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig_0.8_del.txt");
str[3] = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig_0.8_dis_1.txt");
str[4] = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig_0.8_dis_10.txt");
str[5] = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig_0.8_dis_15.txt");
String ansFileName = "C:/Users/16921/Desktop/testtxt/result.txt";
for(int i = 0; i <= 5; i++){
double ans = hammingutil.getSimilarity(simhash.getSimHash(str[0]), simhash.getSimHash(str[i]));
txtio.writeTxt(ans, ansFileName);
}
}
@Test
public void origAndOrigTest(){
String str0 = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig.txt");
String str1 = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig.txt");
String ansFileName = "C:/Users/16921/Desktop/testtxt/result.txt";
double ans = hammingutil.getSimilarity(simhash.getSimHash(str0), simhash.getSimHash(str1));
txtio.writeTxt(ans, ansFileName);
}
@Test
public void origAndAddTest(){
String str0 = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig.txt");
String str1 = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig_0.8_add.txt");
String ansFileName = "C:/Users/16921/Desktop/testtxt/orig_0.8_add.txt";
double ans = hammingutil.getSimilarity(simhash.getSimHash(str0), simhash.getSimHash(str1));
txtio.writeTxt(ans, ansFileName);
}
@Test
public void origAndDelTest(){
String str0 = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig.txt");
String str1 = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig_0.8_del.txt");
String ansFileName = "C:/Users/16921/Desktop/testtxt/result.txt";
double ans = hammingutil.getSimilarity(simhash.getSimHash(str0), simhash.getSimHash(str1));
txtio.writeTxt(ans, ansFileName);
}
@Test
public void origAndDisTest(){
String str0 = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig.txt");
String str1 = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig_0.8_dis_1.txt");
String ansFileName = "C:/Users/16921/Desktop/testtxt/result.txt";
double ans = hammingutil.getSimilarity(simhash.getSimHash(str0), simhash.getSimHash(str1));
txtio.writeTxt(ans, ansFileName);
}
@Test
public void origAndDis10Test(){
String str0 = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig.txt");
String str1 = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig_0.8_dis_10.txt");
String ansFileName = "C:/Users/16921/Desktop/testtxt/result.txt";
double ans = hammingutil.getSimilarity(simhash.getSimHash(str0), simhash.getSimHash(str1));
txtio.writeTxt(ans, ansFileName);
}
@Test
public void origAndAddDia15Test(){
String str0 = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig.txt");
String str1 = txtio.readTxt("C:/Users/16921/Desktop/testtxt/orig_0.8_dis_15.txt");
String ansFileName = "C:/Users/16921/Desktop/testtxt/result.txt";
double ans = hammingutil.getSimilarity(simhash.getSimHash(str0), simhash.getSimHash(str1));
txtio.writeTxt(ans, ansFileName);
}
}
···
2、单元测试得到的测试覆盖率截图
五、计算模块部分异常处理说明
- 若输入语句过短 用ShortStringException类进行报错