示例#1
0
    def populateRoomSize(self, property: Property):
        sp = property.characteristics.split('-')
        for s in sp:
            if s is not None:
                s = str(s)
                if 'br' in s:
                    rooms = s.replace('br', '').strip()
                    property.setRooms(rooms)
                    property.setUpdate()
                elif 'ft_sq' in s:
                    size = s.replace('ft_sq', '').strip()
                    property.setSize(size)
                    property.setUpdate()

        return property
示例#2
0
    def tryGetSizeFromDescription(self, property: Property):

        desc = str(property.characteristics).lower() + ' ' + str(
            property.title).lower() + ' ' + str(
                property.description).lower()  # parse the texto to lowercase
        words = desc.split(' ')
        for i in range(0, len(words)):

            # check for a split pattern in text and apply algorithm to identify the number
            if words[i] in [
                    'square', 'sqft', 'sq.', 'sqt', 'sqf', 'sqft)', 'sq.ft.',
                    'sqft.', 'sq', 'sqft,', 'sf', 'sq.ft', 'sq.ft.,', 'sqft).',
                    'sq/ft', 'sq.ft'
            ]:
                lw = str(words[i - 1]).strip().replace('+',
                                                       '').replace(',', '')
                r = -1
                try:
                    r = int(lw)
                except:
                    r = -1
                if r == -1:
                    try:
                        r = float(lw)
                    except:
                        r = -1
                if r >= 100:
                    property.setSize(r)
                    property.setUpdate()
                    return property

            if words[i] in ['sq/ft:', 'footage:']:
                lw = str(words[i + 1]).strip().replace('+',
                                                       '').replace(',', '')
                r = -1
                try:
                    r = int(lw)
                except:
                    r = -1
                if r == -1:
                    try:
                        r = float(lw)
                    except:
                        r = -1
                if r >= 100:
                    property.setSize(r)
                    property.setUpdate()
                    return property

        find = re.search("\d{1,5}.sq", desc)
        if not find:
            find = re.search("\d{1,5}.ft", desc)
        if find:
            size = str(find.group()).replace('sq', '').replace('ft',
                                                               '').strip()
            r = -1
            try:
                r = float(size)
                if r >= 100:
                    property.setSize(r)
                    property.setUpdate()
                    return property

            except:
                r = -1

        return property