7
Project Report Twitter Aware : MoodSense Dinesh Vaithyalingam Gangatharan

Twitter Aware

Embed Size (px)

DESCRIPTION

Android application to access twitter and do sentiment analysis with it.

Citation preview

Project ReportTwitter Aware : MoodSenseDinesh Vaithyalingam Gangatharan

(Ubiquitous Computing Final Project Report)

(Twitter Aware - Mood Sense) September 5, 2015

1.1 Abstract

The goal of the project is to develop a context aware system, that facilitates user by utilizing twitter applicationdata, to set his room ambience (music). Much of the current applications using Twitter are confined to either androiddevices or desktop applications. The developed application uses the user status from Twitter modelled as a variantwhich can be used to control household devices that can signify it in a closed world or open world scenario. The usehere is to access the music application and control the music.

1.2 Introduction

As we broaden the computing systems away from desktop systems new research challenge arises. One unifyingresearch theme is to focus on our everyday activities. For this reason, we have investigated into the into the use ofour social context from social media applications for setting up a smart home scenario. The Twitter Aware MoodSense prototype has our mood as a context from Twitter and project it as a song in the smart home scenario.

1.3 System setup

The project covers a wide spectrum of technologies involved in making this system. We involve ourselves with anandroid application MoodSense. To connect to twitter and perform data search and collection, we made use of TwitterOAuth combined with Twitter4J java library. For resolving dependencies we performed the Maven integration. Wealso registered our app as on Twitter to gain access with the help of Customer Key and Secret tokens. This allowedus to perform search from user login account.

In addition for communication between our applications/devices, Android and PC, require the need of Messagingmiddleware (MOM) supported on these devices. We used MQTT(Message Queue Telemetry Transport) as messag-ing protocol supported for android and Java. It provides a publicly available server MQTT broker accessible attcp://test.mosquitto.org:1883.

Secondly for the music, the music PC application registers as a subscriber and plays songs.

1.4 System Architecture

The architecture of our scenario is represented in Figure 1.4. MoodSense android application acting as publisher, isactivated as user reaches the Home-Wifi vicinity and creates a connection. This is to enable setting home ambience asthe user reaches back home. The application searches for predefined mood strings on user’s home timeline of twitterfor the current day. If relevant match is found, the application parses and computes mood and intensity on the recenttweet and publishes to broker. As a work around, we notify the user to enter his mood or set the ambience as per themood on twitter on a global scale. The same is published which is received by the Java application(MoodMusic).

MoodMusic parses the message to play user’s favorite tracks as per the mood intensity.

1.5 Android Application

1.5.1 UX Flow Chart

1.5.2 Authentication Screen

This screen authenticates the user to access the application using the user’s twitter credentials. On clicking theAuthenticate with Twitter button, the user is redirected outside the application to MoodSense Light, the twitterapplication which enables the user to access the rest of the application.

1.5.3 Welcome Screen

The user is update his/her status on twitter using the application using the Enter Mood button or see the currentworld mood using the World Mood Twitter button.

1.1 Abstract 1

Figure 1.1: System Architechture

First time screen Connecting to twitter application

Authentication of user credentials

First screen on authentication

Figure 1.2: System Login

1.5.4 User Mood

The user is provided with a list of moods, which will be posted on twitter as "I’m feeling <User Mood>". The useris provided with a list of 8 moods which can be chosen. On successful posting, the pop-up "Post tweeted on twittersuccessfully" pops up.

1.5.5 World Mood

On clicking the world mood, the global search access obtained using the twitter API is used. This calculates the moodon the last 100 tweets posted on twitter. The obtained tweets, parsed as a list is compared with a pre-defined set ofstrings. These strings have the pre-defined set of words for every mood. The adjectives used with the words set theintensity of the mood. Three sets of intensity are set based on this.

1.5.6 Visualization

Using the Achart Library, all the world mood is classified under these 8 moods specified above. This is shown as achart on the screen.

The MoodSense android application make use of two services UserMoodService and WorldMoodService. If user isnot authenticated, our Authentication screen enables user to authenticate the application with his login credentials.The verification of Home-Wifi is done via WifiReceiver extended on Broadcast Receiver of android which is registered

