当前位置: 首页>>代码示例>>Python>>正文


Python SonicScrewdriver.infer_date方法代码示例

本文整理汇总了Python中SonicScrewdriver.infer_date方法的典型用法代码示例。如果您正苦于以下问题:Python SonicScrewdriver.infer_date方法的具体用法?Python SonicScrewdriver.infer_date怎么用?Python SonicScrewdriver.infer_date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SonicScrewdriver的用法示例。


在下文中一共展示了SonicScrewdriver.infer_date方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: int

# 需要导入模块: import SonicScrewdriver [as 别名]
# 或者: from SonicScrewdriver import infer_date [as 别名]
		line = line.rstrip()
		fields = line.split('\t')

		volid = fields[0]
		word = fields[1]
		count = int(fields[2])

		if volid in datedict:
			date = datedict[volid]
		elif volid in rows:
			datetype = table["datetype"][volid]
			firstdate = table["startdate"][volid]
			seconddate = table["enddate"][volid]
			textdate = table["textdate"][volid]
			date = utils.infer_date(datetype, firstdate, seconddate, textdate)
			datedict[volid] = date
		else:
			print(volid + " missing in metadata.")
			date = 0

		if date > 1699 and date < 1924:
			add_counts(wordcounts, date, word, count)
		else:
			undated.add(volid)

with open('/Volumes/TARDIS/work/forandrew/colors.tsv', mode = 'w', encoding = 'utf-8') as f:
	for year, subdictionary in wordcounts.items():
		for word, count in subdictionary.items():
			outline = str(year) + '\t' + word + '\t' + str(count) + '\n'
			f.write(outline)
开发者ID:tedunderwood,项目名称:GenreProject,代码行数:32,代码来源:PostExtractionCollectByYear.py

示例2: enumerate

# 需要导入模块: import SonicScrewdriver [as 别名]
# 或者: from SonicScrewdriver import infer_date [as 别名]
            header = row
            for idx, colhead in enumerate(header):
                columns[colhead] = idx

        else:
            htid = row[columns['htid']]
            genrecounts = int(row[columns['genrecounts']])
            # This is the number of pages *in the genre.*

            title = row[columns['title']]
            author = row[columns['author']]
            datetype = row[columns['datetype']]
            startdate = row[columns['startdate']]
            enddate = row[columns['enddate']]
            imprintdate = row[columns['imprintdate']]
            date = utils.infer_date(datetype, startdate, enddate, imprintdate)
            if date > 1699 and date < 1800:
                centuries['18c'].append((date, author, title, genrecounts, htid))
            elif date < 1900:
                centuries['19c'].append((date, author, title, genrecounts, htid))
            elif date < 1923:
                centuries['20c'].append((date, author, title, genrecounts, htid))

pagecenturies = dict()

for century, voltuples in centuries.items():
    # Each voltuple represent a volume.

    pagecenturies[century] = list()

    # For each list of volumes associated with a century, we construct an associated
开发者ID:tedunderwood,项目名称:HathiGenreTrainingset,代码行数:33,代码来源:randomsample.py


注:本文中的SonicScrewdriver.infer_date方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。