From b6e70b420ed993ee73f71058d04b382147896068 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Sun, 12 Aug 2012 23:33:21 -0400 Subject: use new union api --- extools/striped_grammar.h | 56 ----------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 extools/striped_grammar.h (limited to 'extools/striped_grammar.h') diff --git a/extools/striped_grammar.h b/extools/striped_grammar.h deleted file mode 100644 index bf3aec7d..00000000 --- a/extools/striped_grammar.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _STRIPED_GRAMMAR_H_ -#define _STRIPED_GRAMMAR_H_ - -#include -#include -#include -#include -#include "sparse_vector.h" -#include "wordid.h" -#include "tdict.h" - -// represents statistics / information about a rule pair -struct RuleStatistics { - SparseVector counts; - std::vector > aligns; - RuleStatistics() {} - RuleStatistics(int name, float val, const std::vector >& al) : - aligns(al) { - counts.set_value(name, val); - } - void ParseRuleStatistics(const char* buf, int start, int end); - RuleStatistics& operator+=(const RuleStatistics& rhs) { - counts += rhs.counts; - return *this; - } -}; -std::ostream& operator<<(std::ostream& os, const RuleStatistics& s); - -inline void WriteNamed(const std::vector& v, std::ostream* os) { - bool first = true; - for (int i = 0; i < v.size(); ++i) { - if (first) { first = false; } else { (*os) << ' '; } - if (v[i] < 0) { (*os) << '[' << TD::Convert(-v[i]) << ']'; } - else (*os) << TD::Convert(v[i]); - } -} - -inline void WriteAnonymous(const std::vector& v, std::ostream* os) { - bool first = true; - for (int i = 0; i < v.size(); ++i) { - if (first) { first = false; } else { (*os) << ' '; } - if (v[i] <= 0) { (*os) << '[' << (1-v[i]) << ']'; } - else (*os) << TD::Convert(v[i]); - } -} - -typedef std::tr1::unordered_map, RuleStatistics, boost::hash > > ID2RuleStatistics; - -struct StripedGrammarLexer { - typedef void (*GrammarCallback)(WordID lhs, const std::vector& src_rhs, const ID2RuleStatistics& rules, void *extra); - static void ReadStripedGrammar(std::istream* in, GrammarCallback func, void* extra); - typedef void (*ContextCallback)(const std::vector& phrase, const ID2RuleStatistics& rules, void *extra); - static void ReadContexts(std::istream* in, ContextCallback func, void* extra); -}; - -#endif -- cgit v1.2.3