text
stringlengths
0
828
'version': '0.1',
'uploadKeys': order_list.upload_keys,
'generator': order_list.order_generator,
'currentTime': gen_iso_datetime_str(now_dtime_in_utc()),
# This must match the order of the values in the row assembling portion
# above this.
'columns': STANDARD_ENCODED_COLUMNS,
'rowsets': rowsets,
}
return json.dumps(json_dict)"
1164,"def weather(query):
""""""weather(query) -- use Name Entity Recogniser (nltk-stanford-ner), to
determine location entity in query and fetch weather info for that location
(using yahoo apis).
""""""
print 'Identifying the location . . .'
try:
response = unirest.post(""https://textanalysis.p.mashape.com/nltk-stanford-ner"",
headers={
""X-Mashape-Key"": ""E7WffsNDbNmshj4aVC4NUwj9dT9ep1S2cc3jsnFp5wSCzNBiaP"",
""Content-Type"": ""application/x-www-form-urlencoded""
},
params={
""text"": query
}
)
except:
print 'Unable to connect to internet'
return
location = ''
for entity in response.body['result'].split():
word,tag = entity.split('/')
if(tag == 'LOCATION'):
location += ' '+word
if(location != ''):
print 'Gathering weather information for'+location
import urllib2, urllib, json
baseurl = ""https://query.yahooapis.com/v1/public/yql?""
yql_query = ""select * from weather.forecast where woeid in \
(select woeid from geo.places(1) where text=\""""+location+""\"")""
yql_url = baseurl + urllib.urlencode({'q':yql_query}) + ""&format=json""
try:
result = urllib2.urlopen(yql_url).read()
data = json.loads(result)
result = data['query']['results']['channel']
print result['location']['city']+' '+result['location']['country']+' '+result['location']['region']
print result['item']['condition']['date']
print result['item']['condition']['text']
print result['item']['condition']['temp']+' '+result['units']['temperature']
except:
print 'Unable to connect to internet'
else:
print 'Unable to get the location.'"
1165,"def generic(query):
"""""" generic(query) -- process a generic user query using the Stanford
NLTK NER and duckduckgo api.
""""""
try:
response = unirest.post(""https://textanalysis.p.mashape.com/nltk-stanford-ner"",
headers={
""X-Mashape-Key"": ""E7WffsNDbNmshj4aVC4NUwj9dT9ep1S2cc3jsnFp5wSCzNBiaP"",
""Content-Type"": ""application/x-www-form-urlencoded""
},
params={
""text"": query
}
)
except:
print 'Unable to connect to internet'
return
web_query = ''
for entity in response.body['result'].split():
word,tag = entity.split('/')
if(tag != 'O'):
web_query += ' '+word
if(web_query != ''):
web_query = web_query.strip().split()
duckduckgo.query(web_query)
else:
print 'I do not know how to process this query at this moment.'"
1166,"def _can_construct_from_str(strict_mode: bool, from_type: Type, to_type: Type) -> bool:
""""""
Returns true if the provided types are valid for constructor_with_str_arg conversion
Explicitly declare that we are not able to convert primitive types (they already have their own converters)
:param strict_mode:
:param from_type:
:param to_type:
:return:
""""""
return to_type not in {int, float, bool}"
1167,"def are_flags_valid(packet_type, flags):
""""""True when flags comply with [MQTT-2.2.2-1] requirements based on
packet_type; False otherwise.
Parameters
----------