66 unordered_set<std::string>
tvcb;
68 unordered_map<std::string, std::vector< pair <unsigned, unsigned> > >
72 boost::scoped_ptr<uf::StatsData>
stats;
73 unordered_map<std::string, uu::WordMapper *>
wm;
82 TEST ( HifstCykParserTask, basic_test ) {
84 unordered_map<std::string, boost::any> v;
100 ss <<
"X 3 3 0" << endl <<
"S S_X S_X 0" << endl;
101 ss <<
"X 4 4 0" << endl <<
"X 5 5 0" << endl <<
"X 1 1 0" << endl <<
"X 2 2 0" 103 ss <<
"X 3_4 3_4 0" << endl <<
"X 3_X1_5 3_X1_5 0" << endl <<
"S X1 X1 0" <<
109 d.
hpinstances[
"1"].push_back ( pair<unsigned, unsigned> ( 0, 0 ) );
110 d.
hpinstances[
"3"].push_back ( pair<unsigned, unsigned> ( 1, 0 ) );
111 d.
hpinstances[
"4"].push_back ( pair<unsigned, unsigned> ( 2, 0 ) );
112 d.
hpinstances[
"5"].push_back ( pair<unsigned, unsigned> ( 3, 0 ) );
113 d.
hpinstances[
"2"].push_back ( pair<unsigned, unsigned> ( 4, 0 ) );
114 d.
hpinstances[
"3_4"].push_back ( pair<unsigned, unsigned> ( 1, 1 ) );
115 d.
hpinstances[
"3_X_5"].push_back ( pair<unsigned, unsigned> ( 1, 2 ) );
116 d.
hpinstances[
"X_X"].push_back ( pair<unsigned, unsigned> ( 0, 1 ) );
117 d.
hpinstances[
"X"].push_back ( pair<unsigned, unsigned> ( 0, 0 ) );
122 EXPECT_TRUE ( d.
cykdata == NULL );
124 ASSERT_FALSE ( d.
cykdata == NULL );
139 TEST ( HifstCykParserTask, cykgridfunctor ) {
141 EXPECT_EQ ( cyk.
size(), 0 );
143 cyk.
Add ( 1, 0, 2, 1 );
144 cyk.
Add ( 1, 0, 2, 2 );
145 cyk.
Add ( 1, 0, 2, 3 );
146 cyk.
Add ( 0, 0, 0, 10 );
147 ASSERT_EQ ( cyk ( 1, 0, 2 ).size(), 3 );
148 ASSERT_EQ ( cyk ( 0, 0, 0 ).size(), 1 );
149 EXPECT_EQ ( cyk ( 1, 0, 2 ) [0], 1 );
150 EXPECT_EQ ( cyk ( 1, 0, 2 ) [1], 2 );
151 EXPECT_EQ ( cyk ( 1, 0, 2 ) [2], 3 );
152 EXPECT_EQ ( cyk ( 0, 0, 0 ) [0], 10 );
153 EXPECT_EQ ( cyk ( 1, 0, 2, 0 ), 1 );
154 EXPECT_EQ ( cyk ( 1, 0, 2, 1 ), 2 );
155 EXPECT_EQ ( cyk ( 1, 0, 2, 2 ), 3 );
156 EXPECT_EQ ( cyk ( 0, 0, 0, 0 ), 10 );
158 ASSERT_EQ ( cyk ( 2, 0, 3 ).size(), 0 );
160 EXPECT_EQ ( cyk.
size(), 0 );
163 TEST ( HifstCykParserTask, cykbpfunctor ) {
169 bp.
Add ( 1, 0, 2, aux );
174 bp.
Add ( 1, 0, 2, aux );
176 bp.
Add ( 0, 0, 0, aux );
177 ASSERT_EQ ( bp ( 1, 0, 2 ).size(), 2 );
178 ASSERT_EQ ( bp ( 0, 0, 0 ).size(), 0 );
180 ASSERT_EQ ( aux2[0].size(), 3 );
181 ASSERT_EQ ( aux2[1].size(), 3 );
182 EXPECT_EQ ( aux2[0][0], 1 );
183 EXPECT_EQ ( aux2[0][1], 1 );
184 EXPECT_EQ ( aux2[0][2], 1 );
185 EXPECT_EQ ( aux2[1][0], 2 );
186 EXPECT_EQ ( aux2[1][1], 2 );
187 EXPECT_EQ ( aux2[1][2], 2 );
189 EXPECT_EQ ( bp.
size(), 0 );
194 int main (
int argc,
char **argv ) {
195 ::testing::InitGoogleTest ( &argc, argv );
196 return RUN_ALL_TESTS();
Handles simple wildcard expansion for strings.
void reset()
Clear cyk grid.
bool run(Data &d)
Runs the parsing algorithm.
Relative to Stats across the pipeline.
Data structure containing all cyk-related information.
const std::string kCykparserHrmaxheight
Contains structures and classes for GrammarData.
const std::string kCykparserNtexceptionsmaxspan
unordered_map< std::string, uu::WordMapper * > wm
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)
void reset()
Delete cyk backpointers.
const std::string kGrammarFeatureweights
bool run(Data &d)
run method, given a grammar and instantiated patterns, creates and returns the hashes ...
Interfaces with basic methods for iteration.
Struct containing grammar rules.
uh::GrammarData * grammar
Describes class GrammarTask.
CYKgrid cykgrid
Cyk grid. Each cell of the grid is uniquely defined by three dimensions: [category,x,y].
Task class that loads a grammar into memory.
unordered_map< std::string, std::vector< pair< unsigned, unsigned > > > hpinstances
int getFinalResult()
Returns success (number of nodes in topmost cell) or failure (CYK_RETURNS_FAILURE=0) ...
Contains structures and classes for GrammarData.
Static variables for logger. Include only once from main file.
const std::string kCykparserHmin
std::vector< cykparser_rulebpcoordinates_t > cykparser_ruledependencies_t
const std::string kSsgrammarAddoovsSourcedeletions
unordered_set< std::string > tvcb
Target vocabulary.
const std::string kSsgrammarAddoovsEnable
Convenience functions to parse parameters from a string.
std::basic_string< uint > cykparser_rulebpcoordinates_t
void load(const std::string &file)
Loads rules from a grammar file.
This class uses instantiated patterns to analyze the grammar and deliver two hashes providing candida...
Contains implementation for sentence-specific grammar task.
std::size_t size()
Return actual size of the cyk grid.
Contains definitions for cykparser data and task.
int main(int argc, char **argv)
Contains definitions for cykparser data and task.
Contains cyk parser implementation.
uh::SentenceSpecificGrammarData * ssgd
Contains definitions for sentence-specific grammar data and task.
GrammarData * getGrammarData()
Returns GrammarData.
TEST(HifstCykParserTask, basic_test)
Basic test for CykParserTask.
const std::string kSsgrammarStore
const std::string kGrammarStorepatterns
functor that provides cyk backpointers
Contains sentence-specific grammar data.
Structure for sentence-specific grammar Rules will be queried by cyk per position and number of eleme...
const std::string kGrammarStorentorder
std::size_t size()
Size of the backpointer structure (number of cc,x,y elements inserted).
Public Data class with variables required by CyKParser.
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.
const std::string kCykparserHmax
Unit testing: google testing common header.
boost::scoped_ptr< uf::StatsData > stats
const std::string kGrammarLoad
Static variable for custom_assert. Include only once from main file.
functor that provides cykgrid access methods