private void start(String docFileName, String trainFilename, String testFileName, String outFileName) throws IOException {
        Map<String, Product> productMap = initProducts(docFileName);

        List<Order> orders = readOrders(true, trainFilename);
        OrderHistory history = new OrderHistory(orders);

        indexFromProducts(NAME_RANK, productMap.values());
        indexFromRequests(orders, productMap, history);

        Map<Indexed<Product>, Integer> stats = Maps.newHashMap();
        for (Indexed<Product> doc : search.values()) {
            stats.put(doc, 0);
        }
        for (Order order : orders) {
            Indexed<Product> doc = search.get(order.getSku());
            if (stats.get(doc) != null) {
                stats.put(doc, stats.get(doc) + 1);
            }
        }

        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(outFileName)));
        out.println("sku");

        TfIdfCalculator tfIdfCalculator = new TfIdfCalculator(stats);
        for (Order test : readOrders(false, testFileName)) {
            BagOfWords bag = getBag(test, history);
            List<Product> best = tfIdfCalculator.getBest(bag, test.getRequest().getEntered(), MAP_COUNT);
            out.println(Joiner.on(" ").join(Lists.transform(Lists.newArrayList(best), new Function<Product, String>() {
                public String apply(Product o) {
                    return o.getSku();
                }
            })));
        }
        out.close();
    }