-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79fc86b
commit 816ab7b
Showing
5 changed files
with
350 additions
and
62 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,73 @@ | ||
# himmat-ai | ||
# himmatAI | ||
|
||
himmat AI is at your service when you are in danger or medical emergency, get nearest authority contact details and location and share your location in one click to relatives and authorities. Explore lot more | ||
himmatAI is a step towards a new, empowering and Smart Society. | ||
himmat AI is 24x7 at your service when you are in danger or medical emergency, get nearest authority contact details and location and share your location in one click to relatives and authorities. Explore lot more | ||
|
||
# tools used | ||
|
||
The base of our platform is chatter on framework which supports NLU like api.ai and wit.ai and provides easy deployment avoiding struggle of deployment and integration of NLU apis with backend scripts. | ||
Chatter on uses apis to deal with dynamic data of any type. Following are the apis we used: | ||
himmatAI uses Platform as a Service. The base of our framework is chatteron platform which supports Natural Language Processing like api.ai and wit.ai and provides easy deployment avoiding struggle of deployment and integration of NLU apis with backend scripts. | ||
himmatAI uses apis to deal with dynamic data of any type. Following are the apis we used: | ||
|
||
|
||
`` | ||
prepared a api from scrapped data of justdial (eg. http://twg-api.herokuapp.com/api/dial?city=ludhiana&category=police which has been deployed along with one of applications.) | ||
`` | ||
`` | ||
used sheetsu api for converting google sheets as api | ||
himmatAI uses Google Places API to fetch location based data for the user. | ||
`` | ||
`` | ||
other apis used are: mapmyindia api, pricetree api, pricecheckindia api, food2fork recipe api and many more. | ||
Other apis used are: mapmyindia api, pricetree api, pricecheckindia api, food2fork recipe api and many more. | ||
`` | ||
|
||
Currently we are storing data in google sheets using sheetsu api and fetching it for use by various purposes. | ||
himmatAI is integrated with Flask at the backend to fetch/load the data. | ||
|
||
# features of himmat-ai | ||
# features of himmatAI | ||
|
||
`` | ||
find help around user location | ||
Find help around users location by fetching nearest concerned authorities. | ||
`` | ||
`` | ||
Share users location to loved once at the time of distress. | ||
`` | ||
`` | ||
Helps connect to an NGO for help | ||
`` | ||
share user location | ||
`` | ||
Lodge complaint on twitter for immediate action by government authorities | ||
`` | ||
connect to an NGO | ||
`` | ||
Get grocery vegetable and every product home deliver links. | ||
`` | ||
lodge complaint on twitter for immediate action by government authorities | ||
`` | ||
Cookery dishes recipes. | ||
`` | ||
get grocery. vegetable and every product home deliver | ||
`` | ||
Best online offers on one click. | ||
`` | ||
`` | ||
Women news in trend | ||
`` | ||
|
||
`` | ||
cookery | ||
NLP integration hence making it user friendly and smnart. | ||
`` | ||
|
||
`` | ||
best online offers on one click | ||
Speech Recognition option. | ||
`` | ||
|
||
`` | ||
women news in trend | ||
Easy deployment on various message sending appliactions like Facbook Messenger or Telegram. | ||
`` | ||
|
||
and lot more. | ||
#Some implenmatble features | ||
|
||
`` | ||
Safer Route feature integration to determine the best safest route. | ||
`` | ||
`` | ||
Analyisng the social environment of various areas of the towns and cities. | ||
`` | ||
`` | ||
Creating a central data with Police and medical databse. | ||
`` | ||
|
||
We have update apis we have built. | ||
We have updated APIs we have built. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import os, sys | ||
from flask import Flask, request, jsonify | ||
from pymessenger import Bot | ||
import requests | ||
import json | ||
|
||
app= Flask(__name__) #initialisng app | ||
|
||
#ignore# | ||
page_access_token = "EAATZAU8XCjkcBAI12BNwPrB5RZCZC4poPsJlmTJZAHLbSqtR4GPZC6b2fG5onlNCxYZA8ysMxErMD366dKNmW4pFq6jU0zx55ZAbjvlMfm0uN0GEkbU2GrpyZABdIVlsvdDdWcjvqooYfUNA3iWw4UJb4psevtqGCsQu9lFW9tH8zwZDZD" | ||
bot = Bot(page_access_token) | ||
|
||
@app.route('/', methods=['GET']) | ||
def verify(): | ||
#webhook verification | ||
if request.args.get("hub.mode") == "subscribe" and request.args.get("hub.challenge"): | ||
if not request.args.get("hub.verify_token") == "hello": | ||
return "Verification token mismatch", 403 | ||
return request.args["hub.challenge"], 200 | ||
return "Hello World", 200 | ||
|
||
|
||
|
||
@app.route('/', methods=['POST']) | ||
def webhook(): | ||
data= request.get_json() | ||
log(data) | ||
|
||
if data['object'] == 'page': | ||
for entry in data['entry']: | ||
for messaging_event in entry['messaging']: | ||
|
||
#ids | ||
sender_id= messaging_event['sender']['id'] | ||
recipient_id = messaging_event['recipient']['id'] | ||
|
||
if messaging_event.get('message'): | ||
if 'text' in messaging_event['message']: | ||
messaging_text=messaging_event['message']['text'] | ||
else: | ||
messaging_text = 'no_text' | ||
|
||
response =response_msg(messaging_text) | ||
bot.send_text_message(sender_id, response) | ||
|
||
return "ok", 200 | ||
|
||
|
||
#Main task is to genrate responses for the CESS MANIA | ||
# 3 main resonses based on the query | ||
# 1) Answer to the event: Particular format needed -> | ||
# format : Cess Mania , Name , Task , Answer | ||
# response: "Wassup! I am Cess-istant" /n Welcome to CESS Mania /n Your answer is successfully submitted/n Points will be rewared accorind to correctness of your answer/ Keep playing in CESS MANIA | ||
|
||
# 2) Answer to event but wrong format : "Wassup! I am Cess-istant"/n Oops! look like you entered the answer in wrong format! /n "Format details" /n Please send your response again in given format/n Keep playing in CESS MANIA | ||
# 3) Any other answer response -> "Wassup! I am Cess-istant"/n Thankyou for connecting with CESS /n We will get back to you soonest! /n Cess mania details.. | ||
|
||
|
||
def response_msg(savaal): | ||
|
||
savaal=savaal.lower() | ||
if (savaal.startswith("cess mania") and len(savaal.split(",")) == 4) : | ||
|
||
text_list= savaal.split(",") | ||
student_name= text_list[1] | ||
task=text_list[2] | ||
task_answer=text_list[3] | ||
output = "Wassup! I am Cess-istant. Welcome to CESS Mania. Your answer is successfully submitted. Points will be rewarded according to correctness of your answer. Keep playing in CESS MANIA" | ||
|
||
elif (savaal.startswith("cess mania") or len(savaal.split(",")) == 4) : | ||
output = "Wassup! I am Cess-istant. Oops! looks like you entered the answer in wrong format! Format -> Cess Mania , Name , Task , Answer. Please send your response again in given format. Keep playing in CESS MANIA" | ||
|
||
|
||
|
||
else : | ||
output = "Wassup! I am Cess-istant. Thankyou for connecting with CESS. We will get back to you soonest! (In case you submitted answer for CESS MANIA TASK, please send the answer in given format). Till then go check out CESS MANIA, its awesome. CESS MANIA FAQs : Q) How to register for CESS MANIA A)There is no registration for CESS MANIA, just like and share CESS PAGE and you are good to go" | ||
|
||
|
||
return output | ||
|
||
|
||
def log(msg): | ||
print msg | ||
sys.stdout.flush() | ||
|
||
if __name__ == "__main__": | ||
app.run(debug=True, port =80) | ||
|
||
|
||
#=======================================================# | ||
|
||
|
||
place_api="AIzaSyDT0P7r0ezcoeNvotC_J2AwviQnCCfj0Oo" #api privided by google(google placeapi) | ||
base_url="https://maps.googleapis.com/maps/api/place/search/json?location=" | ||
|
||
|
||
def location_data(lat,lng,type): | ||
|
||
location= lat+","+lng | ||
final_url= base_url+location + "&rankby=distance&types=" + type+ "&key="+ place_api | ||
|
||
#r=requests.get("https://maps.googleapis.com/maps/api/place/search/json?location=31.6607795,74.8214579&rankby=distance&types=police&sensor=false&key="+place_api) | ||
r=requests.get(final_url) | ||
#print r.content | ||
#d = ast.literal_eval(r) | ||
|
||
result = json.loads(r.text) | ||
|
||
data=dict(result) | ||
|
||
#pprint.pprint(data) | ||
|
||
result=data["results"] | ||
final_data=dict() | ||
|
||
final_data["data"]=list() | ||
#fetching required data | ||
|
||
for item in result: | ||
print "Name" , item["name"] | ||
print "Address" ,item["vicinity"] | ||
print "Co-ordinates", item["geometry"]["location"]["lat"], item["geometry"]["location"]["lng"] | ||
|
||
d= {} | ||
d["name"]=item["name"] | ||
d["locations"]=item["vicinity"] | ||
d["lat"]=item["geometry"]["location"]["lat"] | ||
d["lng"]=item["geometry"]["location"]["lng"] | ||
final_data["data"].append(d) | ||
return final_data | ||
|
||
@app.route('/api/sbcon/', methods=['GET']) #configuring the post request to get the data | ||
def data(): | ||
if len(request.args.get("lats")) and len(request.args.get("lngs")) and len(request.args.get("category")): #dynamic parameters | ||
lat=request.args.get("lats") | ||
lng=request.args.get("lngs") | ||
category=request.args.get("category") | ||
return jsonify(location_data(lat,lng,category)) | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(debug=True, port =80) | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import requests | ||
import pprint | ||
from flask import Flask, request, jsonify | ||
|
||
import json | ||
|
||
app = Flask(__name__) | ||
place_api="AIzaSyDT0P7r0ezcoeNvotC_J2AwviQnCCfj0Oo" | ||
|
||
|
||
def location_data(): | ||
type="police" | ||
|
||
r=requests.get("https://maps.googleapis.com/maps/api/place/search/json?location=31.6607795,74.8214579&rankby=distance&types=police&sensor=false&key="+place_api) | ||
#print r.content | ||
#d = ast.literal_eval(r) | ||
|
||
result = json.loads(r.text) | ||
|
||
data=dict(result) | ||
|
||
#pprint.pprint(data) | ||
|
||
result=data["results"] | ||
final_data=dict() | ||
|
||
final_data["data"]=list() | ||
|
||
|
||
for item in result: | ||
print "Name" , item["name"] | ||
print "Address" ,item["vicinity"] | ||
print "Co-ordinates", item["geometry"]["location"]["lat"], item["geometry"]["location"]["lng"] | ||
print "********************************" | ||
d= {} | ||
d["name"]=item["name"] | ||
d["address"]=item["vicinity"] | ||
d["lat"]=item["geometry"]["location"]["lat"] | ||
d["lng"]=item["geometry"]["location"]["lng"] | ||
final_data["data"].append(d) | ||
return final_data | ||
|
||
@app.route('/') | ||
def data(): | ||
return jsonify(location_data()) | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(debug=True, port =80) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pygeocoder import Geocoder | ||
# Convert longitude and latitude to a location | ||
results = Geocoder.reverse_geocode(32.277621,-107.734724) | ||
print results.coordinates | ||
print results.country | ||
|
||
print results.street_address | ||
|
||
print results.administrative_area_level_1 |
Oops, something went wrong.