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的语言方法。

  • 相关阅读:
    LVS基于DR模式负载均衡的配置
    Linux源码安装mysql 5.6.12 (cmake编译)
    HOSt ip is not allowed to connect to this MySql server
    zoj 3229 Shoot the Bullet(无源汇上下界最大流)
    hdu 3987 Harry Potter and the Forbidden Forest 求割边最少的最小割
    poj 2391 Ombrophobic Bovines(最大流+floyd+二分)
    URAL 1430 Crime and Punishment
    hdu 2048 神、上帝以及老天爷(错排)
    hdu 3367 Pseudoforest(最大生成树)
    FOJ 1683 纪念SlingShot(矩阵快速幂)
  • 原文地址:https://www.cnblogs.com/beryl-z/p/13688032.html
Copyright © 2011-2022 走看看