本文整理汇总了Python中line.Line.should_be_skipped方法的典型用法代码示例。如果您正苦于以下问题:Python Line.should_be_skipped方法的具体用法?Python Line.should_be_skipped怎么用?Python Line.should_be_skipped使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类line.Line
的用法示例。
在下文中一共展示了Line.should_be_skipped方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: poem_ex_nihilo
# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import should_be_skipped [as 别名]
def poem_ex_nihilo(**kwargs):
if 'format' in kwargs:
poem = getattr(poemformat, kwargs['format'].capitalize())() #class
else:
poem = getattr(poemformat, sys.argv[1].capitalize())() #class
if 'input_text' in kwargs:
input_text = './SCALIA.txt'
else:
input_text = sys.argv[2] or "./SCALIA.txt"
text = open(input_text).read()
sent_detector = nltk.data.load('tokenizers/punkt/english.pickle')
linetexts = sent_detector.tokenize(text)
# lists_of_linetexts = map(lambda x: x.split(";"), open(input_text).read().split("\n"))
# #lists_of_linetexts = map(lambda x: x.split(","), open(sys.argv[2]).read().split("\n"))
# linetexts = [line for line_list in lists_of_linetexts for line in line_list]
#linetexts = ["camping is in tents", "my tree table tries", "between those times I slept none"]
# linetexts = ["many words in english rhyme with song", "one two three four five six", "a bee see dee word kicks",
# "This is a line that is twenty long", "here are ten more ending in wrong", "Jeremy Bee Merrill plays ping pong",
# ]
if 'rhyme_checker' in kwargs:
p = Poemifier(poem, rhyme_checker=kwargs['rhyme_checker'])
else:
p = Poemifier(poem)
p.debug = True
p.verbose = kwargs.get('verbose', False)
p.allow_partial_lines = kwargs.get('allow_partial_lines', False)
#this can't be a do... while, because we have to add all the lines, then do various processing steps.
for linetext in linetexts:
print linetext
line = Line(linetext, p.rhyme_checker)
if line.should_be_skipped():
continue
#p.try_line(line) #too slow
p.add_line(line)
print ""
complete_poem = p.create_poem(kwargs.get('be_random', True))
if complete_poem:
print poem.format_poem( complete_poem ) #random?
else:
print "No Poem"