Winter operations (2/2)
This work belongs courses | 2020 W Spring classes |
---|---|
Where the job requires | Work requirements |
The target job | Construction of the law, PSP table, Github use, disease statistics program ... |
Text of the job | .... |
Other references | ... |
A, Github repository address
Warehouse addresses of
the main warehouse address
Two, PSP form
PSP2.1 | Personal Software Process Stages | Estimated time consuming (minutes) | The actual time-consuming (minutes) |
---|---|---|---|
Planning | plan | 30 | 40 |
Estimate | Estimate how much time this task requires | 5 | 10 |
Development | Develop | 1200 | 800 |
Analysis | Needs analysis (including learning new technologies) | 180 | 200 |
Design Spec | Generate design documents | 60 | 30 |
Design Review | Design Review | 30 | 30 |
Coding Standard | Code specifications (development of appropriate norms for the current development) | 60 | 50 |
Design | Specific design | 120 | 130 |
Coding | Specific coding | 240 | 360 |
Code Review | Code Review | 30 | 60 |
Test | Test (self-test, modify the code, submit modifications) | 120 | 60 |
Reporting | report | 30 | 20 |
Test Report | testing report | 30 | 20 |
Size Measurement | Computing workload | 10 | 10 |
Postmortem & Process Improvement Plan | Later summarized, and process improvement plan | 20 | 30 |
total | 2165 | 1850 |
Third, the problem-solving ideas description
- The first is to identify the command-line parameters. CSDN study on the related knowledge: the Java learning command-line arguments , pass parameters from the command line .
- Second reading log. Learned to read the specified folder within the knowledge of all the files: basic knowledge of JAVA File class .
- Once again, code analysis log contents. Because some lazy, so there is no JAVA to learn regular expressions, writing a lot of code. Then think about it, so instead of wasting time nor the knowledge learned, really.
- Finally, generate txt document. It is to first get the results in the output to a file.
Fourth, the design and implementation process
Because of homework time, and time is tight, so do not bother to design several classes, several functions. The result, put the code tucked it away in the main function, but fortunately not too much the amount of code. Here are some diagram:
V. Code Description
Processing command line arguments
//得到存放各类型命令行参数的ArrayList具体值
for (int i=0;i<args.length;i++)
{
if (args[i].equals("-log")) {
logList=args[++i];
logList=logList.replace('/', '\');
}
else if (args[i].equals("-out")) {
outList=args[++i];
outList=outList.replace('/', '\');
}
else if (args[i].equals("-date")) {
dateList=args[++i];
}
else if (args[i].equals("-type")) {
for (int j=i+1;j<args.length;j++) {
if (!args[j].equals("-out")&&!args[j].equals("-date")&&
!args[j].equals("-log")&&!args[j].equals("-province"))
{
typeList.add(args[j]);
}
else
{
i=j-1;
break;
}
}
}
else if (args[i].equals("-province")) {
...
}
}//获取ArrayList循环结束处理日志文件
//处理日志中的数据
for(String s:arr)
{
if (s.compareTo(dateList+".log")>0) continue;
try
{
File afile = new File(logList+s);
Scanner sc = new Scanner(afile);
while (sc.hasNext())
{
String first=sc.next();
if (first.equals("//"))
sc.nextLine();
else
{
int index=0;
for (int i=0;i<32;i++)
{
if (first.equals(province[i]))
{
index=i;
break;
}
}
number0=1;
numberindex=1;
String second=sc.next();
if (second.equals("新增"))
{
String third=sc.next();
String four=sc.next();
four=four.replace("人", "");
int member=Integer.parseInt(four);
if (third.equals("感染患者")) {
number[0][0]+=member;
number[index][0]+=member;
}
else {
number0+=member;
numberindex+=member;
}
}
else if (second.equals("感染患者"))
...
}
}
sc.close();
}
}将从日志文件得到的数据转化为所需数据
//得到输出结果
ArrayListresult=new ArrayList ();
if (provinceInt.size()==0)
...
else
{
for (int i=0;i<32;i++)
number i=0;
for (int i=0;i<provinceInt.size();i++)
number provinceInt.get(i)=1;
if(typeInt.size()==0)
{
for (int i=0;i<32;i++)
{
if (number i==0)
{
continue;
}
String mid=province[i]+" 感染患者"+""+number[i][0]+""+"人"+" 疑似患者"+""+number i+""+"人"
+" 治愈"+""+number i+""+"人"+" 死亡"+""+number i+""+"人\n";
result.add(mid);
}
}
else
...
}
}
六、单元测试截图和描述
由于我写代码之前没有仔细看单元测试的内容,所以把所有的代码都写到了main函数里,这就很难测试每一个代码片段了。所以写完以后,我只能修改了一下自己的代码,这样起码main函数可以得到测试结果,。
测试代码
import static org.junit.Assert.*;
import org.junit.Test;
public class InfectStatisticTest
{
@Test
public void testMain()
{
String[] test1=("list -log D:/log/ -out D:/ListOut1.txt -date 2020-01-22").split(" ");
//for(int i=0;i<test1.length;i++)
//System.out.println(test1[i]);
InfectStatistic.main(test1);
assertEquals("全国 感染患者15人 疑似患者22人 治愈2人 死亡1人\n", InfectStatistic.result.get(0));
assertEquals("福建 感染患者5人 疑似患者7人 治愈0人 死亡0人\n", InfectStatistic.result.get(1));
assertEquals("湖北 感染患者10人 疑似患者15人 治愈2人 死亡1人\n", InfectStatistic.result.get(2));
// String[] test2=("list -log D:/log/ -out D:/ListOut2.txt -date 2020-01-22 -province 福建 河北").split(" ");
// InfectStatistic.main(test2);
// assertEquals("福建 感染患者5人 疑似患者7人 治愈0人 死亡0人\n", InfectStatistic.result.get(0));
// assertEquals("河北 感染患者0人 疑似患者0人 治愈0人 死亡0人\n", InfectStatistic.result.get(1));
// String[] test3=("list -log D:/log/ -out D:/ListOut7.txt -date 2020-01-23 -type cure dead ip -province 全国 浙江 福建").split(" ");
// InfectStatistic.main(test3);
// assertEquals("全国 治愈4人 死亡3人 感染患者42人\n", InfectStatistic.result.get(0));
// assertEquals("福建 治愈1人 死亡0人 感染患者9人\n", InfectStatistic.result.get(1));
// assertEquals("浙江 治愈0人 死亡0人 感染患者0人\n", InfectStatistic.result.get(2));
}
}
三个测试结果截图
看起来一样,。
七、单元测试覆盖率优化和性能测试,性能优化截图和描述
单元测试覆盖率
怎么说呢,因为我是直接测试main函数,所以命令行要么带province要么不带province,要么带type要么不带type,就不能一次测试把所有情况都覆盖,难搞。
八、代码规范的链接
https://github.com/massizhi/InfectStatistic-main/blob/master/221701141/codestyle.md
九、心路历程与收获
艰辛!做这个项目,发现自己不会的太多了。原来以为在实验室做了几个项目,自己的工程能力应该不错了,结果用到的都是自己的知识盲区。比如实验室用SVN,这里用Git,虽然都是代码管理工具,学起来也十分吃力。自己比较懒,做作业的时候距离截止时间也不多了,所以做的比较匆忙。当然了,不会的东西多,学到的就多,争取对这个项目经历能做一个详细的总结吧。收获也是挺多的,比如软件工程的初步了解、Github的使用、对自己第一次作业定的目标的资料收集、Java命令行参数的获取、Java输入输出等、构建之法、单元测试等。
十、第一次作业中技术路线图相关的5个仓库
- 谷歌全新开源人工智能系统TensorFlow官方文档: TensorFlow官方文档
机器学习作为人工智能的一种类型,可以让软件根据大量的数据来对未来的情况进行阐述或预判。「TensorFlow」是 Google 多年以来内部的机器学习系统。 - 人工智能实战微信小程序demo:小程序demo
里面为很多微信小程序的demo,AI学到一定程度就可以参考demo编写自己的程序了。 - AI-Practice-Tensorflow-Notes:Tensorflow笔记
里面为人工智能实践:Tensorflow笔记 。 机器学习相关教程:https://github.com/MorvanZhou/tutorials。
Python basic
foundation
multithread threading
multiprocessing multiprocessing
simple window tkinter
machine learning
fun machine learning
reinforcement learning (Reinforcement Learning)
Evolutionary Algorithms (Evolutionary Algorithm) such as genetic algorithms
Tensorflow (neural networks)
PyTorch (neural networks)
Theano (neural networks)
Keras (fast neural network)
Scikit-learn (machine learning)
machine learning practical
data processing
Numpy & Pandas (data processing)
Matplotlib (drawing)
reptiles
other
Git (version control)
Linux simple teachingAndrew Ng teacher machine learning courses personal notes : https://github.com/fengdu78/Coursera-ML-AndrewNg-Notes .
This course provides a broad introduction to machine learning, data mining, statistical pattern recognition programs. Topics include:
1, supervised learning (parametric / nonparametric algorithms, support vector machine, kernel function, neural networks).
2, unsupervised learning (clustering, dimension reduction, recommendation systems, in-depth study recommended).
3, best practices in machine learning (deviation / variance theory; in machine learning and artificial intelligence innovation process).