From aceb387526478e34e41db6c046f707234953e0b5 Mon Sep 17 00:00:00 2001
From: Patrick Simianer
Date: Mon, 29 Aug 2011 22:02:45 +0200
Subject: big update: working iterating, pretty output, test scripts and more
---
decoder/decoder.cc | 4 ++--
decoder/decoder.h | 4 +++-
decoder/scfg_translator.cc | 12 +++++-------
decoder/translator.h | 4 +++-
4 files changed, 13 insertions(+), 11 deletions(-)
(limited to 'decoder')
diff --git a/decoder/decoder.cc b/decoder/decoder.cc
index 434109c2..55d9f1d7 100644
--- a/decoder/decoder.cc
+++ b/decoder/decoder.cc
@@ -708,9 +708,9 @@ void Decoder::SetSupplementalGrammar(const std::string& grammar_string) {
assert(pimpl_->translator->GetDecoderType() == "SCFG");
static_cast(*pimpl_->translator).SetSupplementalGrammar(grammar_string);
}
-void Decoder::SetSentenceGrammar(const std::string& grammar_string) {
+void Decoder::SetSentenceGrammarFromString(const std::string& grammar_str) {
assert(pimpl_->translator->GetDecoderType() == "SCFG");
- static_cast(*pimpl_->translator).SetSentenceGrammar(grammar_string);
+ static_cast(*pimpl_->translator).SetSentenceGrammarFromString(grammar_str);
}
diff --git a/decoder/decoder.h b/decoder/decoder.h
index 6eca12c1..236eacd5 100644
--- a/decoder/decoder.h
+++ b/decoder/decoder.h
@@ -7,6 +7,8 @@
#include
#include
+#include "grammar.h"
+
class SentenceMetadata;
struct Hypergraph;
struct DecoderImpl;
@@ -34,7 +36,7 @@ struct Decoder {
// that will be used on subsequent calls to Decode. rules should be in standard
// text format. This function does NOT read from a file.
void SetSupplementalGrammar(const std::string& grammar);
- void SetSentenceGrammar(const std::string& grammar);
+ void SetSentenceGrammarFromString(const std::string& grammar_str);
private:
boost::program_options::variables_map conf;
boost::shared_ptr pimpl_;
diff --git a/decoder/scfg_translator.cc b/decoder/scfg_translator.cc
index 9fdddfdb..646d67fa 100644
--- a/decoder/scfg_translator.cc
+++ b/decoder/scfg_translator.cc
@@ -106,18 +106,16 @@ struct SCFGTranslatorImpl {
struct NameEquals { NameEquals(const string name) : name_(name) {}
bool operator()(const GrammarPtr& x) const { return x->GetGrammarName() == name_; } const string name_; };
- void SetSentenceGrammar(const std::string& grammar_string) {
- assert( grammar_string != "" );
+ void SetSentenceGrammarFromString(const std::string& grammar_str) {
+ assert( grammar_str != "" );
if (!SILENT) cerr << "Setting sentence grammar" << endl;
usingSentenceGrammar = true;
- //FD::Freeze();
- istringstream in( grammar_string );
+ istringstream in( grammar_str );
TextGrammar* sent_grammar = new TextGrammar( &in );
sent_grammar->SetMaxSpan( max_span_limit );
sent_grammar->SetGrammarName( "__psg" );
grammars.erase ( remove_if(grammars.begin(), grammars.end(), NameEquals("__psg")), grammars.end() );
grammars.push_back( GrammarPtr(sent_grammar) );
- //FD::UnFreeze();
}
bool Translate(const string& input,
@@ -321,8 +319,8 @@ void SCFGTranslator::SetSupplementalGrammar(const std::string& grammar) {
pimpl_->SetSupplementalGrammar(grammar);
}
-void SCFGTranslator::SetSentenceGrammar(const std::string& grammar) {
- pimpl_->SetSentenceGrammar(grammar);
+void SCFGTranslator::SetSentenceGrammarFromString(const std::string& grammar_str) {
+ pimpl_->SetSentenceGrammarFromString(grammar_str);
}
void SCFGTranslator::SentenceCompleteImpl() {
diff --git a/decoder/translator.h b/decoder/translator.h
index 5abf9fd6..cfd3b08a 100644
--- a/decoder/translator.h
+++ b/decoder/translator.h
@@ -7,6 +7,8 @@
#include
#include
+#include "grammar.h"
+
class Hypergraph;
class SentenceMetadata;
@@ -57,7 +59,7 @@ class SCFGTranslator : public Translator {
public:
SCFGTranslator(const boost::program_options::variables_map& conf);
void SetSupplementalGrammar(const std::string& grammar);
- void SetSentenceGrammar(const std::string& grammar);
+ void SetSentenceGrammarFromString(const std::string& grammar);
virtual std::string GetDecoderType() const;
protected:
bool TranslateImpl(const std::string& src,
--
cgit v1.2.3