資源簡介
使用Python語言對DBLP數據集通過sax方式進行簡單處理并存放到csv文件中。處理過程非常簡單,請根據需要進行下載。
代碼片段和文件信息
#?-*-?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‘
#此處需要完整添加所有“塊”結構的標簽,或者需要處理的類型的標簽
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?=?[]#存儲每個“塊”中的所有author
????????self.storage?=?{}#用來存儲生成的數據,結構為{‘title‘:[year?[author1?author2?...]]}
??????
- 上一篇:python36_d.lib
- 下一篇:excel增刪改查功能的封裝
評論
共有 條評論