import numpy as np

# These are the standard categories for property types
STANDARD_PROPERTY_TYPES = {
    "house", "flat", "maisonette", "bungalow", "park home", "block house", "bedsit", "coach house",
    "unknown", "other", "block of flats"
}

# This is a basic mapping that we use to map values that we've seen commonly to standard values
PROPERTY_MAPPING = {
    "HOUSE": "house",
    "FLAT": "flat",
    "MAISONET": "maisonette",
    "BUNGALOW": "bungalow",
    "BLKHOUS": "block house",
    "blkhous": "block house",
    "BEDSIT": "bedsit",
    "COACHSE": "coach house",
    "coachse": "coach house",
    'Admin Unit Type': 'unknown',
    'Block': 'block of flats',
    'Bungalow': 'bungalow',
    'Flat': 'flat',
    'House': 'house',
    'Maisonette': 'maisonette',
    'Stairwell': 'other',
    'MAISON': 'maisonette',
    '3 Bed Semi Detached House': 'house',
    '3 Bed Mid Terrace House': 'house',
    '2 Bed Semi Detached House': 'house',
    '4 Bed Semi Detached House': 'house',
    '2 Bed End Terrace House': 'house',
    '1 Bed Sheltered Bungalow': 'bungalow',
    '1 Bed 1st Floor Sheltered Flat': 'flat',
    '2 Bed Second Floor Flat': 'flat',
    '1 Bed Mid Terrace House': 'house',
    '1 Bed End Terrace House': 'house',
    '7 Bed Detached House': 'house',
    '4 Bed End Terrace House': 'house',
    '1 Bed Link House': 'house',
    '1 Bed Second Floor Flat': 'flat',
    '2 Bed Detached House': 'house',
    '1 Bed Ground Floor Flat': 'flat',
    '2 Bed Sheltered Bungalow': 'bungalow',
    '4 Bed Mid Terrace House': 'house',
    '2 Bed Mid Terrace House': 'house',
    '2 Bed First Floor Flat': 'flat',
    '3 Bed Detached House': 'house',
    'Ground Floor Bedsit': 'bedsit',
    '3 Bed Bungalow': 'bungalow',
    np.nan: 'unknown',
    '5 Bed End Terrace House': 'house',
    '1 Bed Grd Floor Sheltered Flat': 'flat',
    '3 Bed End Terrace House': 'house',
    '2 Bed Second Floor Maisonette': 'maisonette',
    '2 Bed Ground Floor Flat': 'flat',
    '2 Bed First Floor Maisonette': 'maisonette',
    '4 Bed Detached House': 'house',
    '1 Bed Bungalow': 'bungalow',
    '2 Bed Bungalow': 'bungalow',
    'First Floor Bedsit': 'bedsit',
    '3 Bed First Floor Maisonette': 'maisonette',
    '2 Bed 1st Floor Sheltered Flat': 'flat',
    '1 Bed First Floor Flat': 'flat',
    '3 Bed First Floor Flat': 'flat',
    'ND': 'unknown',
    'House (Mid Terrace)': 'house',
    'First Floor Flat General': 'flat',
    'House (End Terrace)': 'house',
    'House (Mid terrace)': 'house',
    'Bungalow (Semi)': 'bungalow',
    'Ground Floor Flat General': 'flat',
    'House (Semi)': 'house',
    'Detached House': 'house',
    'Bedsit': 'bedsit',
    'Terraced House': 'house',
    'Standard Maisonette': 'maisonette',
    'End Terraced House': 'house',
    'Third Floor Flat or Above': 'flat',
    'Town House': 'house',
    'Mid Terraced House': 'house',
    'Back To Back House': 'house',
    'Flat Basement': 'flat',
    'Ground Floor Flat': 'flat',
    'Semi Detached House': 'house',
    'Second Floor Flat': 'flat',
    'First Floor Flat': 'flat',
    'Level not confirmed': 'flat',
    'Cottage': 'house',
    'Studio (1st Floor)': 'flat',
    'Studio (Ground floor)': 'flat',
    'Guest room in a complex': 'other',
    'PIMSS EMPTY': 'bedsit',
    'Room Only': 'other',
    'Detached Property': 'house',
    'End Terrace Housex': 'house',
    'Coach House': 'coach house',
    'Mid Terrace Bungalow': 'bungalow',
    'End Terrace Bungalow': 'bungalow',
    'Mid Terrace House': 'house',
    'Detached Bungalow': 'bungalow',
    'End Terrace House': 'house',
    'Mid Terrace Housekeeping ': 'house',
    'Maisonnette': 'maisonette',
    'Guest Room': 'unknown',
    'Office Buildings': 'unknown',
    'Semi Detached Bung': 'bungalow',
    'Bedspace': 'bedsit',
    'Houses/Bungalows': 'bungalow',
    'Bedsits': 'bedsit',
    'Unknown': 'unknown',
    'Sheltered Flats/besits': 'flat',
    'House/Bungalow  ': 'bungalow',
    'Low/Med Rise Flats/Mais': 'flat',
    'Staff/Comm': 'other',
    'A Rooms': 'other',
    'Studio (3rd floor and above)': 'flat',
    'Adapted Property For Disabled': 'unknown',
    'Studio (2nd floor)': 'flat',
    'Third Floor Flat': 'flat',
    '2 Ext. Wall Flat': 'flat',
    'Hostel': 'other',
    'House: MidTerrace': 'house',
    'House: EndTerrace': 'house',
    'Flat: Mid Terrace: Mid Floor': 'flat',
    'Bungalow: SemiDetached': 'bungalow',
    'Bungalow: EndTerrace': 'bungalow',
    'Flat: End Terrace: Top Floor': 'flat',
    'Maisonette: End Terrace: Ground Floor': 'maisonette',
    'Flat: End Terrace: Ground Floor': 'flat',
    'Flat: Mid Terrace: Top Floor': 'flat',
    'House: Detached': 'house',
    'Flat: End Terrace: Mid Floor': 'flat',
    'House: SemiDetached': 'house',
    'Flat: Semi Detached: Ground Floor': 'flat',
    'Flat: Semi Detached: Top Floor': 'flat',
    'Flat: Mid Terrace: Ground Floor': 'flat',
    'Bungalow: MidTerrace': 'bungalow',
    'Flat: Enclosed End Terrace: Top Floor': 'flat',
    'Flat: Semi Detached: Mid Floor': 'flat',
    'Maisonette: Mid Terrace: Top Floor': 'maisonette',
    'House: EnclosedEndTerrace': 'house',
    'Flat: Detached: Ground Floor': 'flat',
    'Flat: Detached: Mid Floor': 'flat',
    'Flat: Detached: Top Floor': 'flat',
    'Bungalow: Detached': 'bungalow',
    'Maisonette: End Terrace: Mid Floor': 'maisonette',
    'Maisonette: Detached: Top Floor': 'maisonette',
    'Flat: Enclosed Mid Terrace: Mid Floor': 'flat',
    'Flat: Enclosed Mid Terrace: Ground Floor': 'flat',
    'Flat: Enclosed End Terrace: Mid Floor': 'flat',
    'Flat: Enclosed End Terrace: Ground Floor': 'flat',
    'Flat: Enclosed Mid Terrace: Top Floor': 'flat',
    '2013 onwards': 'unknown',

    'House 2 Storey': 'house',
    'Bung': 'bungalow',
    'House 3 Storey': 'house',
    'Shared Flat': 'flat',
    'd': 'unknown',
    'Mais': 'maisonette',
    'e': 'unknown',
    'Shared House': 'house',
    'House 4 Storey': 'house',
    'Shared Bungalow': 'bungalow',
    'Detch': 'house',
    'Shop': 'other',
    'Terr': 'house',
    'Terrace': 'house',
    'Description': 'unknown',
    'Hse': 'house',
    'Room': 'other',
    'Office': 'other',
    'Room In Shared Accommodation': 'other',
    'Apartment': 'flat',
    'm': 'unknown',
    'Garage': 'other',
    'Parking Space': 'other',
    'Community Centre': 'other',
    'Communal Facility': 'other',
    'Semi': 'house',
    'House with Compulsory Garage': 'house',
    'Flat with Compulsory Garage': 'flat',
    'Other': 'other',
    'Maisonette with Compulsory Garage': 'maisonette',
    'Room in Shared Property': 'other',
    'Bungalow Mid Terrace': 'bungalow',
    '4 Ext. Wall Flat': 'flat',
    '3 Ext. Wall Flat': 'flat',
    'Bungalow End Terrace': 'bungalow',
    '6 Ext. Wall Flat': 'flat',
    'Bungalow Detached': 'bungalow',
    'Maisonette 3 Ext. Wall': 'maisonette',
    'Maisonette 2 Ext. Wall': 'maisonette',
    '5 Ext. Wall Flat': 'flat',
    'Bungalow Semi Detached': 'bungalow',
    'COMINT': 'unknown',
    '12 SBEDSIT': 'bedsit',
    '01 HOUSE': 'house',
    '05 BEDSIT': 'bedsit',
    '14 SFLAT': 'flat',
    '09 PBEDSIT': 'bedsit',
    '10 PBUNGALOW': 'bungalow',
    '13 SBUNGALOW': 'bungalow',
    '11 PFLAT': 'flat',
    '02 FLAT': 'flat',
    '04 MAISONETTE': 'maisonette',
    '01 HOUSE MID': 'house',
    '03 BUNGALOW': 'bungalow',
    'Flat?': 'flat',
    'Bungalow ET': 'bungalow',
    'House. SD': 'house',
    'Bungalow SD': 'bungalow',
    'Bungalow D': 'bungalow',
    'House D': 'house',
    'House SD': 'house',
    'House ET': 'house',
    'Bungalow MT': 'bungalow',
    'House MT': 'house',
    'House. MT': 'house',
    '': 'unknown',
    'GROUND FLOOR BEDSIT': 'bedsit',
    'HOUSE 1 LIVING ROOM': 'house',
    'MAISONETTE OVER SHOP': 'maisonette',
    'GROUND FLOOR FLAT': 'flat',
    'SECOND FLOOR FLAT': 'flat',
    'FIRST FLOOR FLAT': 'flat',
    'GROUND FL MAISONETTE': 'maisonette',
    'HOUSE 2 LIVING ROOMS': 'house',
    'FLAT OVER SHOP': 'flat',
    'House With Integral Garage': 'house',
    'Flat Over Parking/Accessway': 'flat',
    'Flat Over Binstore': 'flat',
    'Flat Over Garage': 'flat',
    'House With Independent Garage': 'house',
    'Studio': 'flat',
    'Bedsit bungalow terraced': 'bedsit',
    'Terraced house': 'house',
    'Sheltered flat': 'flat',
    'APD Bungalow': 'bungalow',
    'Flat with partition': 'flat',
    'Bungalow detached': 'bungalow',
    'APD flat': 'flat',
    'Sheltered warden flat': 'flat',
    'Bungalow semi detached': 'bungalow',
    'Sheltered bedsit': 'bedsit',
    'Sheltered bungalow terraced': 'bungalow',
    'Sheltered bungalow semi detached': 'bungalow',
    'Bungalow terraced': 'bungalow',
    'Maisonette flat': 'maisonette',
    'Sheltered bedsit disabled': 'bedsit',
    'Bedsit bungalow semi detached': 'bedsit',
    'Bedsit Flat': 'bedsit',
    'Semi detached house': 'house',
    'Unit': 'unknown',
    'HOUSE (3 STOREY)': 'house',
    'FLAT GROUND FLOOR': 'flat',
    'FLAT TOP FLOOR': 'flat',
    'SHARED HOUSE': 'house',
    'MAISONETTE': 'maisonette',
    'DIRECT ACCESS HOSTEL': 'other',
    'Day centre': 'other',
    'Care home': 'other',
    'BLOCK (Communal)': 'block of flats',
    'SHOP': 'other',
    'Office Block': 'other',
    'BLOCK (Non-Communal)': 'block of flats',
    'Refuge': 'other',
    None: 'unknown',
    'HFOP FLAT': 'flat',
    'HFOP BEDSIT': 'bedsit',
    'LINKED FLAT': 'flat',
    'LINKED BUNGALOW': 'bungalow',

    'Semi Detached Bungalow': 'bungalow',
    'End Terraced Bungalow': 'bungalow',
    'Mid Terraced Town House': 'house',
    'Cottage Flat': 'flat',
    'Semi-Detached House': 'house',
    'Low Rise Flat': 'flat',
    'Mid Terraced Bungalow': 'bungalow',
    'Maisonette Over Shop': 'maisonette',
    'Flat Over Shop': 'flat',
    'Medium Rise Flat': 'flat',
    'End Terraced Town House': 'house',
    'Maisonette Medium Rise': 'maisonette',

    'Semi bungalow': 'bungalow',
    '2nd floor flat': 'flat',
    'End terrace bungalow': 'bungalow',
    'End terrace house': 'house',
    'Ground floor bedsit': 'bedsit',
    'Detached bungalow': 'bungalow',
    'Semi house': 'house',
    '2nd floor flat with study': 'flat',
    '1st floor flat with study room': 'flat',
    'Lower ground floor flat': 'flat',
    'Cluster House': 'house',
    'Mid terrace bungalow': 'bungalow',
    'Mid terrace house': 'house',
    'Basement bedsit': 'bedsit',
    'Detached house': 'house',
    '3rd floor flat': 'flat',
    '4th floor flat': 'flat',
    'Dormer bungalow': 'bungalow',
    '1st floor flat': 'flat',
    'Ground floor flat': 'flat',
    'Ground floor flat with study': 'flat',
    'Basement flat': 'flat',
    '2nd floor bedsit': 'bedsit',
    '1st floor bedsit': 'bedsit',
    '2nd/3rd floor duplex flat': 'flat',
    'Ground floor study bedroom': 'other',
    'General/Communal': 'other',
    'Utility pod': 'other',
    '2nd floor study bedroom': 'other',
    '1st floor study bedroom': 'other',
    'Block property': 'block of flats',
    'Utility pod - DDA compliant': 'other',

    'Bungalow - Detached': 'bungalow',
    'Maisonette - Detached': 'maisonette',
    'Bedsit - Mid Terrace': 'bedsit',
    'Studio Flat': 'flat',
    'House - End Terrace': 'house',
    'House - Mid Terrace': 'house',
    'Bungalow - End Terrace': 'bungalow',
    'Bungalow - Attached': 'bungalow',
    'Maisonette - End Terrace': 'maisonette',
    'Maisonette - Semi Detached': 'maisonette',
    'House - Detached': 'house',
    'Bedsit - End Terrace': 'bedsit',
    'House - Semi detached': 'house',
    'Studio Flat - Mid Terrace': 'flat',
    'Bungalow - Semi detached': 'bungalow',
    'Bungalow - Mid Terrace': 'bungalow',
    'Maisonette - Mid Terrace': 'maisonette',
    'Chalet - Wheelchair': 'other',
    'Amenity Block - Detached': 'other',
    'Amenity Block - Semi detached': 'other',
    'house': 'house',
    'block of flats': 'block of flats',
    'bungalow': 'bungalow',
    'flat': 'flat',
    'FLA': 'flat',
    'HOU': 'house',

    'Maisonette: Mid Terrace: Mid Floor': 'maisonette',
    'Maisonette: Semi Detached: Ground Floor': 'maisonette',
    'Maisonette: Enclosed Mid Terrace: Ground Floor': 'maisonette',
    'Maisonette: Enclosed End Terrace: Ground Floor': 'maisonette',
    'Maisonette: Mid Terrace: Ground Floor': 'maisonette',
    'Flat: Semi Detached: Basement': 'flat',
    'Maisonette: Semi Detached: Top Floor': 'maisonette',
    'Maisonette: Enclosed Mid Terrace: Mid Floor': 'maisonette',
    'Flat: Detached: Basement': 'flat',
    'Maisonette: Enclosed Mid Terrace: Top Floor': 'maisonette',

    'Maisonette: End Terrace: Top Floor': 'maisonette',
    'House: Mid Terrace: Ground Floor': 'house',
    'Bungalow: EnclosedMidTerrace': 'bungalow',
    'Maisonette: Semi Detached: Mid Floor': 'maisonette',
    'Maisonette: Detached: Mid Floor': 'maisonette',

    'House: EnclosedMidTerrace': 'house',

    '3 EXT WALL FLAT': 'flat',
    '1st FLOOR FLAT': 'flat',
    '3 Ext wall flat': 'flat',
    '3 EX WALL FLAT': 'flat',
    'END TERRACE HOUSE': 'house',
    'BUNGALOW-END TERRACE': 'bungalow',
    'BUNGALOW END TERRACE': 'bungalow',
    '2 ext wall flats': 'flat',
    'Mid flat Ground Floor': 'flat',
    '3.EXT.WALL FLAT': 'flat',
    'FLAT 3 WALLS': 'flat',
    'Mid Terrace bungalow': 'bungalow',
    'Bungalow ENd Terrace': 'bungalow',
    '2 Ext Wall flat': 'flat',
    'DETATCHED HOUSE': 'house',
    'Bungalow Semi detached': 'bungalow',
    'BUNGALOW - SEMI DETACHED': 'bungalow',
    'Bungalow mid terrace': 'bungalow',
    'BUNGALOW - MID TERRACED': 'bungalow',
    'BUNGALOW - MID TERRACE': 'bungalow',
    'Bungalow end terrace': 'bungalow',
    '3 EXT. WALL FLAT': 'flat',
    '3 ext wall flat': 'flat',
    'BUNGALOW SEMI-DETACHED': 'bungalow',
    '3 EXT-WALL FLAT': 'flat',
    'Bungalow - mid terrace': 'bungalow',
    'SEMI DETACHED BUNGALOW': 'bungalow',
    'FLAT 2 WALLS': 'flat',
    'MID TERRACE HOUSE': 'house',
    '3 EX WALL MAISONETTE': 'maisonette',
    'BUNGALOW-SEMI DETACHED': 'bungalow',
    '3 Ext Wall Flat': 'flat',
    'Semi Bungalow': 'bungalow',
    'End-Terrace house': 'house',
    'BUNGALOW MID TERRACE': 'bungalow',
    'Mid-terrace house': 'house',
    'SEMI DETACHED HOUSE': 'house',
    'Semi-detached house': 'house',
    '2 EXT WALL FLAT': 'flat',
    '2.EXT.WALL FLAT': 'flat',
    'BUNGALOW SEMI DETACHED': 'bungalow',
    '2 EXT. WALL FLAT': 'flat',
    'END-TERRACE': 'unknown',
    'SEMI DETACHED': 'unknown',
    '2 EXT WALLS': 'unknown',
    'MID TERRACED': 'unknown',
    'BUNGLAOW SEMI DETACHED': 'bungalow',
    'END TERRACE': 'unknown',
    '3 EXT WALLS': 'unknown',
    'Mid Terrace': 'unknown',
    '3 EXT WALL - NOW 2 EXT': 'unknown',
    'MID TERR': 'unknown',
    'DETACHED': 'unknown',
    'MID-TERRACE': 'unknown',
    'Bunagalow Semi Detached': 'bungalow',
    'End-terrace': 'unknown',
    'END - TERRACE': 'unknown',
    'SEMI-DETACHED': 'unknown',
    'Semi-Detached': 'unknown',
    'MID TERRACE': 'unknown',
    'End Terrace': 'unknown',
    'Detached': 'unknown',
    'Mid-terrace': 'unknown',
    'MID - TERRACE': 'unknown',
    'COMOFF': 'unknown',
    'LOTS': 'unknown',

    'Maisonette: Detached: Ground Floor': 'maisonette',
    'Maisonette: Enclosed End Terrace: Top Floor': 'maisonette',
    'Flat: End Terrace: Basement': 'flat',
    'Bungalow: EnclosedEndTerrace': 'bungalow',
    'Flat: Mid Terrace: Basement': 'flat',
    'House: Semi Detached: Top Floor': 'house',
    'House: End Terrace: Ground Floor': 'house',
    'Maisonette: Enclosed End Terrace: Mid Floor': 'maisonette',
    'Flat: Enclosed Mid Terrace: Basement': 'flat',

    'Warden Bungalow': 'bungalow',
    'Warden Flat': 'flat',
    'Upper Floor Flat': 'flat',
    'Extracare Scheme': 'other',

    'SHELTERED': 'unknown',
    'PARLOUR': 'unknown',

}
