本文整理汇总了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")
示例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("")
示例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))