def resolveLocationUsingUserLocation(self, tweet):
     tweetLocation = Utils.getLocationFromTweet(tweet)
     if tweetLocation:
         var = re.sub("\\p{Punct}", " ", tweetLocation)
         location = re.sub("\\s+", " ", var).lower().strip()
         if self.locationNameToLocation.has_key(location):
             return self.locationNameToLocation[location]
         var = re.sub(
             "[!\\\"#$%&'\\(\\)\\*\\+-\\./:;<=>\\?@\\[\\\\]^_`\\{\\|\\}~]",
             " ", tweetLocation)
         locationWithComma = re.sub("\\s+", " ", var).lower().strip()
         match = re.search(".+,\\s*(\\w+)", locationWithComma)
         if match:
             matchedString = match.group().lower()
             if self.locationNameToLocation.has_key(matchedString):
                 return self.locationNameToLocation[matchedString]
             else:
                 items = matchedString.split(',')
                 if len(items) == 2:
                     state = self.extract_state(items[1].strip())
                     if state:
                         return Location('united states', state,
                                         matchedString.split(',')[0], None,
                                         None, None, -1, False)
                     else:
                         co = self.extract_country(items[1].strip())
                         return Location(co, None, None, None, None, None,
                                         -1, False)
                 else:
                     co = self.extract_country(items[2].strip())
                     if co:
                         state = self.extract_state(items[1].strip())
                         if state:
                             return Location(co, state, items[0].strip(),
                                             None, None, None, -1, False)
                         else:
                             return Location(co, None, None, None, None,
                                             None, -1, False)
                     else:
                         state = self.extract_state(items[2].strip())
                         if state:
                             return Location('united states', state, None,
                                             None, None, None, -1, False)
     return None
 def resolveLocationUsingUserLocation(self, tweet):
     tweetLocation = Utils.getLocationFromTweet(tweet)
     if tweetLocation:
         var = re.sub("\\p{Punct}", " ", tweetLocation)
         location = re.sub("\\s+", " ", var).lower().strip()
         if self.locationNameToLocation.has_key(location):
             return self.locationNameToLocation[location]
         var = re.sub("[!\\\"#$%&'\\(\\)\\*\\+-\\./:;<=>\\?@\\[\\\\]^_`\\{\\|\\}~]", " ", tweetLocation)
         locationWithComma = re.sub("\\s+", " ", var).lower().strip()
         match = re.search(".+,\\s*(\\w+)", locationWithComma)
         if match:
             matchedString = match.group().lower()
             if self.locationNameToLocation.has_key(matchedString):
                 return self.locationNameToLocation[matchedString]
             else:
                 items = matchedString.split(',')
                 if len(items) == 2:
                     state = self.extract_state(items[1].strip())
                     if state:
                         return Location('united states', state, matchedString.split(',')[0], None, None, None, -1, False)
                     else:
                         co = self.extract_country(items[1].strip())
                         return Location(co, None, None, None, None, None, -1, False)
                 else:
                     co = self.extract_country(items[2].strip())
                     if co:
                         state = self.extract_state(items[1].strip())
                         if state:
                             return Location(co, state, items[0].strip(), None, None, None, -1, False)
                         else:
                             return Location(co, None, None, None, None, None, -1, False)
                     else:
                         state = self.extract_state(items[2].strip())
                         if state:
                             return Location('united states', state, None, None, None, None, -1, False)
     return None
 def getLatLngFromTweet(tweet):
     return Utils.geo_check_tweet(tweet)
 def getLatLngFromTweet(tweet):
     return Utils.geo_check_tweet(tweet)