diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2010-12-12 15:32:19 -0500 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2010-12-12 15:32:19 -0500 |
commit | 8c16b9384e8b85abf9e51bc670e548bf5cd4a0c5 (patch) | |
tree | 83cb68bb8c884fcf14aa33eddf88f428ad60f807 /decoder/grammar.h | |
parent | b8f314dddda3d440164e4772830e3c951ba06ee4 (diff) |
facility for adding programmitically generated grammars
Diffstat (limited to 'decoder/grammar.h')
-rw-r--r-- | decoder/grammar.h | 9 |
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 |