Пример #1
0
def calculate_description_score():
    try:
        json_request = request.json
        description = json_request['description']
        desc_score = algorithm.check_description(description, minmax, clf)

        json_resp = json.dumps({'description': description, 'score': desc_score})
        resp = Response(json_resp, status=200, mimetype='application/json')
        return resp
    except Exception, e:
        return Response(json.dumps({'error': str(e)}), status=500, mimetype='application/json')
Пример #2
0
        address_score = 0
        try:
            address_score, duplicated_address = algorithm.check_address(
                address['state'], address['city'], address['street'],
                json_listing['price'])
        except Exception, e:
            logger.error(
                'Can not parse the address of the listing with id %s.' %
                listing_id)

        score += address_score

        # DESCRIPTION
        # TODO need to modify the description score
        description = json_listing['description']
        desc_score = algorithm.check_description(description, minmax, clf)
        score += (1 - desc_score)

        # get positive and negative words
        positive_words, negative_words = algorithm.get_positive_negative_words(
            description)

        # TODO scale the score to 0-5

        json_resp = json.dumps({
            'listing_id':
            listing_id,
            'score':
            score,
            'avg_price': {
                'price': round(estimated_rent, 2),