Skip to content
Snippets Groups Projects
Commit 868799b9 authored by Franck Dary's avatar Franck Dary
Browse files

Added function member to FeatureValue

parent be897165
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,15 @@ class FeatureModel ...@@ -26,6 +26,15 @@ class FeatureModel
Final Final
}; };
/// @brief How to transform a FeatureValue into an input expression for the NeuralNetwork.
///
/// Concat = concatenate values, mean = sum then mean values.
enum Function
{
Concat,
Mean
};
/// @brief The value of a Feature (relative to a specific Config). /// @brief The value of a Feature (relative to a specific Config).
/// ///
/// Can be an aggregate of multiple Feature. /// Can be an aggregate of multiple Feature.
...@@ -45,7 +54,9 @@ class FeatureModel ...@@ -45,7 +54,9 @@ class FeatureModel
/// ///
/// @return The real valued vector. /// @return The real valued vector.
std::string toString(unsigned int i); std::string toString(unsigned int i);
FeatureValue(); /// \brief How to transform this FeatureValue into an input expression for the NeuralNetwork
Function func;
FeatureValue(Function func);
FeatureValue(Dict *, const std::string &, const std::string &, Policy); FeatureValue(Dict *, const std::string &, const std::string &, Policy);
}; };
......
...@@ -423,7 +423,7 @@ FeatureModel::Policy FeatureBank::dictPolicy2FeaturePolicy(Dict::Policy policy) ...@@ -423,7 +423,7 @@ FeatureModel::Policy FeatureBank::dictPolicy2FeaturePolicy(Dict::Policy policy)
FeatureModel::FeatureValue FeatureBank::aggregateBuffer(Config & c, int from, int to, const std::vector<std::string> & exceptions) FeatureModel::FeatureValue FeatureBank::aggregateBuffer(Config & c, int from, int to, const std::vector<std::string> & exceptions)
{ {
FeatureModel::FeatureValue result; FeatureModel::FeatureValue result(FeatureModel::Function::Concat);
for (auto & tape : c.tapes) for (auto & tape : c.tapes)
{ {
...@@ -472,7 +472,7 @@ FeatureModel::FeatureValue FeatureBank::aggregateBuffer(Config & c, int from, in ...@@ -472,7 +472,7 @@ FeatureModel::FeatureValue FeatureBank::aggregateBuffer(Config & c, int from, in
FeatureModel::FeatureValue FeatureBank::aggregateStack(Config & c, int from, const std::vector<std::string> & exceptions) FeatureModel::FeatureValue FeatureBank::aggregateStack(Config & c, int from, const std::vector<std::string> & exceptions)
{ {
FeatureModel::FeatureValue result; FeatureModel::FeatureValue result(FeatureModel::Function::Concat);
for (auto & tape : c.tapes) for (auto & tape : c.tapes)
{ {
...@@ -522,7 +522,7 @@ FeatureModel::FeatureValue FeatureBank::aggregateStack(Config & c, int from, con ...@@ -522,7 +522,7 @@ FeatureModel::FeatureValue FeatureBank::aggregateStack(Config & c, int from, con
//TODO : ne pas utiliser une feature value pour word mais un string, pour que ça marche avec les mots inconnus //TODO : ne pas utiliser une feature value pour word mais un string, pour que ça marche avec les mots inconnus
FeatureModel::FeatureValue FeatureBank::fasttext(Config & c, const FeatureModel::FeatureValue & word) FeatureModel::FeatureValue FeatureBank::fasttext(Config & c, const FeatureModel::FeatureValue & word)
{ {
FeatureModel::FeatureValue result; FeatureModel::FeatureValue result(FeatureModel::Function::Mean);
Dict * lettersDict = Dict::getDict("letters"); Dict * lettersDict = Dict::getDict("letters");
auto policy = dictPolicy2FeaturePolicy(lettersDict->policy); auto policy = dictPolicy2FeaturePolicy(lettersDict->policy);
......
...@@ -124,14 +124,16 @@ const char * FeatureModel::policy2str(Policy policy) ...@@ -124,14 +124,16 @@ const char * FeatureModel::policy2str(Policy policy)
FeatureModel::FeatureValue::FeatureValue(Dict * dict, const std::string & name, const std::string & value, Policy policy) FeatureModel::FeatureValue::FeatureValue(Dict * dict, const std::string & name, const std::string & value, Policy policy)
{ {
this->func = Function::Concat;
dicts.emplace_back(dict); dicts.emplace_back(dict);
names.emplace_back(name); names.emplace_back(name);
values.emplace_back(value); values.emplace_back(value);
policies.emplace_back(policy); policies.emplace_back(policy);
} }
FeatureModel::FeatureValue::FeatureValue() FeatureModel::FeatureValue::FeatureValue(Function func)
{ {
this->func = func;
} }
std::string FeatureModel::FeatureDescription::featureValues() std::string FeatureModel::FeatureDescription::featureValues()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment