Пример #1
0
def find_cars_by_document(document_file):
    content = open(document_file).read().decode('cp1251')

    lines = content.split('\n')

    found_cars = []
    for line in lines:
        line = line.strip()
        line = re.sub('\s+', ' ', line)
        if len(line) > 0:
            cars = predict_cars(car_model, line)

            if len(cars) > 0:
                found_cars.extend(cars)
    return found_cars
def find_cars_by_document( document_file ):
    content = open( document_file ).read().decode('cp1251')

    lines = content.split('\n')

    found_cars = []
    for line in lines:
        line = line.strip()
        line = re.sub('\s+', ' ', line)
        if len(line) > 0:
            cars = predict_cars( car_model, line )

            if len(cars) > 0:
                found_cars.extend( cars )
    return found_cars
Пример #3
0
        file_cars = find_cars_by_document(document_file)
        if len(file_cars) > 0:
            found_cars.extend(file_cars)
    found_cars = filter(filter_candidates, found_cars)
    return len(found_cars) > 0, found_cars


data = []

for contract in contracts:
    reg_num = str(contract['regNum'].strip())

    products_names = [prod['name'] for prod in contract['products']['product']]

    for product_name in products_names:
        cars = filter(filter_candidates, predict_cars(car_model, product_name))
        if len(cars) == 0:
            print "Not found car by product", product_name
            if reg_num in available_notifications_for_regnums:

                found_car, found_cars = process_cars_by_documents(reg_num)

                if not found_car:
                    print "Car not found for regnum {0}".format(reg_num)
                else:
                    print "Documentation cars", found_cars[0]
                    contract_id = contract['notif_id']

                    contract_url = "http://clearspending.ru/contract/{0}/".format(
                        reg_num)
        file_cars = find_cars_by_document( document_file )
        if len(file_cars) > 0:
            found_cars.extend( file_cars )
    found_cars = filter(filter_candidates,found_cars)
    return len(found_cars) > 0, found_cars


data = []

for contract in contracts:
    reg_num = str(contract['regNum'].strip())

    products_names = [ prod['name'] for prod in contract['products']['product']    ]

    for product_name in products_names:
        cars = filter(filter_candidates,predict_cars( car_model, product_name ))
        if len(cars) == 0:
            print "Not found car by product", product_name
            if reg_num in available_notifications_for_regnums:

                found_car, found_cars = process_cars_by_documents(reg_num)

                if not found_car:
                    print "Car not found for regnum {0}".format( reg_num )
                else:
                    print "Documentation cars", found_cars[0]
                    contract_id = contract['notif_id']

                    contract_url = "http://clearspending.ru/contract/{0}/".format( reg_num )

                    car_name = found_cars[0]