Cambridge SMT System
data.cykparser.cykbackpointers.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 DATA_CYKPARSER_CYKBACKPOINTERS_HPP
16 #define DATA_CYKPARSER_CYKBACKPOINTERS_HPP
17 
25 namespace ucam {
26 namespace hifst {
32  typedef unordered_map<unsigned, cykparser_ruledependencies_t >
33  cykparser_backpointers_t;
34 
35  private:
37  cykparser_backpointers_t bp_;
38  public:
39 
40  //Get the set of backpointers for given coordinates (cc,x,y)
41  inline const cykparser_ruledependencies_t& operator() ( const unsigned cc,
42  const unsigned x, const unsigned y ) {
43  return bp_[APBASETAG + cc * APCCTAG + x * APXTAG + y * APYTAG];
44  }
45 
47  inline void Add ( const unsigned cc, const unsigned x, const unsigned y,
48  const cykparser_ruledependencies_t& coords ) {
49  if ( coords.size() )
50  bp_[APBASETAG + cc * APCCTAG + x * APXTAG + y * APYTAG] = coords;
51  };
52 
54  inline void Add ( const unsigned cc, const unsigned x, const unsigned y,
55  const cykparser_rulebpcoordinates_t& coords ) {
56  if ( coords.size() )
57  bp_[APBASETAG + cc * APCCTAG + x * APXTAG + y * APYTAG].push_back ( coords );
58  };
59 
61  inline std::size_t size() {
62  return bp_.size();
63  };
64 
66  inline void reset() {
67  bp_.clear();
68  };
69 
70 };
71 
72 }
73 } // end namespaces
74 
75 #endif
#define APBASETAG
void reset()
Delete cyk backpointers.
#define APXTAG
std::vector< cykparser_rulebpcoordinates_t > cykparser_ruledependencies_t
void Add(const unsigned cc, const unsigned x, const unsigned y, const cykparser_rulebpcoordinates_t &coords)
Add set of backpointers to the grid.
std::basic_string< uint > cykparser_rulebpcoordinates_t
const cykparser_ruledependencies_t & operator()(const unsigned cc, const unsigned x, const unsigned y)
#define APYTAG
functor that provides cyk backpointers
#define APCCTAG
std::size_t size()
Size of the backpointer structure (number of cc,x,y elements inserted).
void Add(const unsigned cc, const unsigned x, const unsigned y, const cykparser_ruledependencies_t &coords)
Add all the set of backpointers to the grid.
Definition: bleu.hpp:14