本文整理汇总了Python中SonicScrewdriver.date_row方法的典型用法代码示例。如果您正苦于以下问题:Python SonicScrewdriver.date_row方法的具体用法?Python SonicScrewdriver.date_row怎么用?Python SonicScrewdriver.date_row使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SonicScrewdriver
的用法示例。
在下文中一共展示了SonicScrewdriver.date_row方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dict
# 需要导入模块: import SonicScrewdriver [as 别名]
# 或者: from SonicScrewdriver import date_row [as 别名]
selecteddates[htid] = date
selected.append(htid)
bydate = dict()
authors = dict()
titles = dict()
datesbyhtid = dict()
with open('/Users/tunder/work/genre/metadata/poemeta.csv', encoding = 'utf-8') as f:
reader = csv.DictReader(f)
for row in reader:
htid = row['htid']
authors[htid] = row['author']
titles[htid] = row['title']
date = utils.date_row(row)
datesbyhtid[htid] = date
if htid in selected:
continue
if date in bydate:
bydate[date].append(htid)
else:
bydate[date] = [htid]
controlset = set()
skip = int(input('Skip how many? '))
for theid in selected[skip:]:
date = selecteddates[theid]
print(theid)
print(date)
示例2: input
# 需要导入模块: import SonicScrewdriver [as 别名]
# 或者: from SonicScrewdriver import date_row [as 别名]
import csv, os
from collections import Counter
import SonicScrewdriver as utils
tagas = input("Tag volumes in this session as? ")
metadata = dict()
authordict = dict()
all_docids = set()
metasource = '/Volumes/TARDIS/work/metadata/MergedMonographs.tsv'
with open(metasource, encoding = 'utf-8') as f:
reader = csv.DictReader(f, delimiter = '\t')
for row in reader:
docid = row['HTid']
row['date'] = utils.date_row(row)
metadata[docid] = row
authorstring = row['author']
authorstring = authorstring.replace(',', ' ')
authorstring = authorstring.replace('.', ' ')
authorwords = authorstring.lower().split()
for word in authorwords:
if word not in authordict:
authordict[word] = set()
authordict[word].add(docid)
all_docids.add(docid)
metaout = '/Users/tunder/Dropbox/fiction/meta/genremeta.csv'
with open(metaout, encoding = 'utf-8') as f:
示例3: and
# 需要导入模块: import SonicScrewdriver [as 别名]
# 或者: from SonicScrewdriver import date_row [as 别名]
if pgenre != 'bio' and not likely and ("Biography" in genres or "Autobiography" in genres):
suspicious = True
if pgenre != 'bio' and not likely and ("Biography" in subjects or "Autobiography" in subjects):
suspicious = True
elif pgenre != 'bio' and not likely and ("Description and travel" in genres or "Description and travel" in subjects):
suspicious = True
elif english < 0.45:
suspicious = True
if suspicious:
row['metadatasuspicious'] = True
else:
row['metadatasuspicious'] = ''
row['inferreddate'] = utils.date_row(row)
row['rawprobability'] = row.pop('probability')
row['englishtop1000pct'] = row.pop('englishpct')
rows[pgenre].append(row)
# now we have all the bio, dra, fic, and poe
# write them to file
write_genres(rows, firstfile)
firstfile = False
示例4: open
# 需要导入模块: import SonicScrewdriver [as 别名]
# 或者: from SonicScrewdriver import date_row [as 别名]
newfic = []
oldfic = []
with open(inpath, encoding = 'utf-8') as f:
reader = csv.DictReader(f, delimiter = '\t')
fieldnames = reader.fieldnames
for row in reader:
genre = row['sampledas']
if genre != 'bio':
continue
# right now we're running on biography
authdate = row['authordate']
birth, death = cabinet.parse_authordate(authdate)
date = utils.date_row(row)
if death > 0 and death < 1920:
oldfic.append(row)
continue
elif death > 0 and death + 20 < date:
oldfic.append(row)
continue
else:
stdauthor = standardize_name(row['author'])
row['stdauthor'] = stdauthor
newfic.append(row)
def numeric_only(astring):
numonly = ''
for character in astring:
if character.isdigit():