2015-10-24 01:19:31 +03:00
|
|
|
/*
|
|
|
|
* PhraseTable.h
|
|
|
|
*
|
|
|
|
* Created on: 23 Oct 2015
|
|
|
|
* Author: hieu
|
|
|
|
*/
|
|
|
|
#pragma once
|
2015-10-24 04:02:50 +03:00
|
|
|
#include <string>
|
2015-10-24 01:19:31 +03:00
|
|
|
#include <boost/unordered_map.hpp>
|
2015-11-04 16:09:53 +03:00
|
|
|
#include "../TargetPhrases.h"
|
|
|
|
#include "../Word.h"
|
|
|
|
#include "../FF/StatelessFeatureFunction.h"
|
2015-11-11 19:23:49 +03:00
|
|
|
#include "../legacy/Util2.h"
|
2015-10-24 01:19:31 +03:00
|
|
|
|
2015-12-10 23:49:30 +03:00
|
|
|
namespace Moses2
|
|
|
|
{
|
|
|
|
|
2015-10-26 00:20:55 +03:00
|
|
|
class System;
|
2015-10-24 14:39:15 +03:00
|
|
|
class InputPaths;
|
2015-10-28 20:12:02 +03:00
|
|
|
class InputPath;
|
2015-10-28 20:23:55 +03:00
|
|
|
class Manager;
|
2015-10-24 01:19:31 +03:00
|
|
|
|
2015-10-24 15:31:43 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
2015-10-24 21:54:16 +03:00
|
|
|
class PhraseTable : public StatelessFeatureFunction
|
2015-10-24 01:19:31 +03:00
|
|
|
{
|
|
|
|
public:
|
2015-10-27 18:46:37 +03:00
|
|
|
PhraseTable(size_t startInd, const std::string &line);
|
2015-10-24 01:19:31 +03:00
|
|
|
virtual ~PhraseTable();
|
2015-10-28 19:42:12 +03:00
|
|
|
|
|
|
|
virtual void SetParameter(const std::string& key, const std::string& value);
|
2015-10-28 20:23:55 +03:00
|
|
|
virtual void Lookup(const Manager &mgr, InputPaths &inputPaths) const;
|
2015-12-10 17:06:42 +03:00
|
|
|
virtual TargetPhrases *Lookup(const Manager &mgr, MemPool &pool, InputPath &inputPath) const;
|
2015-10-24 01:19:31 +03:00
|
|
|
|
2015-10-24 15:31:43 +03:00
|
|
|
void SetPtInd(size_t ind)
|
|
|
|
{ m_ptInd = ind; }
|
|
|
|
size_t GetPtInd() const
|
|
|
|
{ return m_ptInd; }
|
|
|
|
|
2015-10-29 02:26:17 +03:00
|
|
|
virtual void
|
2015-12-18 00:03:28 +03:00
|
|
|
EvaluateInIsolation(MemPool &pool,
|
|
|
|
const System &system,
|
|
|
|
const Phrase &source,
|
|
|
|
const TargetPhrase &targetPhrase,
|
2015-10-29 03:47:06 +03:00
|
|
|
Scores &scores,
|
2015-11-04 18:25:09 +03:00
|
|
|
Scores *estimatedScores) const;
|
2015-10-29 02:26:17 +03:00
|
|
|
|
2015-12-07 20:19:46 +03:00
|
|
|
virtual void CleanUpAfterSentenceProcessing();
|
|
|
|
|
2015-10-24 01:19:31 +03:00
|
|
|
protected:
|
2015-11-06 13:55:04 +03:00
|
|
|
std::string m_path;
|
|
|
|
size_t m_ptInd;
|
|
|
|
size_t m_tableLimit;
|
2015-10-24 14:39:15 +03:00
|
|
|
|
2015-12-07 17:43:10 +03:00
|
|
|
// cache
|
|
|
|
size_t m_maxCacheSize; // 0 = no caching
|
|
|
|
|
2015-12-07 19:10:20 +03:00
|
|
|
struct CacheCollEntry2
|
|
|
|
{
|
2015-12-10 17:06:42 +03:00
|
|
|
TargetPhrases *tpsPtr;
|
2015-12-07 19:10:20 +03:00
|
|
|
clock_t clock;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef boost::unordered_map<size_t, CacheCollEntry2> CacheColl;
|
2015-12-07 17:43:10 +03:00
|
|
|
mutable boost::thread_specific_ptr<CacheColl> m_cache;
|
|
|
|
|
2015-12-07 20:19:46 +03:00
|
|
|
mutable boost::thread_specific_ptr<MemPool> m_cacheMemPool;
|
|
|
|
|
2015-12-07 17:43:10 +03:00
|
|
|
|
|
|
|
CacheColl &GetCache() const;
|
2015-12-07 20:19:46 +03:00
|
|
|
MemPool &GetCacheMemPool() const;
|
|
|
|
|
2015-12-07 17:43:10 +03:00
|
|
|
void ReduceCache() const;
|
|
|
|
|
2015-10-24 01:19:31 +03:00
|
|
|
};
|
|
|
|
|
2015-12-10 23:49:30 +03:00
|
|
|
}
|
|
|
|
|