summaryrefslogtreecommitdiff
path: root/extools/striped_grammar.h
diff options
context:
space:
mode:
authorPatrick Simianer <simianer@cl.uni-heidelberg.de>2012-11-05 15:29:46 +0100
committerPatrick Simianer <simianer@cl.uni-heidelberg.de>2012-11-05 15:29:46 +0100
commit6f29f345dc06c1a1033475eac1d1340781d1d603 (patch)
tree6fa4cdd7aefd7d54c9585c2c6274db61bb8b159a /extools/striped_grammar.h
parentb510da2e562c695c90d565eb295c749569c59be8 (diff)
parentc615c37501fa8576584a510a9d2bfe2fdd5bace7 (diff)
merge upstream/master
Diffstat (limited to 'extools/striped_grammar.h')
-rw-r--r--extools/striped_grammar.h56
1 files changed, 0 insertions, 56 deletions
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 <iostream>
-#include <boost/functional/hash.hpp>
-#include <vector>
-#include <tr1/unordered_map>
-#include "sparse_vector.h"
-#include "wordid.h"
-#include "tdict.h"
-
-// represents statistics / information about a rule pair
-struct RuleStatistics {
- SparseVector<float> counts;
- std::vector<std::pair<short,short> > aligns;
- RuleStatistics() {}
- RuleStatistics(int name, float val, const std::vector<std::pair<short,short> >& 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<WordID>& 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<WordID>& 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<std::vector<WordID>, RuleStatistics, boost::hash<std::vector<WordID> > > ID2RuleStatistics;
-
-struct StripedGrammarLexer {
- typedef void (*GrammarCallback)(WordID lhs, const std::vector<WordID>& src_rhs, const ID2RuleStatistics& rules, void *extra);
- static void ReadStripedGrammar(std::istream* in, GrammarCallback func, void* extra);
- typedef void (*ContextCallback)(const std::vector<WordID>& phrase, const ID2RuleStatistics& rules, void *extra);
- static void ReadContexts(std::istream* in, ContextCallback func, void* extra);
-};
-
-#endif