template-ise, preparing for chart version

This commit is contained in:
Barry Haddow 2014-08-06 15:56:34 +01:00
parent c99a889420
commit ae2a52bd21
3 changed files with 11 additions and 7 deletions

View File

@ -88,7 +88,7 @@ public:
OutputCollector* alignmentInfoCollector,
OutputCollector* unknownsCollector,
bool outputSearchGraphSLF,
boost::shared_ptr<HypergraphOutput> hypergraphOutput) :
boost::shared_ptr<HypergraphOutput<Manager> > hypergraphOutput) :
m_source(source), m_lineNumber(lineNumber),
m_outputCollector(outputCollector), m_nbestCollector(nbestCollector),
m_latticeSamplesCollector(latticeSamplesCollector),
@ -374,7 +374,7 @@ private:
OutputCollector* m_alignmentInfoCollector;
OutputCollector* m_unknownsCollector;
bool m_outputSearchGraphSLF;
boost::shared_ptr<HypergraphOutput> m_hypergraphOutput;
boost::shared_ptr<HypergraphOutput<Manager> > m_hypergraphOutput;
std::ofstream *m_alignmentStream;
@ -489,9 +489,9 @@ int main(int argc, char** argv)
TRACE_ERR(weights);
TRACE_ERR("\n");
}
boost::shared_ptr<HypergraphOutput> hypergraphOutput;
boost::shared_ptr<HypergraphOutput<Manager> > hypergraphOutput;
if (staticData.GetOutputSearchGraphHypergraph()) {
hypergraphOutput.reset(new HypergraphOutput(PRECISION));
hypergraphOutput.reset(new HypergraphOutput<Manager>(PRECISION));
}

View File

@ -41,7 +41,8 @@ using namespace std;
namespace Moses {
HypergraphOutput::HypergraphOutput(size_t precision) :
template<class M>
HypergraphOutput<M>::HypergraphOutput(size_t precision) :
m_precision(precision) {
const StaticData& staticData = StaticData::Instance();
vector<string> hypergraphParameters = staticData.GetParam("output-search-graph-hypergraph");
@ -117,7 +118,8 @@ HypergraphOutput::HypergraphOutput(size_t precision) :
weightsOut.close();
}
void HypergraphOutput::Write(const Manager& manager) const {
template<class M>
void HypergraphOutput<M>::Write(const M& manager) const {
stringstream fileName;
fileName << m_hypergraphDir << "/" << manager.GetLineNumber();
@ -148,6 +150,7 @@ void HypergraphOutput::Write(const Manager& manager) const {
file.pop();
}
template class HypergraphOutput<Manager>;
}

View File

@ -31,6 +31,7 @@ namespace Moses {
class Manager;
template<class M>
class HypergraphOutput {
public:
@ -38,7 +39,7 @@ public:
HypergraphOutput(size_t precision);
/** Write this hypergraph to file */
void Write(const Manager& manager) const;
void Write(const M& manager) const;
private:
size_t m_precision;