from pyspark import SparkContext
sc = SparkContext("local", "first app")
text = sc.textFile("C:\data.txt")
words = text.map(lambda line: str(line)).flatMap(lambda x: x.lower().split(" "))
print(words.top(100))
total_words = words.count()
print(words.count())
wordCount = words.map(lambda x: (x,1)).reduceByKey(lambda x,y: x+y)
print(wordCount.top(20))
вход: mahi, Mahi, mAhi, maHi, mahI, MAHI, MAhi, MAHi, straw, Straw, STRAW, berry, Berry
выход: [('straw,', 3), ('mahi,', 8), ('berry,', 1), ('berry', 1)]
Но вывод должен возвращать [('straw,', 3), ('mahi,', 8), ('berry,', 2)]
. Я новичок в pyspark
. Может кто-нибудь, пожалуйста, помогите мне, что не так с кодом?