That'll work

We could add a function to reset the number of scores but it's not a big 
priority

Sent from my flying horse

> On 14 Jun 2014, at 20:22, Marcin Junczys-Dowmunt <[email protected]> wrote:
> 
> Came up with something like that, still ugly, but works. num-features can be 
> specified too, and it will complain if it does not match the length of 
> "scores"
> 
> std::string ParseScores(const std::string &line, const std::string& 
> defaultScores) {
>   vector<string> toks = Tokenize(line);
>   UTIL_THROW_IF2(toks.empty(), "Empty line");
> 
>   for (size_t i = 1; i < toks.size(); ++i) {
>     std::vector<std::string> args = TokenizeFirstOnly(toks[i], "=");
>     UTIL_THROW_IF2(args.size() != 2,
>       "Incorrect format for feature function arg: " << toks[i]);
> 
>     if (args[0] == "scores") {
>       return args[1];
>     }
>   }
>   return defaultScores;
> }
> 
> EditOps::EditOps(const std::string &line)
>   : StatelessFeatureFunction(ParseScores(line, "mdis").size(), line),
>     m_factorType(0), m_chars(false), m_scores(ParseScores(line, "mdis"))
> {
>   std::cerr << "Initializing EditOps feature.." << std::endl;
>   ReadParameters();
> }
> 
> 
> W dniu 14.06.2014 20:28, Hieu Hoang pisze:
>> 
>> 
>> 
>>> On 14 June 2014 19:19, Marcin Junczys-Dowmunt <[email protected]> wrote:
>>> Actually, I do know it at construction time. For instance I specify a 
>>> string "scores=mdis" in the ini, every character in the value corresponds 
>>> to one type of score, so I have 4 feature scores. Setting again 
>>> "num-features=4" is redundant now (I guess I can still do that, but I don't 
>>> like it). I see the number of scores is set in the low-level function 
>>> ParseLine in the FeatureFunction class, should I override ParseLine in the 
>>> inherited class then?
>>  let's not override ParseLine yet. I can't see what's wrong with
>>    num-features=4
>> We need some kind of consistency 
>>  
>>> W dniu 14.06.2014 20:11, Hieu Hoang pisze:
>>> 
>>>> the number of scores must be set in the feature function constructor, 
>>>> there's no functionality to change it once its set
>>>> 
>>>> You might be better off using sparse features if you don't know how many 
>>>> scores you have at construction time
>>>> 
>>>> 
>>>>> On 14/06/14 09:17, Marcin Junczys-Dowmunt wrote:
>>>>> Hi,
>>>>> what's the trick for defining a feature function with a variable number
>>>>> of scores based on custom parameters in the ini-file?
>>>>> Just setting m_numScoreComponents = 2 in SetParameter(...) doesn't work.
>>>>> It seems the number of features is registered somewhere on object
>>>>> creation as I get the followiing message:
>>>>> 
>>>>> Exception: moses/ScoreComponentCollection.cpp:242 in void
>>>>> Moses::ScoreComponentCollection::Assign(const Moses::FeatureFunction*,
>>>>> const std::vector<float>&) threw util::Exception'.
>>>>> Feature function EditOps0 specified 1 dense scores or weights. Actually
>>>>> has 2
>>>>> 
>>>>> Thanks,
>>>>> Marcin
>>>>> 
>>>>> 
>>>>> _______________________________________________
>>>>> Moses-support mailing list
>>>>> [email protected]
>>>>> http://mailman.mit.edu/mailman/listinfo/moses-support
>> 
>> 
>> -- 
>> Hieu Hoang
>> Research Associate
>> University of Edinburgh
>> http://www.hoang.co.uk/hieu
> 
_______________________________________________
Moses-support mailing list
[email protected]
http://mailman.mit.edu/mailman/listinfo/moses-support

Reply via email to