所以我有下面的代碼來計算文本文件中的字數。我想用出現次數最多的單詞對輸出進行排序。這如何實現? ally = open("alice.txt", "r")
wordcount={}
for word in ally.read().split():
if word not in wordcount:
wordcount[word] = 1
else:
我無法與階 object WordCount {
def main(args: Array[String]): Unit = {
val inputPath = args(0)
val outputPath = args(1)
val sc = new SparkContext()
val lines = sc.textFile(inputPath)
val wordCounts =
我需要編寫一個函數來計算文件中的所有單詞並打印單詞的平均長度。 (標點符號務必被刪除。) def average(fileName):
infile = open(fileName,'r')
wordcount = {}
for word in infile.read().split():
if word not in wordcount: