Skip to content

Commit

Permalink
minor change
Browse files Browse the repository at this point in the history
  • Loading branch information
Arshdeep Singh committed Apr 18, 2018
2 parents 5749139 + 0c72319 commit 431353a
Show file tree
Hide file tree
Showing 59 changed files with 4,648 additions and 21,316 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
test.py
*.json
environment.sh
logfile.txt
__pycache__
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,26 @@ Inspirata is a crowdsourced platform, which extracts motivating and encouraging
Responses generated by Inspirata can be seen [here](http://www.cse.iitd.ac.in/~cs5160625/cfd.html) and also on [Twitter](https://twitter.com/_inspirata/with_replies) and program is running on a local server.

## Updates on Instabot
As an update to our platform, we extended our idea and added it to instagram, where we made a service which searches for certain keywords on instagram and then using our algorithms on images and caption comments with encouraging words.
As an update to our platform, we extended our idea to instagram, where we made a service which searches for certain keywords on instagram and then using sentiment analysis on captions and emotion analysis on images, we find if the instagram post is sad or depressing. Then we comment on that post with encouraging words.


# Specs
We used Microsoft Text Analytics APIs for Natural Language Processing and then used a markov chain to produce sentences. We first use Language Detection to segregate tweets in English. Sentiment analysis then calculates positive or negative sentiment which is used to classify the tweet as sad or happy. If the tweet is a sad one, our app replies the person who tweeted with an inspiring qoute. If the tweet is a happy one, our app uses it to train the Markov chain model for generating inspiring quotes to tweet. In this sense, our app is a crowdsourced app. For Instagram we used the same algorithm but added additional feature to use an image for Emotion Detection that further enhances its functionality.

### We are not using any hardcoded quotes. All the quotes are generated through Markov Chain.

## Working

![picture1](https://raw.githubusercontent.com/4rshdeep/Code.fun.do/master/images/tweet1.png)

![picture2](https://raw.githubusercontent.com/4rshdeep/Code.fun.do/master/images/tweet2.PNG)

Above two pictures are sentences from our file on which markov chain is trained, and as we can see how the below sentence is generated.
![picture2](https://raw.githubusercontent.com/4rshdeep/Code.fun.do/master/images/final.jpg)




# Demo
### Twitter
![alt text](https://raw.githubusercontent.com/4rshdeep/Code.fun.do/master/images/7.PNG)
Expand All @@ -25,7 +37,7 @@ We used Microsoft Text Analytics APIs for Natural Language Processing and then u
![alt text](https://raw.githubusercontent.com/4rshdeep/Code.fun.do/master/images/4.PNG)
### Instagram
![alt text](https://raw.githubusercontent.com/4rshdeep/Code.fun.do/master/images/12.png)
![alt text](https://raw.githubusercontent.com/4rshdeep/Code.fun.do/master/images/13.png){ width=50% }
![alt text](https://raw.githubusercontent.com/4rshdeep/Code.fun.do/master/images/13.png)
![alt text](https://raw.githubusercontent.com/4rshdeep/Code.fun.do/master/images/14.png)
![alt text](https://raw.githubusercontent.com/4rshdeep/Code.fun.do/master/images/15.png)

Expand Down
17 changes: 13 additions & 4 deletions facebookbot/bot.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
import facebook
import os
import requests

app_id = "340963926402035"
app_secret = "b9c46f67e14f5d69c343e0df06bea0bd"

graph = facebook.GraphAPI(access_token='EAACEdEose0cBADJY4EEZCKw86CA5LFt5NXelh7weB0F6EHKVodV6Jb2Vt6nmtuqZB2ZCwCuf486Gsfw0rcJruSLZARlaJlH7I52mIYanPJPgyiFZBt9acFr9AQCdktKt99R52inH9cG1sMyZA5MvuOZAcxwfUF1P3Q0VUiBvmhzeJlIrFNsEV9BuMsGfHE1wBvUy2SkYZBiBOgZDZD', version="2.10")
def get_fb_token(app_id, app_secret):
payload = {'grant_type': 'client_credentials', 'client_id': app_id, 'client_secret': app_secret}
file = requests.post('https://graph.facebook.com/oauth/access_token?', params = payload)
#print file.text #to test what the FB api responded with
result = file.json()['access_token']
#print file.text #to test the TOKEN
return result

graph = facebook.GraphAPI(access_token='EAACEdEose0cBAAUoPkaEZBZADr1W5xpcHoMioICVaVbkWZBYB9ciclWZAZBsyF0KEZBZAslc8EICxChAsUdoSBytirO3gTYfACEEI5qQCVx88QsT1fuHZBl9ZBkTZB3pxvZBCP0A88TWpz0NlDeS0zQ1oOs8Pw36LJcvB3kINwO90fdq8dETIPoE5cQZCOeg15Kgqzo0CvngqJXlLAZDZD', version="2.10")
# get_app_access_token(app_id, app_secret)

users = graph.search(type='user', q='4rshdeep')
# users = graph.search(type='user', q='4rshdeep')

for user in users['data']:
print('%s %s' % (user['id'],user['name'].encode()))
# for user in users['data']:
# print('%s %s' % (user['id'],user['name'].encode()))



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
3,751 changes: 3,751 additions & 0 deletions facebookbot/facebook-page-post-scraper/531752773523381_facebook_statuses.csv

Large diffs are not rendered by default.

273 changes: 273 additions & 0 deletions facebookbot/facebook-page-post-scraper/Untitled.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>status_id</th>\n",
" <th>status_message</th>\n",
" <th>status_author</th>\n",
" <th>link_name</th>\n",
" <th>status_type</th>\n",
" <th>status_link</th>\n",
" <th>status_published</th>\n",
" <th>num_reactions</th>\n",
" <th>num_comments</th>\n",
" <th>num_shares</th>\n",
" <th>num_likes</th>\n",
" <th>num_loves</th>\n",
" <th>num_wows</th>\n",
" <th>num_hahas</th>\n",
" <th>num_sads</th>\n",
" <th>num_angrys</th>\n",
" <th>num_special</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>531752773523381_1767214209977225</td>\n",
" <td>🇨🇦🇧🇷🇪🇺🇯🇵🇰🇷🇮🇳🇿🇦🇪🇸🇻🇪🇹🇴🇬🇧🇺🇸🇿🇼🇨🇴🇨🇿🇩🇴🇫🇮🇫🇷🇩🇪🇮🇩🇮🇪🇲🇳🇳🇿...</td>\n",
" <td>Svetlana Vorontsova</td>\n",
" <td>Partnership Fundraising: The Business of the 2...</td>\n",
" <td>link</td>\n",
" <td>http://www.passive-income-learn-why-here-link.ru/</td>\n",
" <td>2018-01-26 18:46:33</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>531752773523381_1767176869980959</td>\n",
" <td>NaN</td>\n",
" <td>Hon Adedeji Sikiru</td>\n",
" <td>Natural Freshwater Pearl Jewelry Set w/Sterlin...</td>\n",
" <td>link</td>\n",
" <td>http://www.gotclicks1.com/xHw7Vvc5mbsZ</td>\n",
" <td>2018-01-26 17:49:24</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>531752773523381_1767169219981724</td>\n",
" <td>NaN</td>\n",
" <td>Jonar Fabula</td>\n",
" <td>NaN</td>\n",
" <td>status</td>\n",
" <td>NaN</td>\n",
" <td>2018-01-26 17:35:54</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>531752773523381_1767148543317125</td>\n",
" <td>NaN</td>\n",
" <td>David Smith</td>\n",
" <td>Let's Vagabond</td>\n",
" <td>photo</td>\n",
" <td>https://www.facebook.com/letsvagabond/photos/a...</td>\n",
" <td>2018-01-26 17:05:07</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>531752773523381_1767139313318048</td>\n",
" <td>Per Week Earn Over $700 . ANYONE who knows how...</td>\n",
" <td>Lopa Lota</td>\n",
" <td>NaN</td>\n",
" <td>status</td>\n",
" <td>NaN</td>\n",
" <td>2018-01-26 16:49:55</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" status_id \\\n",
"0 531752773523381_1767214209977225 \n",
"1 531752773523381_1767176869980959 \n",
"2 531752773523381_1767169219981724 \n",
"3 531752773523381_1767148543317125 \n",
"4 531752773523381_1767139313318048 \n",
"\n",
" status_message status_author \\\n",
"0 🇨🇦🇧🇷🇪🇺🇯🇵🇰🇷🇮🇳🇿🇦🇪🇸🇻🇪🇹🇴🇬🇧🇺🇸🇿🇼🇨🇴🇨🇿🇩🇴🇫🇮🇫🇷🇩🇪🇮🇩🇮🇪🇲🇳🇳🇿... Svetlana Vorontsova \n",
"1 NaN Hon Adedeji Sikiru \n",
"2 NaN Jonar Fabula \n",
"3 NaN David Smith \n",
"4 Per Week Earn Over $700 . ANYONE who knows how... Lopa Lota \n",
"\n",
" link_name status_type \\\n",
"0 Partnership Fundraising: The Business of the 2... link \n",
"1 Natural Freshwater Pearl Jewelry Set w/Sterlin... link \n",
"2 NaN status \n",
"3 Let's Vagabond photo \n",
"4 NaN status \n",
"\n",
" status_link status_published \\\n",
"0 http://www.passive-income-learn-why-here-link.ru/ 2018-01-26 18:46:33 \n",
"1 http://www.gotclicks1.com/xHw7Vvc5mbsZ 2018-01-26 17:49:24 \n",
"2 NaN 2018-01-26 17:35:54 \n",
"3 https://www.facebook.com/letsvagabond/photos/a... 2018-01-26 17:05:07 \n",
"4 NaN 2018-01-26 16:49:55 \n",
"\n",
" num_reactions num_comments num_shares num_likes num_loves num_wows \\\n",
"0 0 0 0 0 0 0 \n",
"1 0 0 0 0 0 0 \n",
"2 0 0 0 0 0 0 \n",
"3 0 0 0 0 0 0 \n",
"4 0 0 0 0 0 0 \n",
"\n",
" num_hahas num_sads num_angrys num_special \n",
"0 0 0 0 0 \n",
"1 0 0 0 0 \n",
"2 0 0 0 0 \n",
"3 0 0 0 0 \n",
"4 0 0 0 0 "
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = pd.read_csv('531752773523381_facebook_statuses.csv')\n",
"df.head()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Index(['status_id', 'status_message', 'status_author', 'link_name',\n",
" 'status_type', 'status_link', 'status_published', 'num_reactions',\n",
" 'num_comments', 'num_shares', 'num_likes', 'num_loves', 'num_wows',\n",
" 'num_hahas', 'num_sads', 'num_angrys', 'num_special'],\n",
" dtype='object')"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.columns"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [default]",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,9 @@ def request_until_succeed(url):
success = False
while success is False:
try:
<<<<<<< HEAD
response = requests.get(url, proxies = proxyDict)
if response.status_code == 200:
success = True
=======
response = requests.get(url)
# if response.getcode() == 200:
# success = True
>>>>>>> 3e349e852b543ba36a4bbda9736e957393e6734f
except Exception as e:
print(e)
time.sleep(5)
Expand Down
Binary file added images/final.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/insta1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/insta2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/insta3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/insta4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/insta5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/insta6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/insta7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/insta8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/tweet1.PNG
Binary file not shown.
Binary file added images/tweet1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/tweet2.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions instabot/examples/model.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions instabot/instabot/bot/model.json

Large diffs are not rendered by default.

Loading

0 comments on commit 431353a

Please sign in to comment.