统计句子中的单词个数

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u012300744/article/details/80706956
from collections import Counter

def bag_of_words(text):
    # TODO: Implement bag of words
    return Counter(text.split())

test_text = 'the quick brown fox jumps over the lazy dog'

print(bag_of_words(test_text))

猜你喜欢

转载自blog.csdn.net/u012300744/article/details/80706956