Beispiel #1
0
    count = len(exbusiness['businesses'])
    if togetcount < count:
        count = togetcount
    args = []
    args.append('--consumer_key='+ckey)
    args.append('--consumer_secret='+csecret)
    args.append('--token='+token)
    args.append('--token_secret='+tokensecret)

    for i in range(0, count):
        business = exbusiness['businesses'][i]
        if business.get('reviews') is not None:
            continue
        newargs = list(args)
        newargs.append('--id='+business['id'].encode('ascii','ignore'))
        print newargs
        result = yp.main(newargs)
        if result is None or result.get('reviews') is None:
            print 'cannot get for context number ',context.attribute['number'] ,'  ' ,result
            continue
        business['reviews'] = result['reviews']
        time.sleep(3)
    print 'got the context', ' ', context.attribute['number']
    fh = open(odir+'/'+context.attribute['number'],'wb')
    json.dump(exbusiness, fh)       
    fh.close()
    
        
    

Beispiel #2
0
    args.append('--token_secret='+tokensecret)
#args.append('--location='+context.attribute['city']+','+context.attribute['state']+',USA')
#    args.append('-p='+pl)
#   args.append('-m='+'1')
#    print pl
    newbusiness = list(exbusiness['businesses'])
    for i in range(0, count):
        business = exbusiness['businesses'][i]
        address = ''
        for adpart in business['location']['display_address']:
            address = address +","+str(adpart)    
      #  pl = lat+','+lng    
        ypargs = list(args)
        ypargs.append('-l='+address)
        print args
        result = yp.main(ypargs)
        if result is None or result.get('businesses') is None:
            print 'cannot get for context number ',context.attribute['number'] ,'  ' ,result
            continue
        for newb in result['businesses']:
            if len(newbusiness) > 250:
                break
            if bid.get(newb['id']) is  None:
                bid[newb['id']] = 1
                newbusiness.append(newb)
        time.sleep(3)
    print 'content number ' , context.attribute['number'], ' got new business places =  ', len(newbusiness)
    exbusiness['businesses'] = newbusiness
    fh = open('/usa/arao/trec/contexttrec12/yelpplaces2/'+context.attribute['number'],'wb')
    json.dump(exbusiness, fh)       
    fh.close()
Beispiel #3
0
import json
from searchpl import yelpsearch as yp
import sys

contextlist = list()
chandler = saxparser.ContextFileHandler(contextlist)
ckey = sys.argv[1]
csecret = sys.argv[2]
token = sys.argv[3]
tokensecret = sys.argv[4]

saxparser.parse("/usa/arao/trec/contexttrec12/contexts.txt", chandler)
for context in contextlist:
    args = []
    args.append("--consumer_key=" + ckey)
    args.append("--consumer_secret=" + csecret)
    args.append("--token=" + token)
    args.append("--token_secret=" + tokensecret)
    lat = str(context.attribute["lat"])
    lng = str(context.attribute["long"])
    pl = lat + "," + lng
    args.append("--location=" + context.attribute["city"] + "," + context.attribute["state"] + ",US")
    # args.append('-p='+pl)
    # args.append('-m='+'1')
    #    print pl
    result = yp.main(args)
    print "content nuber ", context.attribute["number"], " got total places =  ", result.get("total")
    if result.get("total") is not None:
        json.dump(result, open("/usa/arao/trec/contexttrec12/yelpplaces/" + context.attribute["number"], "wb"))
    print result.get("total")
Beispiel #4
0
import sys
contextlist = list()
chandler = saxparser.ContextFileHandler(contextlist)
ckey = sys.argv[1]
csecret = sys.argv[2]
token = sys.argv[3]
tokensecret = sys.argv[4]

saxparser.parse('/usa/arao/trec/contexttrec12/contexts.txt',chandler)
for context in contextlist:
    args = []
    args.append('--consumer_key='+ckey)
    args.append('--consumer_secret='+csecret)
    args.append('--token='+token)
    args.append('--token_secret='+tokensecret)
    lat = str(context.attribute['lat'])
    lng = str(context.attribute['long'])
    pl = lat+','+lng    
    args.append('--location='+context.attribute['city']+','+context.attribute['state']+',US')
    #args.append('-p='+pl)
    #args.append('-m='+'1')
#    print pl
    result = yp.main(args)
    print 'content nuber ' , context.attribute['number'], ' got total places =  ', result.get('total')
    if result.get('total') is not None:
        json.dump(result, open('/usa/arao/trec/contexttrec12/yelpplaces/'+context.attribute['number'],'wb'))       
    print result.get('total')