/*********************************************************************** Moses - statistical machine translation system Copyright (C) 2006-2011 University of Edinburgh This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ***********************************************************************/ #pragma once #include "Alignment.h" #include "Rule.h" #include "SyntaxTree.h" #include #include #include #include #include namespace Moses { namespace GHKM { class Node; class Subgraph; class ScfgRule : public Rule { public: ScfgRule(const Subgraph &fragment, const MosesTraining::SyntaxTree *sourceSyntaxTree = 0); const Subgraph &GetGraphFragment() const { return m_graphFragment; } const Symbol &GetSourceLHS() const { return m_sourceLHS; } const Symbol &GetTargetLHS() const { return m_targetLHS; } const std::vector &GetSourceRHS() const { return m_sourceRHS; } const std::vector &GetTargetRHS() const { return m_targetRHS; } float GetPcfgScore() const { return m_pcfgScore; } bool HasSourceLabels() const { return m_hasSourceLabels; } void PrintSourceLabels(std::ostream &out) const { for (std::vector::const_iterator it = m_sourceLabels.begin(); it != m_sourceLabels.end(); ++it) { out << " " << (*it); } } void UpdateSourceLabelCoocCounts(std::map< std::string, std::map* > &coocCounts, float count) const; int Scope() const { return Rule::Scope(m_sourceRHS); } private: void PushSourceLabel(const MosesTraining::SyntaxTree *sourceSyntaxTree, const Node *node, const std::string &nonMatchingLabel); const Subgraph& m_graphFragment; Symbol m_sourceLHS; Symbol m_targetLHS; std::vector m_sourceRHS; std::vector m_targetRHS; float m_pcfgScore; bool m_hasSourceLabels; std::vector m_sourceLabels; unsigned m_numberOfNonTerminals; }; } // namespace GHKM } // namespace Moses