Python 查找特定代词的程序

Python 查找特定代词的程序,python,Python,**这是可以打印代词数量而不是实际代词数量的代码。它使用列表打印。那么有没有办法让代词打印出来。请简单一点 **您可以使用字典来统计您遇到的每个名词的数量(查看“添加”的注释,查看代码中发生了哪些更改)- 打印(“名词计数器”) 句子=“这是可以打印代词数量而不是实际代词数量的代码。”\ “它使用列表打印。那么有什么方法可以让代词打印出来?” #输入(“写一个句子:”) 代词=“指示的” #(输入(“从指示词、疑问词和不定词中选择一个代词:”) 如果代词==“指示词”: 来源=句子 代词=[“这

**这是可以打印代词数量而不是实际代词数量的代码。它使用列表打印。那么有没有办法让代词打印出来。请简单一点
**

您可以使用字典来统计您遇到的每个名词的数量(查看“添加”的注释,查看代码中发生了哪些更改)-

打印(“名词计数器”)
句子=“这是可以打印代词数量而不是实际代词数量的代码。”\
“它使用列表打印。那么有什么方法可以让代词打印出来?”
#输入(“写一个句子:”)
代词=“指示的”
#(输入(“从指示词、疑问词和不定词中选择一个代词:”)
如果代词==“指示词”:
来源=句子
代词=[“这个”、“那个”、“这些”、“那个”]#从某处下载一个列表
打印(“指示代词的数量:”)
count=dict(zip(代词,[0]*len(代词))#加法
words=source.split()
对于w,大写:
如果代词中的w.lower():
计数[w.lower()]+=1#加法
打印(计数)
elif代词==“不定”:
来源=句子
代词=[“其他人”、“任何人”、“任何人”、“任何事”、“每个人”、“要么”、“足够”、“每个人”、“每个人”,
“一切”、“很少”、“很多”、“既没有”、“没有人”、“没有人”、“没有”、“一个”、“另一个”、“某人”,
“某物”、“两者”、“很少”、“更少”、“很多”、“其他”、“几个”、“全部”、“任何”、“更多”、“大多数”,
“某人”、“无”、“某些人”、“这样”]#从某处下载列表
打印(“不定代词的数量:”)
count=dict(zip(代词,[0]*len(代词))#加法
words=source.split()
对于w,大写:
如果代词中的w.lower():
计数[w.lower()]+=1#加法
打印(计数)
elif代词==“疑问词”:
来源=句子
代词=[“谁”、“谁”、“谁”、“什么”、“哪个”]
打印(“疑问代词的数量:”)
count=dict(zip(代词,[0]*len(代词))#加法
words=source.split()
对于w,大写:
如果代词中的w.lower():
计数[w.lower()]+=1#加法
打印(计数)
其他:
打印(“未找到名为“+代词+”,请重试)
乌普图
谢谢@sai我真的在寻求帮助。该代码简单方便。谢谢你在这里讨论了你的问题,你应该考虑接受回答这个问题的答案。
print("Noun Counter")
sentence = input("Write A sentence: ")
pronoun = (input("Choose a pronoun from Demonstrative, interrogative and indefinite: "))

if pronoun == "Demonstrative":
    source = sentence
    pronouns = ["this", "that", "these", "those"]  # download a list from somewhere
    print("Number of Demonstrative pronouns: ")
    count = 0
    words = source.split()
    for w in words:
        if w.lower() in pronouns:
            count += 1
    print(count)

elif pronoun == "Indefinite":
    source = sentence
    pronouns = ["Another", "anybody", "anyone", "anything", "each", "either", "enough", "everybody", "everyone",
                "everything", "little", "much", "neither", "nobody", "no one", "nothing", "one", "other", "somebody",
                "something", "Both", "few", "fewer", "many", "others", "several", "All", "any", "more", "most",
                "someone", "none", "some", "such"]  # download a list from somewhere
    print("Number of Indefinite pronouns: ")
    count = 0
    words = source.split()
    for w in words:
        if w.lower() in pronouns:
            count += 1
    print(count)

elif pronoun == "Interrogative":
    source = sentence
    pronouns = ["who", "whom", "whose", "what", "which"]
    print("Number of Interrogative pronouns: ")
    count = 0
    words = source.split()
    for w in words:
        if w.lower() in pronouns:
            count += 1
    print(count)

else:
    print("No pronoun found named: " + pronoun + ", please try again")
Noun Counter
Number of Demonstrative pronouns: 
{'this': 1, 'that': 1, 'these': 0, 'those': 0}