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


Python Article.sentences方法代码示例

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


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

示例1: main

# 需要导入模块: from article import Article [as 别名]
# 或者: from article.Article import sentences [as 别名]
def main():
    _, file_name, nquestion = sys.argv
    clean_up(file_name)
    timer_log("reference resolution")
    questions = []
#     replaced
    with open("../temp/article.clean") as farticle:
        article = Article(farticle.read())
        for sent in article.sentences():
            print(sent)
            try:
                for simp_s in simplify_sen(sent):
                    q_generated = question(simp_s)
                    questions.extend(q_generated)
                    for q in q_generated:
                        print(q)
                    print("")
            except:
                print("failed")
                if debug:
                    traceback.print_exc()
            timer_log("one sentence")
    
    print(ranking.get_top_questions('\n'.join(questions), nquestion))
    timer_log("ranking")
开发者ID:DerrickZhu1,项目名称:11611teamproject-YenYuan-,代码行数:27,代码来源:ask.py

示例2: open

# 需要导入模块: from article import Article [as 别名]
# 或者: from article.Article import sentences [as 别名]
'''
Created on Apr 9, 2016

@author: zhongzhu
'''

import traceback

from article import Article
from simplify import simplify_sen


with open("../data/set1/a2.txt") as f:
    article = Article(f.read())
    for s in article.sentences():
        try:
            if s:
                print("ORIGINAL:\n" + s)
                for sen in simplify_sen(s):
                    print("DERIVED:\n" + sen)
        except Exception as e:
            print("[Error]" + str(e))
            traceback.print_exc()
        print("")
开发者ID:DerrickZhu1,项目名称:11611teamproject-YenYuan-,代码行数:26,代码来源:test_simplify.py

示例3: open

# 需要导入模块: from article import Article [as 别名]
# 或者: from article.Article import sentences [as 别名]
'''
Created on Apr 8, 2016

@author: zhongzhu
'''
import traceback

from article import Article
from gen_question import question
from simplify import simplify_sen


with open("../temp/questions.txt", "w+") as qf:
    with open("../data/set1/a1.txt") as f:
        article = Article(f.read())
        sents = article.sentences()
        for sent in sents[:20]:
            print(sent)
        for ori_sentence in article.sentences():
            try:
                for s in simplify_sen(ori_sentence):
                    if s:
                        print(s)
                        for q in question(s):
                            print(q)
                            qf.write(q + "\n")
                            qf.flush()
            except Exception as e:
                continue
                '''
                print("[Error]" + str(e))
开发者ID:DerrickZhu1,项目名称:11611teamproject-YenYuan-,代码行数:33,代码来源:test_qg.py


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