用 python 识别句子中的副词

identify Adverbs in a sentences With python

我想编写一个 Python 程序来查找英语副词和法语副词给定句子中的所有副词及其位置这是代码:

text = "My sister's eyes were clearly and clearly filled with affection for you."
for m in re.finditer(r"\w+ly", text):
    print('%d-%d: %s' % (m.start(), m.end(), m.group(0)))

text = "parle doucement"
for m in re.finditer(r"\w+ement", text):
    print('%d-%d: %s' % (m.start(), m.end(), m.group(0)))

除了我做的程序没有考虑到所有的副词有没有办法做到这一点,非常感谢

我会推荐使用 NLTK (https://www.nltk.org/)

来自本教程 (https://www.nltk.org/book/ch05.html):

text = word_tokenize("And now for something completely different")
nltk.pos_tag(text)

这会给你:在这里我们看到and是CC,并列连词; now 和 completely 是 RB,或副词; for 是 IN,一个介词; something 是 NN,一个名词; different是形容词JJ