資源簡(jiǎn)介
使用Python語(yǔ)言對(duì)DBLP數(shù)據(jù)集通過sax方式進(jìn)行簡(jiǎn)單處理并存放到csv文件中。處理過程非常簡(jiǎn)單,請(qǐng)根據(jù)需要進(jìn)行下載。
代碼片段和文件信息
#?-*-?coding:utf-8?-*-
‘‘‘
@author:Zhong?Peng
@createDate:2015-11-05
@version:1.0.0
‘‘‘
import?sys
from?xml.sax?import?handler?make_parser
import?pickle
import?os
DBLP_xml_PATH?=?r‘C:\Users\zhongpeng\Desktop\dblp.xml‘
#此處需要完整添加所有“塊”結(jié)構(gòu)的標(biāo)簽,或者需要處理的類型的標(biāo)簽
paperTag?=?(‘inproceedings‘‘proceedings‘
????????‘incollection‘‘phdthesis‘‘mastersthesis‘‘www‘)
class?CoauthorHandler(handler.ContentHandler):
????def?__init__(self):
????????self.title?=?‘‘
????????self.year?=?‘‘
????????self.author?=?‘‘
????????self.count?=?0
????????self.isPaperTag?=?0
????????self.istitleTag?=?0
????????self.isYearTag?=?0
????????self.isAuthorTag?=?0
????????self.authors?=?[]#存儲(chǔ)每個(gè)“塊”中的所有author
????????self.storage?=?{}#用來(lái)存儲(chǔ)生成的數(shù)據(jù),結(jié)構(gòu)為{‘title‘:[year?[author1?author2?...]]}
??????
- 上一篇:python36_d.lib
- 下一篇:excel增刪改查功能的封裝
評(píng)論
共有 條評(píng)論