Hi Amir, The input is passed to the feature functions via InitializeForInput(InputType const& source). This method is called before search and collecting of translation options (cf. moses/FF/FeatureFunction.h). You can set a member variable to have access to the input in your scoring method.
Alternatively, if you implement EvaluateWithSourceContext(), the input is passed directly to the method as a parameter (const InputType &input) and you can use that. Finally, there's another option in the EvaluateWhenApplied() methods. You can get the input from the Hypothesis object: const InputType& input = hypo.GetManager().GetSource(); The input is an InputType object. Moses knows different input types, see InputTypeEnum in moses/TypeDef.h . So what you get might differ depending on what was passed to the decoder. If you're happy with implementing your feature for sentence input only, then you can cast the input to a Sentence object. The Sentence object gives you convenient access methods, in particular GetSize() and GetWord(size_t pos). You can thus obtain the sequence of words in the input. "Words" can contain several factors in Moses. The factor with index 0 is typically the surface form. Access it using the [] operator. I guess you will never really want to work directly with the string representation of the factor, but at this point you would be able to get it and for instance print it to your debug output. Hope this was helpful as another answer to your first question. Cheers, Matthias On Wed, 2014-12-10 at 11:41 +0330, amir haghighi wrote: > Hi everyone > > > > I'm implementing a feature function in moses-chart. I need the source > words string and also their indexes in the source sentence. I've > written a function that gets the source words but I don't know how > extract word string from a word. > could anyone guide me how to do that? as I know, each word is > implemented as an array of factors, which of them is its string? > > > I have also some questions about the states in the stateful features, > what kind of variables should be stored in each state? only those ones > that should be used in the compare function? or any variable from the > previous hypothesis that we use in our feature? > > > Thanks in advance! > > > Cheers > > Amir > > _______________________________________________ > Moses-support mailing list > Moses-support@mit.edu > http://mailman.mit.edu/mailman/listinfo/moses-support -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. _______________________________________________ Moses-support mailing list Moses-support@mit.edu http://mailman.mit.edu/mailman/listinfo/moses-support