Reranker Framework (ReFr)
Reranking framework for structure prediction and discriminative language modeling
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
executive-feature-extractor.H
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 //
37 
38 #ifndef RERANKER_EXECUTIVE_FEATURE_EXTRACTOR_H_
39 #define RERANKER_EXECUTIVE_FEATURE_EXTRACTOR_H_
40 
41 #include <iostream>
42 #include <string>
43 #include <memory>
44 #include <vector>
45 
46 #include "candidate.H"
47 #include "candidate-set.H"
48 #include "feature-extractor.H"
49 #include "tokenizer.H"
50 
51 namespace reranker {
52 
53 using std::istream;
54 using std::string;
55 using std::shared_ptr;
56 using std::vector;
57 
67  public:
72 
77  static shared_ptr<ExecutiveFeatureExtractor> InitFromSpec(
78  const string &filename);
79 
84  virtual void Reset() const = 0;
85 
90  virtual void Extract(CandidateSet &candidate_set) const = 0;
91 };
92 
93 #define REGISTER_NAMED_EXECUTIVE_FEATURE_EXTRACTOR(TYPE,NAME) \
94  REGISTER_NAMED(TYPE,NAME,ExecutiveFeatureExtractor)
95 
96 #define REGISTER_EXECUTIVE_FEATURE_EXTRACTOR(TYPE) \
97  REGISTER_NAMED_EXECUTIVE_FEATURE_EXTRACTOR(TYPE,TYPE)
98 
100  virtual void RegisterInitializers(Initializers &initializers) {
101  initializers.Add("extractors", &extractors_);
102  }
103  virtual void Reset() const;
104  virtual void Extract(CandidateSet &candidate_set) const;
105  private:
106  // data members
108  vector<shared_ptr<FeatureExtractor> > extractors_;
109 };
110 
111 } // namespace reranker
112 
113 #endif
Provides the reranker::Candidate class for representing a candidate hypothesis from an initial model...
Provides the reranker::FeatureExtractor interface.
virtual ~ExecutiveFeatureExtractor()
Destroys this instance.
ExecutiveFeatureExtractor()
Constructs a new intance.
Provides the Tokenizer class.
virtual void Reset() const =0
Indictes to this instance that iteration has been reset.
virtual void Extract(CandidateSet &candidate_set) const =0
Extracts features for the specified CandidateSet using the suite of FeatureExtractor instances specif...
void Add(const string &name, T *member, bool required=false)
Definition: factory.H:225
This class is like a regular FeatureExtractor, but has been promoted to the executive level and thus ...
A class to hold a set of candidates, either for training or test.
Definition: candidate-set.H:62
static shared_ptr< ExecutiveFeatureExtractor > InitFromSpec(const string &filename)
A convenience factory method that uses an internal Factory<ExecutiveFeatureExtractor> instance to con...
An interface to make it easier to implement Factory-constructible types by implementing both required...
Definition: factory.H:382
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.
A container for all the member initializers for a particular Factory-constructible instance...
Definition: factory.H:203