def get(self): args = parser.parse_args() request = args['request'] request_type = args['request_type'] results = nlp.parse(request) if request_type == "General": return general.call(results) elif request_type == "Apartments": return apartments.call(results)
def testHasGym(self): api = parse("Show me all buildings in Richmond, Virginia that have a local gym") has_fitness_center = api.get('has_fitness_center') self.assertTrue(has_fitness_center)
def test_max_sqft_1(self): api = parse("Show me all apartments that are under 60,000 sqft") max_sqft = api.get("max_sqft") self.assertEqual(max_sqft, '60000')
def testStateFullName(self): api = parse("Show me all the apartments in Richmond, Virginia.") self.assertEqual(api['state'], "Virginia")
def test_min_sqft_4(self): api = parse("Show all apartments that are greater than 2,000 sqft in Richmond") self.assertEqual(api['min_sqft'], '2000')
def testZipCodeNoState(self): api = parse("List apartments in the 23269 area") self.assertEqual(api['zip_code'], '23269')
def testZipCodeAfterState(self): api = parse("Show me everything in Richmond, Virginia 23221.") self.assertEqual(api['zip_code'], '23221')
def testHasLaundryFacilitiesIndirectlyStated_2(self): api = parse("Show me all apartments in Richmond, Virginia that have a washer and dryer") has_laundry_facilities = api.get('has_laundry_facilities') self.assertEqual(has_laundry_facilities, True)
def testDoesNotHaveAirConditioning(self): api = parse("Show me all buildings in Richmond, Virginia that does not have air conditioning") has_air_conditioning = api.get("has_air_conditioning") self.assertFalse(has_air_conditioning)
def testHasAirConditioning(self): api = parse("Show me all buildings in Richmond, Virginia that have air conditioning") has_air_conditioning = api.get("has_air_conditioning") self.assertTrue(has_air_conditioning)
def testDishWasherIndirectlyStated(self): api = parse("Show me all apartments in Richmond, Virginia that have a dish cleaner") has_dishwasher = api.get('has_dishwasher') self.assertTrue(has_dishwasher)
def testDoesNotHaveDishwasher(self): api = parse("Show me all buildings in Richmond, Virginia that do not have a dishwasher") has_dishwasher = api.get('has_dishwasher') self.assertFalse(has_dishwasher)
def testHasDishwasher(self): api = parse("Show me all buildings in Richmond, Virginia that have a dishwasher") has_dishwasher = api.get('has_dishwasher') self.assertTrue(has_dishwasher)
def test_has_wheelchair_access_3(self): api = parse("Show me all buildings in Richmond, Virginia that have handicap access") has_wheelchair_access = api.get('has_wheelchair_access') self.assertTrue(has_wheelchair_access)
def testDoesNotHaveWheelChairAccess(self): api = parse("Show me all buildings in Richmond, Virginia that do not have wheelchair access") has_wheelchair_access = api.get('has_wheelchair_access') self.assertFalse(has_wheelchair_access)
def testCityNotInCityList(self): api = parse("Show me all the 3 bedrooms in New York City, New York") with self.assertRaises(KeyError): city = api["city"]
def testDoesNotHaveLaundryFacilities(self): api = parse("Show me all apartments in Richmond, Virginia that do not have laundry facilities") has_laundry_facilities = api.get('has_laundry_facilities') self.assertEqual(has_laundry_facilities, False)
def testStateAbbreviation(self): api = parse("What rental property is in Charleston, SC.") self.assertEqual(api["city"], "Charleston")
def testSameCityAsState(self): api = parse("Show me all the 3 bedrooms in New York, New York") self.assertEqual(api["city"], "New York")
def testAirConditioningIndirectlyStated(self): api = parse("Show me all apartments in Richmond, Virginia that have heating and cooling") has_air_conditioning = api.get("has_air_conditioning") self.assertTrue(has_air_conditioning)
def testZipCodeByItself(self): api = parse("List houses in the 23269 area code of Richmond.") self.assertEqual(api['zip_code'], '23269')
def testHasParking(self): api = parse("Show me all buildings in Richmond, Virginia that have parking") has_parking = api.get("has_parking") self.assertTrue(has_parking)
def test_min_sqft_1(self): api = parse("Show all 2,000 feet apartments") self.assertEqual(api['min_sqft'], '2000')
def testDoesNotHaveParking(self): api = parse("Show me all buildings in Richmond, Virginia that do not have parking") has_parking = api.get("has_parking") self.assertFalse(has_parking)
def test_min_sqft_7(self): api = parse("List apartments with at greater than 1,000 ft") self.assertEqual(api['min_sqft'], '1000')
def testHasParkingIndirectlyStated(self): api = parse("Show me all apartments in Richmond, Virginia that have a parking garage") has_parking = api.get("has_parking") self.assertTrue(has_parking)
def test_min_sqft_8(self): api = parse("Show me all apartments that are at least 50,000 sqft and under 60,000 sqft") self.assertEqual(api['min_sqft'], '50000')
def testIsNotFurnished(self): api = parse("Show me all buildings in Richmond, Virginia that are not furnished") is_furnished = api.get("is_furnished") self.assertFalse(is_furnished)
def testIsFurnishedIndirectlyStated(self): api = parse("Show me all apartments in Richmond, Virginia that already have furniture") is_furnished = api.get("is_furnished") self.assertTrue(is_furnished)
def testDoesNotHaveFitnessCenter(self): api = parse("Show me all buildings in Richmond, Virginia that do not have a fitness center nearby") has_fitness_center = api.get('has_fitness_center') self.assertFalse(has_fitness_center)