def crossCheck(thisone, thatone): err = [thisone,thatone] for word in ['&',' AND ',' ST. ',' ST ',' STREET ',' AVE ',' AVE. ',' AVENUE ','@']: thisone[1] = thisone[1].replace(word,'') thatone[1] = thatone[1].replace(word,'') thisAddNum = thisone[1].split(' ')[0] thatAddNum = thatone[1].split(' ')[0] if getPercentDiff(thisone[1], thatone[1]) >= 0.69 and thisone[2] == thatone[2] and thisone[3] == thatone[3]: if thisAddNum.isdigit() and thatAddNum.isdigit() and abs(int(thisAddNum) - int(thatAddNum)) < 10: return True else: return False else: return False
yelpURL = getYelpURL(cgRestName,cgLat,cgLon).encode('ascii','ignore') yelpData = json.load(urllib2.urlopen(yelpURL)) #print str(yelpData)[:100] if len(yelpData['businesses']) > 0: yelpRevCount = yelp(yelpData,'review_count') cgAddress = unicode(soup.street.string) cgPhone = unicode(soup.phone_number.string) yelpRestName = unicode(yelp(yelpData,'name')) yelpAddress = unicode(yelp(yelpData,'address1')) yelpPhone = unicode(yelp(yelpData,'phone')) yelpLat = unicode(yelp(yelpData,'latitude')) yelpLon = unicode(yelp(yelpData,'longitude')) info = [['CityGrid',cgRestName,cgAddress,cgPhone,cgLat,cgLon],['Yelp',yelpRestName,yelpAddress,yelpPhone,yelpLat,yelpLon]] try: print cgAddress + ' ' + yelpAddress + ' ' + str(getPercentDiff(cgAddress.upper(),yelpAddress.upper())) except: pass try: print cgRestName + ' ' + yelpRestName + ' ' + str(getPercentDiff(cgRestName.upper(),yelpRestName.upper())) except: pass try: print cgPhone + ' ' + yelpPhone except: pass if getPercentDiff(cgAddress.upper(),yelpAddress.upper()) >= 0.6 or (cgPhone == yelpPhone and yelpLat[:8] == cgLat[:8] and yelpLon[:9] == cgLon[:9]): if getPercentDiff(cgRestName.upper(),yelpRestName.upper()) >= 0.6: #soup.location.name = 'YELPED' #when yelp values added location id changed to YELPED #soup.user_review_count.string = str(cityRevCount + yelpRevCount)