mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-08-16 15:00:33 +03:00
Derive your property class from PhraseProperty. Do any expensive string processing of the property value in there, not in the feature implementation, and provide methods to access the information in appropriate data formats. The property value string will thus have to be processed only once (on loading) rather than each time the respective phrase is applied and your feature needs to access the property value.
34 lines
642 B
C++
34 lines
642 B
C++
#pragma once
|
|
|
|
#include "moses/PP/PhraseProperty.h"
|
|
#include <string>
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
#include <boost/unordered_map.hpp>
|
|
|
|
namespace Moses
|
|
{
|
|
|
|
class PhrasePropertyCreator;
|
|
|
|
class PhrasePropertyFactory
|
|
{
|
|
public:
|
|
PhrasePropertyFactory();
|
|
|
|
~PhrasePropertyFactory();
|
|
|
|
boost::shared_ptr<PhraseProperty> ProduceProperty(const std::string &key, const std::string &value) const;
|
|
void PrintPP() const;
|
|
|
|
private:
|
|
void Add(const std::string &name, PhrasePropertyCreator *creator);
|
|
|
|
typedef boost::unordered_map<std::string, boost::shared_ptr<PhrasePropertyCreator> > Registry;
|
|
|
|
Registry m_registry;
|
|
};
|
|
|
|
} // namespace Moses
|
|
|