This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<root> | |
<devicevendordef> | |
<vendorname>Dell</vendorname> | |
<vendorid>16700</vendorid> | |
</devicevendordef> | |
<deviceproductdef> | |
<productname>Dell USB Keyboard</productname> | |
<productid>8195</productid> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Get the last line of text in Alice in Wonderland that contains each of the top 20 frequent words in the book | |
NOT ACTUALLY TESTED, just logically combined. See fork source for original version that is mulch ore likely to work. | |
*/ | |
import scala.io.Source | |
val alice = Source.fromURL("http://www.gutenberg.org/files/11/11.txt").getLines.zipWithIndex.toList | |
val aliceWords = TypedPipe.from(alice).flatMap { case (text, _) => text.split("\\s+").toList } | |
val wordCount = aliceWords.map { word => (word, 1L) }.group.sum | |
val top20 = wordCount.groupAll.sortBy { case (word, count) => -count }.take(20).values | |
val lastLine = alicePipe.flatMap { case (text, line) => text.split("\\s+").toList.map { word => (word, line) }}.group.max |