Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 146111b

Browse filesBrowse files
Changed method name from top to mostFrequentWords in Main.scala
1 parent 4849916 commit 146111b
Copy full SHA for 146111b

File tree

Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed
Open diff view settings
Collapse file

‎workspace/w09_words/Main.scala‎

Copy file name to clipboardExpand all lines: workspace/w09_words/Main.scala
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ object Main:
44
val defaultUrl = "https://fileadmin.cs.lth.se/pgk/skattkammaron.txt"
55
val defaultN = 10
66

7-
def top(n: Int, freqMap: Map[String, Int]): Vector[(String, Int)] = ???
7+
def mostFrequentWords(n: Int, freqMap: Map[String, Int]): Vector[(String, Int)] = ???
88

99
def report(text: Text, from: String, n: Int): String =
1010
val longestWordsWithLength =
11-
top(n, text.distinct.map(w => (w, w.length)).toMap).mkString(", ")
11+
mostFrequentWords(n, text.distinct.map(w => (w, w.length)).toMap).mkString(", ")
1212
s"""
1313
|Källa: $from
1414
|
1515
|*** Antal ord: ${text.words.size}
1616
|
1717
|*** De $n vanligaste orden och deras frekvens:
18-
|${top(n, text.wordFreq).mkString(", ")}
18+
|${mostFrequentWords(n, text.wordFreq).mkString(", ")}
1919
|
2020
|*** De $n längsta orden och deras längd:
2121
|$longestWordsWithLength

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.