软工实践结对第二次作业

作业链接

分工

  • 廖钰萍:编写爬虫代码,更新WordCount代码
  • 苏芳锃:编写博客

PSP表格

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

解题思路与实现

  • 爬虫:利用Python和scrapy框架编写爬虫代码
  • 代码组织与内部实现

  • 关键部分

int Paper::cmp(Word W1,Word W2)
{
    return W1.count > W2.count;
}

void Paper::Vsort()
{
    sort(Title.begin(), Title.end(), cmp);
    sort(Abstract.begin(), Abstract.end(), cmp);
}

int Paper::getgeneral_wordCount(int weight)
{
    for (vector<Word>::iterator it = Title.begin();it != Title.end();it++)
    {
        general_wordCount = general_wordCount + it->count * weight;
    }

    for (vector<Word>::iterator it = Abstract.begin();it != Abstract.end();it++)
    {
        general_wordCount = general_wordCount + it->count;
    }
}

附加题设计与展示

  • 从网站爬取论文标题,发表日期和论文pdf链接,对论文按日期进行分类,生成表格,可通过链接转到pdf页面
  • 通过爬取的日期计算每个月份出现的频度,得到论文发表时间的分布图

关键代码解释

def parse_detail (response):
    item = CvprItem()
    item['Title'] = response.xpath('//div[@id="content"]//dd/div[@id="papertitle"]/text()').extract()
    item['Abstract'] = response.xpath('//div[@id="content"]//dd/div[@id="abstract"]/text()').extract()

    yield item
   def start_requests(self):
        url='http://openaccess.thecvf.com/CVPR2018.py'
        yield Request(url,headers=self.headers)

    def parse(self,response):
        links= response.xpath('//div[@id="content"]//dt//a/@href').extract()
        for link in links:
            link = 'http://openaccess.thecvf.com/'+link
            yield Request(link,headers=self.headers,callback=parse_detail)

遇到的问题

  • 最初的wordCount程序数据结构设计不合理,导致后来修改花了许多时间

猜你喜欢

转载自www.cnblogs.com/liao-yp/p/9781177.html