Cambridge SMT System
task.loadwordmap.hpp
Go to the documentation of this file.
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use these files except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12 
13 // Copyright 2012 - Gonzalo Iglesias, AdriĆ  de Gispert, William Byrne
14 
15 #ifndef TASK_LOADWORDMAP_HPP
16 #define TASK_LOADWORDMAP_HPP
17 
25 namespace ucam {
26 namespace fsttools {
27 
29 template <class Data >
31  private:
33  const std::string key_;
34 
36  boost::scoped_ptr< ucam::util::WordMapper > wm_;
37 
38  public:
39 
42  const std::string& key ,
43  bool reverse = false ) {
44  if ( rg.exists ( key ) )
45  if ( rg.get<std::string> ( key ) != "" ) return new LoadWordMapTask ( rg, key,
46  reverse );
47  return NULL;
48  }
51  const std::string& key ,
52  bool reverse = false ) :
53  key_ ( key ),
54  wm_ ( new ucam::util::WordMapper ( rg.get<std::string> ( key ), reverse ) ) {
55  LINFO ( "LoadWordMapTask key=" << key << ", Done!" );
56  };
57 
59  bool run ( Data& d ) {
60  if (wm_ != NULL ) {
61  LINFO ( "wordmap available in data object under key=" << key_ );
62  d.wm[key_] = wm_.get();
63  } else {
64  LINFO ( "Wordmap available");
65  }
66  return false;
67  };
68 
69  private:
70  ZDISALLOW_COPY_AND_ASSIGN ( LoadWordMapTask );
71 
72 };
73 
74 }
75 } // End namespaces
76 #endif
bool run(Data &d)
Delivers pointer to wordmap.
#define LINFO(msg)
static LoadWordMapTask * init(const ucam::util::RegistryPO &rg, const std::string &key, bool reverse=false)
Static constructor, will return NULL if there is no need for word-mapping.
T get(const std::string &key) const
Returns parsed value associated to key.
Definition: registrypo.hpp:194
Loads wordmap in constructor and delivers pointer to data object during run time. ...
Templated (hybrid) Interface for Task classes.
bool exists(const std::string &key) const
Determines whether a program option (key) has been defined by the user.
Definition: registrypo.hpp:235
LoadWordMapTask(const ucam::util::RegistryPO &rg, const std::string &key, bool reverse=false)
Constructor with ucam::util::RegistryPO object.
Definition: bleu.hpp:14