The purpose of the lab is to get acquainted with Rx and RxJava from Netflix.
If you want to run the program locally you need:
- 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.
- Maven 3
The exercises can be done in any order but the following order is suggested.
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:- If the sentence contains more positive words than negative words then the outcome is positive.
- If the sentence contains more negative words than positive words then the outcome is negative.
- If the sentence contains an equal amount of negative words and positive words then the outcome is neutral.
- 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:
- Convert the list of sentences loaded from
sentences.txt
into an Observable then solve the problem in a FRP style. - Implement an Observable that shuffles and delays each sentence by a small amount of time for infinity.
- 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)
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:- 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.
- 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.
- 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.