Created
November 26, 2017 13:30
-
-
Save syedatifakhtar/12ba1fb9c58b85fe21aa3d76cc160a49 to your computer and use it in GitHub Desktop.
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
%spark.dep | |
z.reset() // clean up previously added artifact and repository | |
// add maven repository | |
z.addRepo("Millhouse Bintray").url("http://dl.bintray.com/themillhousegroup/maven") | |
z.load("com.themillhousegroup:scoup_2.10:0.2.295") | |
import com.themillhousegroup.scoup.Scoup | |
import com.themillhousegroup.scoup.ScoupImplicits._ | |
val seasonLink = "https://genius.com/albums/Game-of-thrones/Season-%d-scripts" | |
(1 to 7).map(seasonLink.format(_)) | |
val allDialogues = | |
Future.sequence( | |
allSeasons.map{ | |
thisSeason=> | |
Scoup | |
.parse(thisSeason) | |
.map{ | |
_ | |
.select(".chart_row a") | |
.map(_.attribute("href").get).toList | |
} | |
}) | |
.map(_.flatten) | |
.map{ | |
_.map{ | |
link=> | |
Scoup.parse(link).map{ | |
_.select("p") | |
.text.filter(_!=']') | |
.split('.') | |
.map(_.split(":")) | |
.filter(_.length==2) | |
.map{a=>Speech(a(0).trim,a(1).trim)} | |
} | |
} | |
}.flatMap(Future.sequence(_)) | |
Await.ready(allDialogues,100 seconds).value.get.get.flatten |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment