summaryrefslogtreecommitdiff
path: root/decoder/grammar.h
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2010-12-12 15:32:19 -0500
committerChris Dyer <cdyer@cs.cmu.edu>2010-12-12 15:32:19 -0500
commitf5cf383fffc3dee05c7f24733db45d0260f486ed (patch)
tree191860106fb61c9983dce51b6358d93f230a6aa7 /decoder/grammar.h
parent658263d53805482d2bc2dc186476626a01cb4e93 (diff)
facility for adding programmitically generated grammars
Diffstat (limited to 'decoder/grammar.h')
-rw-r--r--decoder/grammar.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/decoder/grammar.h b/decoder/grammar.h
index 1173e3cd..f5d00817 100644
--- a/decoder/grammar.h
+++ b/decoder/grammar.h
@@ -1,13 +1,15 @@
#ifndef GRAMMAR_H_
#define GRAMMAR_H_
+#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
-#include <boost/shared_ptr.hpp>
#include <string>
+#include <boost/shared_ptr.hpp>
+
#include "lattice.h"
#include "trule.h"
@@ -62,12 +64,14 @@ typedef boost::shared_ptr<Grammar> GrammarPtr;
class TGImpl;
struct TextGrammar : public Grammar {
TextGrammar();
- TextGrammar(const std::string& file);
+ explicit TextGrammar(const std::string& file);
+ explicit TextGrammar(std::istream* in);
void SetMaxSpan(int m) { max_span_ = m; }
virtual const GrammarIter* GetRoot() const;
void AddRule(const TRulePtr& rule, const unsigned int ctf_level=0, const TRulePtr& coarse_parent=TRulePtr());
void ReadFromFile(const std::string& filename);
+ void ReadFromStream(std::istream* in);
virtual bool HasRuleForSpan(int i, int j, int distance) const;
const std::vector<TRulePtr>& GetUnaryRules(const WordID& cat) const;
@@ -92,4 +96,5 @@ struct PassThroughGrammar : public TextGrammar {
};
void RefineRule(TRulePtr pt, const unsigned int ctf_level);
+
#endif