From eecc4cbf5a6e28f910130cd4a58444e9d4701ea9 Mon Sep 17 00:00:00 2001 From: Kenneth Heafield Date: Mon, 27 Jan 2014 17:42:19 -0800 Subject: KenLM 5cc905bc2d214efa7de2db56a9a672b749a95591 --- klm/lm/facade.hh | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'klm/lm/facade.hh') diff --git a/klm/lm/facade.hh b/klm/lm/facade.hh index 8b186017..de1551f1 100644 --- a/klm/lm/facade.hh +++ b/klm/lm/facade.hh @@ -16,19 +16,28 @@ template class ModelFacade : publ typedef StateT State; typedef VocabularyT Vocabulary; - // Default Score function calls FullScore. Model can override this. - float Score(const State &in_state, const WordIndex new_word, State &out_state) const { - return static_cast(this)->FullScore(in_state, new_word, out_state).prob; - } - /* Translate from void* to State */ - FullScoreReturn FullScore(const void *in_state, const WordIndex new_word, void *out_state) const { + FullScoreReturn BaseFullScore(const void *in_state, const WordIndex new_word, void *out_state) const { return static_cast(this)->FullScore( *reinterpret_cast(in_state), new_word, *reinterpret_cast(out_state)); } - float Score(const void *in_state, const WordIndex new_word, void *out_state) const { + + FullScoreReturn BaseFullScoreForgotState(const WordIndex *context_rbegin, const WordIndex *context_rend, const WordIndex new_word, void *out_state) const { + return static_cast(this)->FullScoreForgotState( + context_rbegin, + context_rend, + new_word, + *reinterpret_cast(out_state)); + } + + // Default Score function calls FullScore. Model can override this. + float Score(const State &in_state, const WordIndex new_word, State &out_state) const { + return static_cast(this)->FullScore(in_state, new_word, out_state).prob; + } + + float BaseScore(const void *in_state, const WordIndex new_word, void *out_state) const { return static_cast(this)->Score( *reinterpret_cast(in_state), new_word, -- cgit v1.2.3