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


Python SonicScrewdriver.simple_date方法代码示例

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


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

示例1: addmetadata

# 需要导入模块: import SonicScrewdriver [as 别名]
# 或者: from SonicScrewdriver import simple_date [as 别名]
    def addmetadata(self, row, table):
        self.author = table['author'][row]
        self.title = table['title'][row]
        self.date = utils.simple_date(row, table)
        genrelist = table['genres'][row].split(';')
        self.genres = set(genrelist)

        varietiesofnon = ['Bibliographies', 'Catalog', 'Dictionary', 'Encyclopedia', 'Handbooks', 'Indexes', 'Legislation', 'Directories', 'Statistics', 'Legal cases', 'Legal articles', 'Calendars', 'Autobiography', 'Biography', 'Letters', 'Essays', 'Speeches']

        self.nonmetaflag = False
        for genre in varietiesofnon:
            if genre in self.genres:
                self.nonmetaflag = True
开发者ID:deepfriedrabbit,项目名称:genre,代码行数:15,代码来源:logisticconfidence.py

示例2: print

# 需要导入模块: import SonicScrewdriver [as 别名]
# 或者: from SonicScrewdriver import simple_date [as 别名]
filelist = [x for x in filelist if x.endswith(".txt")]
contexts = []

WINDOWRADIUS = 7

ctr = 0

for filename in filelist:

    htid = utils.pairtreelabel(filename.replace('.fic.txt', ''))

    if htid not in rows:
        print(htid)
        continue
    else:
        date = utils.simple_date(htid, table)

    filepath = os.path.join(sourcedir, filename)
    with open(filepath, encoding = 'utf-8') as f:
        filelines = f.readlines()
    pagelist = [filelines]

    # The wordcounter module expects a list of pages, each of which is a list of lines.
    # Ebooks have no pages -- at least as I currently receive them -- so we treat it
    # all as one giant page.

    tokenstream = modelingcounter.makestream(pagelist)

    newcontexts = modelingcounter.extract_snippets(tokenstream,  WINDOWRADIUS, alltargetwords)

    approvedcontexts = []
开发者ID:tedunderwood,项目名称:GenreProject,代码行数:33,代码来源:fifteenwordsnippets.py

示例3: count_words

# 需要导入模块: import SonicScrewdriver [as 别名]
# 或者: from SonicScrewdriver import simple_date [as 别名]
rows, columns, table = utils.readtsv('/Users/tunder/Dropbox/GenreProject/metadata/topicmodelingsample.tsv')

sourcedir = "/Volumes/TARDIS/work/moneytexts/"

for row in rows:
    filename = utils.pairtreefile(row) + ".fic.txt"
    filepath = os.path.join(sourcedir, filename)
    if os.path.isfile(filepath):
        tokencount, wordcount = count_words(filepath)
    else:
        print("Missing file: " + filepath)
        sys.exit(0)

    idcode = table["HTid"][row]
    date = str(utils.simple_date(row, table))
    author = table["author"][row]
    title = table["title"][row]
    newrow = [idcode, date, tokencount, wordcount, author, title]
    outtable.append(newrow)
    print(counter)
    counter += 1

outfile = '/Users/tunder/Dropbox/GenreProject/metadata/improvedficsample.csv'
with open(outfile, mode='w', encoding = 'utf-8') as f:
    f.write('idcode,date,tokens,words,author,title\n')
    writer = csv.writer(f)
    for row in outtable:
        writer.writerow(row)

开发者ID:tedunderwood,项目名称:GenreProject,代码行数:30,代码来源:better_metadata_maker.py

示例4: int

# 需要导入模块: import SonicScrewdriver [as 别名]
# 或者: from SonicScrewdriver import simple_date [as 别名]
        jgenre = fields[13]
        date = int(fields[1])

        if jgenre == 'poe':
            selecteddates[htid] = date
            selected.add(htid)

rows, columns, table = utils.readtsv('/Users/tunder/Dropbox/GenreProject/metadata/filteredpoetry.tsv')

bydate = dict()

for row in rows:
    if row in selected:
        continue

    date = utils.simple_date(row, table)

    if date in bydate:
        bydate[date].append(row)
    else:
        bydate[date] = [row]

controlset = set()

for theid, date in selecteddates.items():
    found = False
    while not found:
        candidates = bydate[date]
        choice = random.sample(candidates, 1)[0]
        print(table["author"][choice])
        print(table["title"][choice])
开发者ID:tedunderwood,项目名称:GenreProject,代码行数:33,代码来源:select_poetry_corpus.py


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