zoukankan      html  css  js  c++  java
  • 第一次个人编程作业

    一、github链接

    [https://github.com/berylZ1008/031802140]

    二、PSP表格

    PSP2.1 Personal Software Process Stages 预估耗时(分钟) 实际耗时(分钟)
    Planning 计划 30
    · Estimate · 估计这个任务需要多少时间 30
    Development 开发 120
    · Analysis · 需求分析 (包括学习新技术) 1000
    · Design Spec · 生成设计文档 30
    · Design Review · 设计复审 40
    · Coding Standard · 代码规范 (为目前的开发制定合适的规范) 60
    · Design · 具体设计 240
    · Coding · 具体编码 360
    · Code Review · 代码复审 60
    · Test · 测试(自我测试,修改代码,提交修改) 120
    Reporting 报告 40
    · Test Repor · 测试报告 30
    · Size Measurement · 计算工作量 10
    · Postmortem & Process Improvement Plan · 事后总结, 并提出过程改进计划 60
    · 合计 2230

    三、计算模块接口的设计与实现过程

    1.整体流程图

    2.主要函数及算法介绍

    (1)jieba分词


    这里主要用了github上其他作者上传的jieba词库

    (2)重复词删除

    首先,对字符串进行排序,使相同字符串位置相邻,运用sort函数,如sort(vectora.begin,a.end())
    然后,运用vector容器中的unique函数,将重复词全部放到vector容器末尾,并返回当前重复词第一个位置,如position=unique(a.begin(),a.end())
    最后,运用vector容器中的erase函数,将重复词全部删除,如erase(unique(a.begin(),a.end()),a.end())

    (3)Jaccard相似系数计算

    两个集合A和B交集元素的个数在A、B并集中所占的比例,称为这两个集合的杰卡德系数,用符号 J(A,B) 表示。杰卡德相似系数是衡量两个集合相似度的一种指标(余弦距离也可以用来衡量两个集合的相似度)。杰卡德系数越大,相似度越高。

    函数实现:

    四、计算模块部分单元测试展示

    1.测试代码

    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <iomanip>
    #include <cstring>
    #include<string>
    #include<cmath>
    #include<map>
    #include<vector>
    #include<queue>
    #include<set>
    using namespace std;
    int main(int argc, const char * argv[]) {
    string files[]={
    "orig_0.8_add.txt",
    "orig_0.8_del.txt",
    "orig_0.8_dis_1.txt",
    "orig_0.8_dis_3.txt",
    "orig_0.8_dis_7.txt",
    "orig_0.8_dis_10.txt",
    "orig_0.8_dis_15.txt",
    "orig_0.8_mix.txt",
    "orig_0.8_rep.txt"
    };
    string path;
    string path1="main.exe sim_0.8/orig.txt sim_0.8/";
    string path2=" result.txt";
    for(int i=0;i<9;i++){
    cout<<"文件orig.txt与文件" <<files[i]<< "的相似度:"<<endl;
    path=path1+files[i]+path2;
    system(path.c_str());
    cout<<endl;
    }
    return 0;
    }

    2.样本测试

    五、计算模块部分异常处理说明

    异常情况:输出相似度和正确值相差很多
    改进:加入重复词组去除步骤,即可解决

    六、PSP表格

    PSP2.1 Personal Software Process Stages 预估耗时(分钟) 实际耗时(分钟)
    Planning 计划 30 50
    · Estimate · 估计这个任务需要多少时间 30 30
    Development 开发 120 200
    · Analysis · 需求分析 (包括学习新技术) 1000 1500
    · Design Spec · 生成设计文档 30 60
    · Design Review · 设计复审 40 50
    · Coding Standard · 代码规范 (为目前的开发制定合适的规范) 60 60
    · Design · 具体设计 240 250
    · Coding · 具体编码 360 300
    · Code Review · 代码复审 60 60
    · Test · 测试(自我测试,修改代码,提交修改) 120 200
    Reporting 报告 40 40
    · Test Repor · 测试报告 30 30
    · Size Measurement · 计算工作量 10 10
    · Postmortem & Process Improvement Plan · 事后总结, 并提出过程改进计划 60 90
    · 合计 2230 2930

    七、总结

    这一次作业主要学习到了:jieba词库的分词使用、vector容器中的一些函数的使用、jaccard相似度系数的想法,这一次作业对我来说还是很有难度的,遇到了很多大大小小的问题,以此也能看出来我需要学习的内容,还有很多。并且,虽然这次代码长度也不算很长,但是相比用Python的同学,感觉还是麻烦不少,因此,之后可能需要学习Python的语言方法。

  • 相关阅读:
    5-python基础—获取某个目录下的文件列表(适用于任何系统)
    Automated, Self-Service Provisioning of VMs Using HyperForm (Part 1) (使用HyperForm自动配置虚拟机(第1部分)
    CloudStack Support in Apache libcloud(Apache libcloud中对CloudStack支持)
    Deploying MicroProfile-Based Java Apps to Bluemix(将基于MicroProfile的Java应用程序部署到Bluemix)
    Adding Persistent Storage to Red Hat CDK Kit 3.0 (在Red Hat CDK Kit 3.0添加永久性存储)
    Carve Your Laptop Into VMs Using Vagrant(使用Vagran把您笔记本电脑刻录成虚拟机)
    使用Python生成一张用于登陆验证的字符图片
    Jupyter notebook的安装方法
    Ubuntu16.04使用Anaconda5搭建TensorFlow使用环境 图文详细教程
    不同时区的换算
  • 原文地址:https://www.cnblogs.com/beryl-z/p/13688032.html
Copyright © 2011-2022 走看看