Cambridge SMT System
data.cykparser.cykgrid.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_CYKGRID_HPP
16 #define DATA_CYKPARSER_CYKGRID_HPP
17 
25 namespace ucam {
26 namespace hifst {
27 
32 class CYKgrid {
33  typedef unordered_map< uint, ssgrammar_listofrules_t > cykparser_cykgrid_t;
34  private:
35 
36  cykparser_cykgrid_t cykgrid_;
37  public:
38 
40  inline const ssgrammar_listofrules_t& operator() ( const uint cc, const uint x,
41  const uint y ) {
42  return cykgrid_[APBASETAG + cc * APCCTAG + x * APXTAG + y * APYTAG];
43  };
44 
46  inline uint operator() ( const uint cc, const uint x, const uint y,
47  const uint rulepos ) {
48  return cykgrid_[ APBASETAG + cc * APCCTAG + x * APXTAG + y * APYTAG ][rulepos];
49  };
50 
52  inline void Add ( const uint cc, const uint x, const uint y,
53  const uint ruleidx ) {
54  cykgrid_[ APBASETAG + cc * APCCTAG + x * APXTAG + y * APYTAG ].push_back (
55  ruleidx );
56  };
57 
59  inline void reset() {
60  cykgrid_.clear();
61  };
63  inline std::size_t size() {
64  return cykgrid_.size();
65  };
66 
67 };
68 
69 }
70 } // end namespaces
71 
72 #endif //DATA_CYKPARSER_CYKGRID_HPP
void reset()
Clear cyk grid.
#define APBASETAG
const ssgrammar_listofrules_t & operator()(const uint cc, const uint x, const uint y)
Get list of grammar rules assigned to (cc,x,y)
void Add(const uint cc, const uint x, const uint y, const uint ruleidx)
Add a rule to the cyk grid at (cc,x,y)
#define APXTAG
std::size_t size()
Return actual size of the cyk grid.
#define APYTAG
#define APCCTAG
std::basic_string< uint > ssgrammar_listofrules_t
Definition: bleu.hpp:14
functor that provides cykgrid access methods