Skip to content

johanhaleby/rx-kdag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RxJava lab

The purpose of the lab is to get acquainted with Rx and RxJava from Netflix.

Prerequisites

If you want to run the program locally you need:

  1. Java 8 (Optional but recommended. If you want to use Java 7 then change compiler version in the pom.xml file). Note that you can also use Groovy or Clojure if you prefer.
  2. Maven 3

Exercises

The exercises can be done in any order but the following order is suggested.

Sentiment Analyzer

The purpose is to implement a simple sentiment analyzer that inspects a sequence of sentences and for each one determine if the sentence is positive or negative by checking if the sequence contains a given set of words. The rules are as follows:
  1. If the sentence contains more positive words than negative words then the outcome is positive.
  2. If the sentence contains more negative words than positive words then the outcome is negative.
  3. If the sentence contains an equal amount of negative words and positive words then the outcome is neutral.
  4. If the sentence doesn't contain any positive or negative words then the outcome is neutral.

Print the result to the console (or something fancier if you like)! Start at com.jayway.kdag.rx.SentimentAnalysisExample and implement the three sub-tasks:

  1. Convert the list of sentences loaded from sentences.txt into an Observable then solve the problem in a FRP style.
  2. Implement an Observable that shuffles and delays each sentence by a small amount of time for infinity.
  3. Create an Observable that takes live data from a Twitter stream (perhaps using twitter4j and performs sentiment analysis on each tweet. Note that this exercise may take some time so you may want to come back to it at the end if you have enough time.

(Inspiration to this exercise came from Jonathan Worthington)

Button Combination

Running the `com.jayway.kdag.rx.ButtonCombinationExample` will open up a simple Swing UI with two buttons (A & B) and two text areas. The purpose of this exercise is to use the RxJava Swing extension to do the following:
  1. React to button presses for the two buttons and print the button name on the text area in the south west corner for each button press.
  2. Find out if the user has pressed the password sequence of "ABBABA" and if so print "Password matched" in text area in the south east corner.
  3. Add so that the password sequence must be entered within 4 seconds otherwise it's no match! Also clear the text area in the south east corner after an appropriate amount of time after a match has been found.

Top movies

The purpose here is to download the first 100 movie titles from the IMDB top 250 movie list and compare them to the movies at Film Crave. For each top list compare the the movie titles and see which movies that are on the same position on both lists. Print the movie name and the position of the movie to the console (or something fancier if time allows). You should use the RxJava HttpClient extension when making requests to the website. You may parse the website in whatever way you find suitable (as long as it's downloaded using the RxJava HttpClient wrapper) but there are examples on how to parse to website using RestAssured's XmlPath in the test `com.jayway.kdag.rx.MovieExampleTest`. To spice things up you should also periodically check the website for changes, you never know when a new film enters the top-list or if a position change :)

Wikipedia search

Implement a simple Swing UI (or something similar) that continuously reads a text field and searches for Wikipedia articles that match the query (note that you obviously can't send a new query on each key stroke so they need to be buffered a certain amount of time). The found articles should be clickable and if clicked the article should be downloaded and displayed in the UI.

Rock-Paper-Scissors event analyzer

Open the rock-paper-scissors game that you created in an earlier lab session. Post all events to a queue or directly to an RxJava observable and perform some cool analysis on the game play in realtime. If time allows then push the results of your analysis to a websocket (using for example VertX RxJava extension) and present it in a UI (perhaps using d3).

Releases

No releases published

Packages

No packages published

Languages