假设我有一段:
text = '''Darwin published his theory of evolution with compelling evidence in his 1859 book On the Origin of Species, overcoming scientific rejection of earlier concepts of transmutation of species.[4][5] By the 1870s the scientific community and much of the general public had accepted evolution as a fact. However, many favoured competing explanations and it was not until the emergence of the modern evolutionary synthesis from the 1930s to the 1950s that a broad consensus developed in which natural selection was the basic mechanism of evolution.[6][7] In modified form, Darwin's scientific discovery is the unifying theory of the life sciences, explaining the diversity of life.[8][9]'''
如果说我输入了一个词(喜欢),那么我怎样才能删除该词所在的整个句子。我之前使用的方法很乏味;我会使用 sent_tokenize 来打破 para(超过 13000 个单词),因为我必须检查超过 1000 个单词,所以我会运行一个循环来检查每个句子中的每个单词。这需要很多时间,因为有 400 多个句子。
相反,我想检查段落中的那 1000 个单词,当找到该单词时,它会选择之前的所有单词直到句号,然后选择所有单词,直到句号。