diff options
author | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-12-10 06:17:36 +0300 |
---|---|---|
committer | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-12-11 04:09:22 +0300 |
commit | 29694af6e43c1cec7a6fd0b157eb44faca706129 (patch) | |
tree | acda250a83c5a3a4244be011f1f4b9e6337f5d6b /moses/ConfusionNet.cpp | |
parent | 240b88c6834c9c94e8a6448a34dc4ad33bdf3fbd (diff) |
Code cleanup and refactoring.
Diffstat (limited to 'moses/ConfusionNet.cpp')
-rw-r--r-- | moses/ConfusionNet.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/moses/ConfusionNet.cpp b/moses/ConfusionNet.cpp index f71c798f7..f60b7907f 100644 --- a/moses/ConfusionNet.cpp +++ b/moses/ConfusionNet.cpp @@ -66,9 +66,8 @@ ConfusionNet(AllOptions::ptr const& opts) : InputType(opts) { stats.createOne(); - const StaticData& SD = StaticData::Instance(); - if (SD.IsSyntax()) { - m_defaultLabelSet.insert(SD.GetInputDefaultNonTerminal()); + if (is_syntax(opts->search.algo)) { + m_defaultLabelSet.insert(opts->syntax.input_default_non_terminal); } UTIL_THROW_IF2(InputFeature::InstancePtr() == NULL, "Input feature must be specified"); } @@ -92,14 +91,14 @@ ConfusionNet(Sentence const& s) : InputType(s.options()) bool ConfusionNet:: -ReadF(std::istream& in, const std::vector<FactorType>& factorOrder, int format) +ReadF(std::istream& in, int format) { VERBOSE(2, "read confusion net with format "<<format<<"\n"); switch(format) { case 0: - return ReadFormat0(in,factorOrder); + return ReadFormat0(in); case 1: - return ReadFormat1(in,factorOrder); + return ReadFormat1(in); default: std::cerr << "ERROR: unknown format '"<<format <<"' in ConfusionNet::Read"; @@ -109,22 +108,20 @@ ReadF(std::istream& in, const std::vector<FactorType>& factorOrder, int format) int ConfusionNet:: -Read(std::istream& in, - const std::vector<FactorType>& factorOrder, - AllOptions const& opts) +Read(std::istream& in) { - int rv=ReadF(in,factorOrder,0); + int rv=ReadF(in,0); if(rv) stats.collect(*this); return rv; } bool ConfusionNet:: -ReadFormat0(std::istream& in, const std::vector<FactorType>& factorOrder) +ReadFormat0(std::istream& in) { Clear(); + const std::vector<FactorType>& factorOrder = m_options->input.factor_order; - // const StaticData &staticData = StaticData::Instance(); const InputFeature *inputFeature = InputFeature::InstancePtr(); size_t numInputScores = inputFeature->GetNumInputScores(); size_t numRealWordCount = inputFeature->GetNumRealWordsInInput(); @@ -140,7 +137,6 @@ ReadFormat0(std::istream& in, const std::vector<FactorType>& factorOrder) Column col; while(is>>word) { Word w; - // String2Word(word,w,factorOrder); w.CreateFromString(Input,factorOrder,StringPiece(word),false,false); std::vector<float> probs(totalCount, 0.0); for(size_t i=0; i < numInputScores; i++) { @@ -179,9 +175,10 @@ ReadFormat0(std::istream& in, const std::vector<FactorType>& factorOrder) bool ConfusionNet:: -ReadFormat1(std::istream& in, const std::vector<FactorType>& factorOrder) +ReadFormat1(std::istream& in) { Clear(); + const std::vector<FactorType>& factorOrder = m_options->input.factor_order; std::string line; if(!getline(in,line)) return 0; size_t s; |