2

USER LOGIN FLOW

USER OR WORLD MOOD SELECTION

USER MOOD TWITTER UPDATE FLOW

WORLD MOOD VISUALIZATION FLOW

Figure 1.3: UX Flow Chart

No status on Twitter

Notification to enter mood

List of moods

User selected mood posted on Twitter

Mood from application available on Twitter

Figure 1.4: User Notification for tweet

on WIFI_STATE_CHANGED and SCAN_RESULTS. We check and run the service every 5 minutes 1, to verify ifuser has updated his status on twitter.

1.6 Technical Explanation

1.6.1 Async task

The user mood and world mood are computed using an Async Task. The onPreExecute sets the progress informationwhile the doInBackgroud does the logic to either obtain user tweet or find the world mood. The onPostExecute opensthe screen to show that the user tweet has been posted or show the world mood that has the maximum percentage.

1.6.2 Services

The application also functions as a publisher to provide the mood to the subscriber. This doesn’t need user interven-tion. So a background service which runs, sends the tweets to the subscriber(The Java music application). A separatethread runs in the background, which does not use the main thread of the application to do this process.

1 for test

1.6 Technical Explanation 3

1.6.3 Broadcast Receiver

The application should start the service on reaching the home-wifi zone specified in the application. Extending thebroadcast receiver which enabled access to get Wifi details allows the application to do a SSID check before startingthe background service.

1.6.4 Notification Service

The application uses notification foreground notification service to provide a notification to the user on entering theuser mood to play music as per his/her mood on entering the wifi-zone. If ignored, the world mood is computed then.

Data Classification

The string search can be increased, however due to limitation from Twitter API that allows 15 calls per 15 minutesRate limit exceeed exception 2,the number of searches has been restricted to 10 tweets per day.To counter more than one matched tweets for current day, the recent match computed from user’s timeline is setas the current mood type. Computed mood is then published via the MqttMoodClient to the Mqtt broker by topic/home/mood.

If no tweet was found by the user on current day, then a notification is presented to the user to enter his mood.This can be done via User mood selection screen. Here user could also choose to update his/her mood on Twitterto consider our future twitter cycles. However, the user can also just update his home ambience by selecting HomeMood. User can even choose to ignore to enter mood, and this will make the application calculate the current moodon twitter on a global scale (World’s Mood).

Global mood search is performed over the same predefined phrases and tweets per minute is computed over eachmood type. The functionality is abstracted in utility class ComputeWorldMood which performs the computation.worldMoodRatio is calculated over the Tweets Per minute for each mood type. Then the difference of worldMoodRatiowith our constants worldTemperamentRatios defined as follows:

public static float temperamentRatios[] = {0.13f,0.15f,0.20f,0.14f,0.16,f0.12f,0.10f};

Higher is the difference more substantial is the increase of tweets for mood type, so that mood type becomes themost dominant mood type of world. Mood intensities are calculated with respect to our mood thresholds defined as:

public static final float moderateMoodThreshold = (2.0f);

public static final float extremeMoodThreshold = (4.0f);

In this manner the computed world mood type and intensity is also published to the Mqtt broker.

1.7 Java application

The subscriber is our Java based music application. Based on every mood we have a song and the volume is adjustedbased on the intensity of the mood (i.e) the stronger the intensity, the louder the song will be played.

1.8 Conclusion

In conclusion, we have attempted to define the space of an application using ubiquitous computing via transparentinteractions and user mobility. The framework defined creates a system where we have connected social mood withan ubiquitous system and translate our social mood into machine understandable sensor inputs. This is input intothe pub/sub mechanism. Interaction over IoT provides user with the facility to sense his mood via his home/roomambience. This can be termed furthermore as a Mood Room in which user comes to relax, listen music. Furtherenhancements are possible to also capture user localization combined with his mood. Also provide a world view withdifferent mood types per location.

2 https://dev.twitter.com/rest/public/rate-limiting

4

Notification provided to user to enter mood. User decides to ignore

World mood computed andmood and intensity provided onapplication

Graphical display of worldmood to user

Figure 1.5: User Mood Display Time Chart

1.8 Conclusion 5