def test_checkingTwoWordedStates(self): self.assertEqual( location_info.extract_location("Washington DC 20022")["Zipcode"], "20022" ) self.assertEqual( location_info.extract_location("Princeton New Jersey 08540")["Zipcode"], "08540", )
def run(self, request, *, outer_task_id): """ returns dictionary with transcription text and keys relating to extracted date and location info. all key values (except transcription text) are None if extraction fails """ text = request.get("text") call_sid = request.get("call_sid") logger.info(f"Extract got text = {text}.") self.update_state(task_id=outer_task_id, state=State.extracting) d = {"trancription": text} date = date_info.extract_date_time(text) d.update(date) location = location_info.extract_location(text) d.update(location) logger.info(f"Date = {date}. Location = {location}") self.update_state(task_id=outer_task_id, state=State.extracting_done) return {"call_sid": call_sid, "data": d}
def test_findsInFullSentence(self): self.assertEqual( location_info.extract_location( "something something happened in Washington 98102" )["Zipcode"], "98102", )
def test_basic(self): self.assertEqual( location_info.extract_location("Washington 98102"), { "State": "WA", "Zipcode": "98102", "City": "Seattle", "Confidence_location": "high", }, )
def test_isNotNone(self): self.assertIsNotNone(location_info.extract_location("Washington 98102"))
def test_lowConfindenceIfNonMatchingZip(self): results_dict = location_info.extract_location("texas 10983") self.assertEqual(results_dict["Confidence_location"], "low") self.assertEqual(results_dict["State"], "TX")
def test_checkCapitalization2(self): self.assertEqual( location_info.extract_location("WASHINGTON 98102")["Zipcode"], "98102" )
def test_checkCapitalization(self): self.assertEqual( location_info.extract_location("washington 98102")["Zipcode"], "98102" )