QuickRank  v2.0
QuickRank: A C++ suite of Learning to Rank algorithms
generate_oblivious.h
Go to the documentation of this file.
1 /*
2  * QuickRank - A C++ suite of Learning to Rank algorithms
3  * Webpage: http://quickrank.isti.cnr.it/
4  * Contact: quickrank@isti.cnr.it
5  *
6  * Unless explicitly acquired and licensed from Licensor under another
7  * license, the contents of this file are subject to the Reciprocal Public
8  * License ("RPL") Version 1.5, or subsequent versions as allowed by the RPL,
9  * and You may not copy or use this file in either source code or executable
10  * form, except in compliance with the terms and conditions of the RPL.
11  *
12  * All software distributed under the RPL is provided strictly on an "AS
13  * IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND
14  * LICENSOR HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
15  * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16  * PURPOSE, QUIET ENJOYMENT, OR NON-INFRINGEMENT. See the RPL for specific
17  * language governing rights and limitations under the RPL.
18  *
19  * Contributor:
20  * HPC. Laboratory - ISTI - CNR - http://hpc.isti.cnr.it/
21  */
22 #pragma once
23 
24 #include <string>
25 #include <memory>
26 #include <fstream>
27 #include <sstream>
28 #include <iomanip>
29 #include <limits>
30 #include <list>
31 #include <iostream>
32 #include <cstring>
33 #include <vector>
34 #include <utils/strutils.h>
35 
36 #include "pugixml/src/pugixml.hpp"
37 
38 namespace quickrank {
39 namespace io {
40 
41 /**
42  * This class is a code generator on QuickRank XML files.
43  *
44  * The XML format is used for loading and storing ranking models.
45  */
46 class GenOblivious {
47  public:
48 
49  /// Generates the C++ implementation of the model scoring function.
50  /// This applies to forests of oblivious trees.
51  ///
52  /// \param model_filename Previously saved XML ranker model.
53  /// \param code_filename Output source code file name.
54  void generate_oblivious_code(const std::string, const std::string);
55 
56  private:
57  void model_tree_get_leaves(pugi::xml_node &, std::vector<std::string> &);
58  void
59  model_tree_get_feature_ids(pugi::xml_node &, std::vector<unsigned int> &);
60  void model_tree_get_thresholds(pugi::xml_node &, std::vector<std::string> &);
61 };
62 
63 } // namespace io
64 } // namespace quickrank
Definition: dataset.cc:28
This class is a code generator on QuickRank XML files.
Definition: generate_oblivious.h:46
void model_tree_get_thresholds(pugi::xml_node &, std::vector< std::string > &)
Definition: generate_oblivious.cc:97
void generate_oblivious_code(const std::string, const std::string)
Generates the C++ implementation of the model scoring function.
Definition: generate_oblivious.cc:130
void model_tree_get_leaves(pugi::xml_node &, std::vector< std::string > &)
Definition: generate_oblivious.cc:32
void model_tree_get_feature_ids(pugi::xml_node &, std::vector< unsigned int > &)
Definition: generate_oblivious.cc:65