结对同窗的博客连接
本做业博客的连接
Github项目地址
附加功能代码
代码规范连接html
庄卉:爬虫、词频权重计算+自定义统计输出、附加功能、博客撰写
胡绪佩:词组词频统计功能+字符及有效行数目、单元测试、性能分析、博客撰写java
PSP2.1 | Personal Software Process Stages | 预估耗时(分钟) | 实际耗时(分钟) |
---|---|---|---|
Planning | 计划 | 30 | 30 |
· Estimate | · 估计这个任务须要多少时间 | 30 | 30 |
Development | 开发 | 1770 | 1740 |
· Analysis | · 需求分析 (包括学习新技术) | 120 | 150 |
· Design Spec | · 生成设计文档 | 30 | 30 |
· Design Review | · 设计复审 | 30 | 30 |
· Coding Standard | · 代码规范 (为目前的开发制定合适的规范) | 30 | 60 |
· Design | · 具体设计 | 120 | 90 |
· Coding | · 具体编码 | 900 | 720 |
· Code Review | · 代码复审 | 180 | 180 |
· Test | · 测试(自我测试,修改代码,提交修改) | 360 | 480 |
Reporting | 报告 | 120 | 120 |
· Test Repor | · 测试报告 | 60 | 30 |
· Size Measurement | · 计算工做量 | 30 | 20 |
· Postmortem & Process Improvement Plan | · 过后总结, 并提出过程改进计划 | 30 | 70 |
合计 | 1920 | 1890 |
f = open("result.txt", 'a', encoding='utf-8') html1 = urllib.request.urlopen("http://openaccess.thecvf.com/CVPR2018.py").read() bf1 = BeautifulSoup(html1) texts1 = bf1.select('.ptitle') a_bf = BeautifulSoup(str(texts1)) a = a_bf.find_all('a') urls = [] for each in a: urls.append("http://openaccess.thecvf.com/" + each.get('href')) for i in range(len(urls)): f.write(str(i)) f.write("\n") html2 = urllib.request.urlopen(urls[i]).read() bf = BeautifulSoup(html2) texts2 = bf.find_all('div', id='papertitle') f.write("Title: " + texts2[0].text.lstrip('\n') + "\n") texts3 = bf.find_all('div', id='abstract') f.write("Abstract: " + texts3[0].text.lstrip('\n') + "\n\n\n")
031602114&031602444 |- src |- WordCount.sln |- WordCount |- CharCount.cpp |- CharCount.h |- LineCount.cpp |- LineCount.h |- WeightTypeNE.cpp |- WeightTypeNE.h |- SortTopN.cpp |- SortTopN.h |- Word_Group_Cnt.cpp |- Word_Group_Cnt.h |- WordCount.cpp |- WordCount.h |- pch.cpp |- pch.h |- main.cpp |- WordCount.vcxproj |- cvpr |- Crawler.py |- result.txt
单词权重计算python
根据我的项目判断有效单词的算法进行改进,讲按字符串读取改为按行读取,判断该行是title仍是absract,经过存储分割符的位置进行切割读取有效词并计算权重。
词组切割
根据用户输入决定词组切割长度,切割过程当中借用队列辅助存储每个合法单词的长度,遇到不合法单词则能够将队列que清空便可,不然就根据词组单词组成长度以及队列存储的单词长度进行进队出队操做,达到更新string后进行截取(使用substr库函数)获得新的词组存入map容器。c++
爬虫能力有限orz,只从网站综合爬取论文的除题目、摘要外其余信息。爬虫语言使用python。额外爬取信息有:做者、PDF连接、SUPPPDF连接、ARXIV连接。
txt文件如图:
git
想象力有限orz,咱们分析了论文列表中各位做者之间的关系,论文A的第一做者可能同时是论文B的第二做者,不一样论文多位做者之间可能存在着联系,并将关系可视化。
咱们从附加功能1的txt文件提取了发表在2018cvpr顶会上的全部论文的第一做者和第二做者,使用分析工具NodeXL作出了关系图谱。
图谱全貌以下:
逐渐剔除较少联系点的图谱以下:
github
(没有第二做者时在第二做者处填empty)算法
能够看出发表论文最多的做者是Ming-Hsuan Yang,在2018cvpr上一共发表了17篇论文。flask
具体解释: 使用辅助队列存储每一个合法单词的长度,经过入队和出队操做更新string进行截取不断得到新的词组;函数详情在如下.h文件中均有描述;app
/*统计指定长度的合法单词量造成的词组词频*/ void Word_Group_Cnt(int word_Group_Len, string str, map <string, int > &group_Map,int ttl_Abs) { string word_Now = ""; string word_Group = ""; int lenth = str.length(); queue <int> que; for (int i = 0; i < lenth; i++) { if (Is_Num(str[i]) || Is_Engch(str[i]) && i != lenth - 1) //字符是字母或数字就将其链接到word_Now { word_Now += str[i]; continue; } else if (Is_Num(str[i]) || Is_Engch(str[i]) && i == lenth - 1) //字符是字母或数字且为字段末位链接后就须要对末尾的单词判断是否为合法单词,不然会跳出循环漏掉末尾一个单词; { word_Now += str[i]; word_Now = Is_Word(word_Now); int word_Len = word_Now.length(); if (word_Len >= 4) { word_Group += word_Now; if (que.size() == word_Group_Len - 1) { group_Map[word_Group] += ttl_Abs; } else if (que.size() > word_Group_Len - 1) { word_Group = word_Group.substr(que.front()); group_Map[word_Group] += ttl_Abs; } } else if (word_Len >= 0 && word_Len < 4) { continue; } } else { word_Now = Is_Word(word_Now); int word_Len = word_Now.length(); if (word_Len >= 4) { word_Group += word_Now; if (que.size() < word_Group_Len - 1) //队列大小比所需合法单词数word_Group_Len-1小状况 { word_Group += str[i]; word_Len += 1; while (!Is_Num(str[i + 1]) && !Is_Engch(str[i + 1]) && i + 1 < lenth) { word_Group += str[i + 1]; word_Len += 1; i += 1; } que.push(word_Len); word_Now = ""; } else if (que.size() == word_Group_Len - 1) //队列大小=所需合法单词数word_Group_Len-1状况 { group_Map[word_Group] += ttl_Abs; word_Group += str[i]; word_Len += 1; while (!Is_Num(str[i + 1]) && !Is_Engch(str[i + 1]) && i + 1 < lenth) { word_Group += str[i + 1]; word_Len += 1; i += 1; } que.push(word_Len); word_Now = ""; } else if (que.size() > word_Group_Len - 1) //队列大小等于词组所需合法单词数量,则对队列进行进队和出队操做更新string并进行截取 { word_Group = word_Group.substr(que.front()); group_Map[word_Group] += ttl_Abs; que.pop(); word_Group += str[i]; word_Len += 1; while (!Is_Num(str[i + 1]) && !Is_Engch(str[i + 1]) && i + 1 < lenth) { word_Group += str[i + 1]; word_Len += 1; i += 1; } que.push(word_Len); word_Now = ""; } } else if (word_Len > 0 && word_Len < 4) //遇到不合法单词且不是分隔符或空串的,则返回为no,将队列清空 { while (que.empty() != 1) { que.pop(); } word_Now = ""; word_Group = ""; } else if (word_Len == 0) { continue; } //是否要判断在输入到函数中 } } }
测试的函数及其测试数据构造思路:框架
对于其余一些函数,由于在计算行数、计算单词数、计算字符数、词组切割统计以及词频排序中都有调用,而这些函数测试均正确,所以那些简易的函数的没有作出测试,经过复杂函数的正确测试间接反应其正确性。
部分代码展现:
namespace IsWord //判断是不是单词 { TEST_CLASS(UnitTest1) { public: TEST_METHOD(TestMethod1) { string word = "123ajlk"; word = Is_Word(word); Assert::IsTrue(word == "no"); } TEST_METHOD(TestMethod2) { string word = "Ajlk"; word = Is_Word(word); Assert::IsTrue(word == "ajlk"); } TEST_METHOD(TestMethod3) { string word = "Ajl"; word = Is_Word(word); Assert::IsTrue(word == "no"); } TEST_METHOD(TestMethod4) { string word = "Ajlk123"; word = Is_Word(word); Assert::IsTrue(word == "ajlk123"); } TEST_METHOD(TestMethod5) { string word = "jl12k23"; word = Is_Word(word); Assert::IsTrue(word == "no"); } }; } namespace Word_Group_Count //词组切割统计 { TEST_CLASS(UnitTest1) { public: TEST_METHOD(TestMethod1) { map<string, int> m; Word_Group_Cnt(3, "aaaa bbbb cccc cccc bbbb cccc aaaa dddd cccc bbbb aaaa bbbb cccc dddd", m, 10); Assert::IsTrue(m["aaaa bbbb cccc"] == 20 && m["bbbb cccc cccc"] == 10); } TEST_METHOD(TestMethod2) { map<string, int> m; Word_Group_Cnt(4, "aaaa bbbb cccc dddd bbbb cccc aaaa dddd cccc bbbb aaaa bbbb cccc dddd", m, 10); Assert::IsTrue(m["aaaa bbbb cccc dddd"] == 20 && m["bbbb cccc dddd bbbb"] == 10); } TEST_METHOD(TestMethod3) { map<string, int> m; Word_Group_Cnt(2, "aaaa bbbb cccc cccc bbbb cccc aaaa dddd cccc bbbb aaaa bbbb cccc dddd", m, 10); Assert::IsTrue(m["bbbb cccc"] == 30 && m["aaaa bbbb"] == 20); } TEST_METHOD(TestMethod4) { map<string, int> m; Word_Group_Cnt(5, "aaaa (bbbb) cccc cccc bbbb cccc aaaa dddd cccc bbbb aaaa bbbb cccc dddd", m, 10); Assert::IsTrue(m["aaaa (bbbb) cccc cccc bbbb"] == 10 && m["bbbb aaaa bbbb cccc dddd"] == 10); } TEST_METHOD(TestMethod5) { map<string, int> m; Word_Group_Cnt(6, "aaaa (bbbb)-cccc cccc bbbb cccc aaaa dddd cccc bbbb aaaa bbbb cccc dddd", m, 10); Assert::IsTrue(m["aaaa (bbbb)-cccc cccc bbbb cccc"] == 10 && m["aaaa dddd cccc bbbb aaaa bbbb"] == 10); } }; }
代码覆盖率:
(两人提交记录)
① 佩佩
问题描述:
作过哪些尝试:
②沸沸
有何收获:
爬虫能力提高,搜索能力提高
胡绪佩
佩佩,有太多值得我学习的地方了……好比遇到bug不放弃坚持持续打码n小时解决,好比遇到问题钻研求知的精神,好比知难而进的性格,好比在我睡觉的时候把博客发了……好队友!!!
基本上没有,除了让我不要偷偷背着他打代码hhhhhhh
庄卉
沸沸,有太多值得我学习的地方了+1......好比看到项目便知道体谅队友把难点(附加功能)揽下力肝(卉:表示并无完成得很好),好比写代码速度老是莫名其妙超快的不知道有何秘诀!好比善于和队友沟通交流的团队精神,解决未知困难的能力plusplus,完美解决了本次做业第一第二做者图谱的这个难点,好比温柔美丽的气质......棒队友!!!
基本上没有,再有机会紧抱大腿我定牢牢不放xixixixixi
第N周 | 新增代码(行) | 累计代码(行) | 本周学习耗时(小时) | 累计学习耗时(小时) | 重要成长 |
---|---|---|---|---|---|
1 | 666 | 666 | 15 | 15 | 复习c++,学习单元测试和代码覆盖率,学习git |
2 | 97 | 763 | 4 | 19 | 没什么成长,就是在优化代码 |
3 | 0 | 0 | 10 | 29 | 阅读《构建之法》第三章和第八章,学习使用Axure RP8,了解原型设计的方法 |
4 | 197 | 960 | 20 | 49 | 进一步学习爬虫(了解beautifulsoup使用、学会使用正则),学习使用git进行团队协做,学习使用NodeXL,了解flask |