This file contains hidden or 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
type Aux[T, Repr0] = Generic[T] { type Repr = Repr0 } |
This file contains hidden or 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
case class Simple(number: Int, working: Boolean, someText: String) | |
val s = Simple(2, true, "hello") | |
// s: Simple = Simple(2,true,hello) | |
val sGen = Generic[Simple] | |
// sGen: shapeless.Generic[Simple]{type Repr = Int :: Boolean :: String :: shapeless.HNil} = anon$macro$4$1@215c6699 |
This file contains hidden or 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
trait Generic[T] extends Serializable { | |
/** The generic representation type for {T}, which will be composed of {Coproduct} and {HList} types */ | |
type Repr | |
/** Convert an instance of the concrete type to the generic value representation */ | |
def to(t : T) : Repr | |
/** Convert an instance of the generic representation to an instance of the concrete type */ | |
def from(r : Repr) : T | |
} |
This file contains hidden or 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
implicit def caseClassToGenerator[A, Repr <: HList]( | |
implicit generic: LabelledGeneric.Aux[A, Repr], | |
gen: ComponentGenerator[Repr], | |
reactComponent: ReactComponentGenerator[A] | |
): ComponentGenerator[A] = | |
new ComponentGenerator[A] { | |
override def generate = reactComponent.generate(gen.generate) | |
} |
This file contains hidden or 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
{ | |
content: "RT @HKane: What a feeling to score a winner for @England at the @FIFAWorldCup. Loved it! No less than we deserved. 🦁🦁🦁 #ThreeLions #ENG #Wo…", | |
author: "Ogunlola Olamide", | |
sentimentScore: 63, | |
mentionedCountries: [ | |
{ | |
England: { | |
name: "England" | |
} | |
} |
This file contains hidden or 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
{ | |
content: "RT @georgeseara: Sooo epic and an honour to be a part of.. @shawnmendes x @portugal ⚽️ Força Portugal!! 🇵🇹❤️ #WorldCup #Portugal #ShawnMend…", | |
author: "Hanslei Mendes", | |
sentimentScore: 83, | |
mentionedCountries: [ | |
{ | |
Portugal: { | |
name: "Portugal" | |
} | |
} |
This file contains hidden or 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
{ | |
status: "200 OK", | |
data: { | |
Poland: { | |
count: 8, | |
sentimentCount: 8, | |
averageSentiment: 0 | |
}, | |
Egypt: { | |
count: 14, |
This file contains hidden or 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
class StatisticsActor extends Actor { | |
import StatisticsActor._ | |
self ! Init | |
def receive: Receive = { | |
case Init => context become ready(Map[String, Stats]()) | |
} | |
def ready(stats: Map[String, Stats]): Receive = { |
This file contains hidden or 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
object AwsSentimentService extends SentimentService { | |
override def getSentiment(s: String): Future[Sentiment] = { | |
val awsCreds = DefaultAWSCredentialsProviderChain.getInstance | |
val comprehendClient = AmazonComprehendClientBuilder.standard.withCredentials(awsCreds).withRegion("eu-west-1").build | |
Future { | |
val req = new DetectSentimentRequest().withText(s).withLanguageCode("en") | |
val result = comprehendClient.detectSentiment(req) | |
println(result) | |
Sentiment(result.getSentiment, getSentimentScore(result)) |
This file contains hidden or 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
class TweetConsumerService extends LazyLogging { | |
this: LatestUpdateModule with SentimentModule => | |
def start = { | |
logger.info( "starting streaming" ) | |
val client = TwitterStreamingClient() | |
client.filterStatuses(stall_warnings = true, tracks = Seq("Russia2018", "WorldCup", "FIFA"))(handleTweet) | |
} | |
def handleTweet: PartialFunction[StreamingMessage, Unit] = { |