mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-17 14:17:13 +03:00
fixings about include files
This commit is contained in:
parent
626c9d7a84
commit
f39419e737
@ -35,7 +35,7 @@
|
||||
|
||||
#include "util/exception.hh"
|
||||
|
||||
#include "PhraseAlignment.h"
|
||||
#include "ExtractionPhrasePair.h"
|
||||
|
||||
namespace MosesTraining
|
||||
{
|
||||
@ -64,17 +64,14 @@ public:
|
||||
/** Passed to each feature to be used to calculate its values */
|
||||
struct ScoreFeatureContext {
|
||||
ScoreFeatureContext(
|
||||
const PhraseAlignmentCollection &thePhrasePair,
|
||||
float theCount, /* Total counts of all phrase pairs*/
|
||||
const ExtractionPhrasePair &thePhrasePair,
|
||||
const MaybeLog& theMaybeLog
|
||||
) :
|
||||
phrasePair(thePhrasePair),
|
||||
count(theCount),
|
||||
maybeLog(theMaybeLog) {
|
||||
}
|
||||
|
||||
const PhraseAlignmentCollection& phrasePair;
|
||||
float count;
|
||||
const ExtractionPhrasePair &phrasePair;
|
||||
MaybeLog maybeLog;
|
||||
};
|
||||
|
||||
@ -85,16 +82,19 @@ struct ScoreFeatureContext {
|
||||
class ScoreFeature
|
||||
{
|
||||
public:
|
||||
|
||||
/** Some features might need to store properties in ExtractionPhrasePair,
|
||||
* e.g. to pass along external information loaded by a feature
|
||||
* which may distinguish several phrase occurrences based on sentence ID */
|
||||
virtual void addPropertiesToPhrasePair(ExtractionPhrasePair &phrasePair,
|
||||
float count,
|
||||
int sentenceId) const {};
|
||||
|
||||
/** Add the values for this feature function. */
|
||||
virtual void add(const ScoreFeatureContext& context,
|
||||
std::vector<float>& denseValues,
|
||||
std::map<std::string,float>& sparseValues) const = 0;
|
||||
|
||||
/** Return true if the two phrase pairs are equal from the point of this feature. Assume
|
||||
that they already compare true according to PhraseAlignment.equals()
|
||||
**/
|
||||
virtual bool equals(const PhraseAlignment& lhs, const PhraseAlignment& rhs) const = 0;
|
||||
|
||||
virtual ~ScoreFeature() {}
|
||||
|
||||
};
|
||||
@ -112,17 +112,18 @@ public:
|
||||
/** Pass the unused command-line arguments to configure the extra features */
|
||||
void configure(const std::vector<std::string> args);
|
||||
|
||||
/** Some features might need to store properties in ExtractionPhrasePair,
|
||||
* e.g. to pass along external information loaded by a feature
|
||||
* which may distinguish several phrase occurrences based on sentence ID */
|
||||
void addPropertiesToPhrasePair(ExtractionPhrasePair &phrasePair,
|
||||
float count,
|
||||
int sentenceId) const;
|
||||
|
||||
/** Add all the features */
|
||||
void addFeatures(const ScoreFeatureContext& context,
|
||||
std::vector<float>& denseValues,
|
||||
std::map<std::string,float>& sparseValues) const;
|
||||
|
||||
/**
|
||||
* Used to tell if the PhraseAlignment should be considered the same by all
|
||||
* extended features.
|
||||
**/
|
||||
bool equals(const PhraseAlignment& lhs, const PhraseAlignment& rhs) const;
|
||||
|
||||
const std::vector<ScoreFeaturePtr>& getFeatures() const {
|
||||
return m_features;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public:
|
||||
std::vector<std::string> target;
|
||||
std::vector<std::string> source;
|
||||
std::vector<int> alignedCountS;
|
||||
std::vector<std::vector<int> > alignedToT;
|
||||
std::vector<std::vector<int> > alignedToT, alignedToS;
|
||||
int sentenceID;
|
||||
std::string weightString;
|
||||
|
||||
@ -46,6 +46,8 @@ public:
|
||||
bool create(char targetString[], char sourceString[],
|
||||
char alignmentString[], char weightString[], int sentenceID, bool boundaryRules);
|
||||
|
||||
void invertAlignment();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -60,6 +60,8 @@ private:
|
||||
const std::map<std::string, std::string> &,
|
||||
const Options &,
|
||||
std::ostream &);
|
||||
void WriteUnknownWordSoftMatches(const std::set<std::string> &,
|
||||
std::ostream &);
|
||||
void WriteGlueGrammar(const std::set<std::string> &,
|
||||
const std::map<std::string, int> &,
|
||||
std::ostream &);
|
||||
|
@ -40,6 +40,7 @@ public:
|
||||
, maxScope(3)
|
||||
, minimal(false)
|
||||
, pcfg(false)
|
||||
, treeFragments(false)
|
||||
, sentenceOffset(0)
|
||||
, unpairedExtractFormat(false)
|
||||
, unknownWordMinRelFreq(0.03f)
|
||||
@ -62,9 +63,11 @@ public:
|
||||
int maxScope;
|
||||
bool minimal;
|
||||
bool pcfg;
|
||||
bool treeFragments;
|
||||
int sentenceOffset;
|
||||
bool unpairedExtractFormat;
|
||||
std::string unknownWordFile;
|
||||
std::string unknownWordSoftMatchesFile;
|
||||
float unknownWordMinRelFreq;
|
||||
bool unknownWordUniform;
|
||||
};
|
||||
|
@ -21,6 +21,8 @@
|
||||
#ifndef EXTRACT_GHKM_RULE_WRITER_H_
|
||||
#define EXTRACT_GHKM_RULE_WRITER_H_
|
||||
|
||||
#include "Subgraph.h"
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace Moses
|
||||
@ -40,7 +42,9 @@ public:
|
||||
, m_inv(inv)
|
||||
, m_options(options) {}
|
||||
|
||||
void Write(const ScfgRule &);
|
||||
void Write(const ScfgRule &rule, bool printEndl=true);
|
||||
|
||||
void Write(const ScfgRule &rule, const Subgraph &g);
|
||||
|
||||
private:
|
||||
// Disallow copying
|
||||
|
@ -83,6 +83,9 @@ template <class Except, class Data> typename Except::template ExceptionTag<Excep
|
||||
#define UTIL_THROW(Exception, Modify) \
|
||||
UTIL_THROW_BACKEND(NULL, Exception, , Modify);
|
||||
|
||||
#define UTIL_THROW2(Modify) \
|
||||
UTIL_THROW_BACKEND(NULL, util::Exception, , Modify);
|
||||
|
||||
#if __GNUC__ >= 3
|
||||
#define UTIL_UNLIKELY(x) __builtin_expect (!!(x), 0)
|
||||
#else
|
||||
@ -98,6 +101,9 @@ template <class Except, class Data> typename Except::template ExceptionTag<Excep
|
||||
#define UTIL_THROW_IF(Condition, Exception, Modify) \
|
||||
UTIL_THROW_IF_ARG(Condition, Exception, , Modify)
|
||||
|
||||
#define UTIL_THROW_IF2(Condition, Modify) \
|
||||
UTIL_THROW_IF_ARG(Condition, util::Exception, , Modify)
|
||||
|
||||
// Exception that records errno and adds it to the message.
|
||||
class ErrnoException : public Exception {
|
||||
public:
|
||||
@ -111,6 +117,13 @@ class ErrnoException : public Exception {
|
||||
int errno_;
|
||||
};
|
||||
|
||||
// file wasn't there, or couldn't be open for some reason
|
||||
class FileOpenException : public Exception {
|
||||
public:
|
||||
FileOpenException() throw() {}
|
||||
~FileOpenException() throw() {}
|
||||
};
|
||||
|
||||
// Utilities for overflow checking.
|
||||
class OverflowException : public Exception {
|
||||
public:
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef UTIL_READ_COMPRESSED__
|
||||
#define UTIL_READ_COMPRESSED__
|
||||
#ifndef UTIL_READ_COMPRESSED_H
|
||||
#define UTIL_READ_COMPRESSED_H
|
||||
|
||||
#include "util/exception.hh"
|
||||
#include "util/scoped.hh"
|
||||
@ -78,4 +78,4 @@ class ReadCompressed {
|
||||
|
||||
} // namespace util
|
||||
|
||||
#endif // UTIL_READ_COMPRESSED__
|
||||
#endif // UTIL_READ_COMPRESSED_H
|
||||
|
Loading…
Reference in New Issue
Block a user