Reranker Framework (ReFr)
Reranking framework for structure prediction and discriminative language modeling
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
candidate-set-proto-reader-test.C
Go to the documentation of this file.
1 // Copyright 2012, Google Inc.
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met:
7 //
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above
11 // copyright notice, this list of conditions and the following disclaimer
12 // in the documentation and/or other materials provided with the
13 // distribution.
14 // * Neither the name of Google Inc. nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 // -----------------------------------------------------------------------------
30 //
31 //
35 
36 #include <iostream>
37 
38 #include "candidate.H"
39 #include "candidate-set.H"
41 #include "../proto/data.pb.h"
42 #include "../proto/dataio.h"
43 
44 using namespace reranker;
45 using namespace std;
46 
47 #define DEBUG 1
48 
49 int main(int argc, char **argv) {
51  ConfusionProtoIO* reader = NULL;
52  bool is_compressed = true;
53  bool use_base64 = true;
54  if (argc >= 2) {
55  reader = new ConfusionProtoIO(argv[1], ConfusionProtoIO::READ,
56  is_compressed, use_base64);
57  } else {
58  reader = new ConfusionProtoIO("", ConfusionProtoIO::READSTD,
59  is_compressed, use_base64);
60  }
61  bool reader_valid = true;
62  while (reader_valid) {
63  confusion_learning::CandidateSetMessage tmp_msg;
64  reader_valid = reader->Read(&tmp_msg);
65  if (DEBUG) {
66  if (reader_valid) {
67  cout << "Data: " << tmp_msg.Utf8DebugString();
68  }
69  }
70  CandidateSet candidate_set;
71  cspr.Read(tmp_msg, 5, candidate_set);
72  cout << candidate_set;
73  break;
74  }
75  reader->Close();
76  delete reader;
77 }
void Read(const CandidateSetMessage &m, CandidateSet &set)
Fills in the specified CandidateSet based on the specified CandidateSetMessage, crucially constructin...
Provides the reranker::Candidate class for representing a candidate hypothesis from an initial model...
int main(int argc, char **argv)
A class to hold a set of candidates, either for training or test.
Definition: candidate-set.H:62
Reads CandidateSetMessage instances and converts them to reranker::CandidateSet instances.
A class to fill in a CandidateSet based on a CandidateSetMessage, crucially constructing new Candidat...
Class to hold a single training instance for a reranker, which is a set of examples, typically the n-best output of some input process, posibly including a gold-standard feature vector.