如何匹配我已经预定义的字符串,然后如果它们出现在我传递的段落中,则提取它们。
段落:
Paragraph are the building blocks of papers. Many student define paragraph in terms of length: a paragraph is a group of at least five sentences, a paragraph is half a page long, etc. In reality, though, the unity and coherence of ideas among sentences is what constitutes a paragraph
预定义字符串:
['paragraph','building blocks', 'length', 'page', 'students']
输出:
['paragraph', 'paragraph', 'paragraph', 'paragraph', 'paragraph', 'length', 'page', 'student' ]
match = []
string_doob = paragraph.lower()
for i in predefined_string:
if i in string_doob:
match.append(i)
print(match)