oops, i forgot. In phrase-based decoding, the 1st hypothesis (in stack 0) have states created by the method
   StatefulFeatureFunction::EmptyHypothesisState()
that you have to override for every stateful ff. Put code to rest your state info here

On 11/03/2016 09:03, Jasneet Sabharwal wrote:
Hi Hieu,

Thank you for your reply. I tried both of these approaches.

In first case, I get an exception at NOT_FOUND. When I try to print the words range array, the minimum is always "wordsRange: [0..0]”.

In second case, "cur_hypo.GetWordsBitmap().GetNumWordsCovered() == 0” is never true as the minimum I get is equal to 1.

As, InitializeForInput() cannot be useful in my current situation, is there any other way to know when I start processing a new sentence?

Thank you and regards,
Jasneet
On Mar 9, 2016, at 3:41 PM, Hieu Hoang <[email protected] <mailto:[email protected]>> wrote:

i get ya. You can do

EvaluateWhenApplied(Hypothesis cur_hypo, FFState, ScoreComponenetCollection) {
If (cur_hypo.GetCurrSourceWordsRange() == NOT_FOUND) then {
LMState = CoarseLM->BeginSentenceState()
}
}

or

EvaluateWhenApplied(Hypothesis cur_hypo, FFState, ScoreComponenetCollection) {
If (cur_hypo.GetWordsBitmap().GetNumWordsCovered() == 0) then {
LMState = CoarseLM->BeginSentenceState()
}
}

Each FF can also override
     InitializeForInput()

This might not be suitable for you on this occasion, but it's worth bearing in mind


On 09/03/2016 23:20, Jasneet Sabharwal wrote:
Hi Hieu,

Thanks for replying. For example:

EvaluateWhenApplied(Hypothesis, FFState, ScoreComponenetCollection) {
If (processing a new source sentence), then {
LMState = CoarseLM->BeginSentenceState()
}
}

Here, I am trying to check if I am processing a new source sentence, so I should reset my language model states that I calling from my feature function.

Does this give an idea of what I am trying to do?

Regards,
Jasneet

On Mar 9, 2016, at 2:51 PM, Hieu Hoang <[email protected]> wrote:

can you give an example

Hieu Hoang
http://www.hoang.co.uk/hieu

On 9 March 2016 at 22:36, Jasneet Sabharwal <[email protected]> wrote:

    Hi Everyone,

    I have added a feature function in Moses. Is it possible to
    know through the Hypothesis parameter in “EvaluateWhenApplied”
    function that I am now processing the first state in a new
    source sentence. I would like to reset certain states whenever
    we start translating a new source sentence.

    Thank you for the help.

    Regards,
    Jasneet
    _______________________________________________
    Moses-support mailing list
    [email protected] <mailto:[email protected]>
    http://mailman.mit.edu/mailman/listinfo/moses-support






_______________________________________________
Moses-support mailing list
[email protected]
http://mailman.mit.edu/mailman/listinfo/moses-support

Reply via email to