summaryrefslogtreecommitdiff
path: root/klm/lm/return.hh
diff options
context:
space:
mode:
authorKenneth Heafield <kenlm@kheafield.com>2011-09-21 18:23:50 -0400
committerKenneth Heafield <kenlm@kheafield.com>2011-09-21 18:23:50 -0400
commit83cae8bd92a2ebffcf2b8b4d2500766da008fe3d (patch)
tree575a54bbebc74eaafef6e9ebe4b37e6ad211b632 /klm/lm/return.hh
parent4b619c0ca5b8c521c6fb4c3df1c4b43756baa306 (diff)
Updated kenlm. Includes left state support but not the cdec-side use of it. Updated binary format.
Diffstat (limited to 'klm/lm/return.hh')
-rw-r--r--klm/lm/return.hh39
1 files changed, 39 insertions, 0 deletions
diff --git a/klm/lm/return.hh b/klm/lm/return.hh
new file mode 100644
index 00000000..15571960
--- /dev/null
+++ b/klm/lm/return.hh
@@ -0,0 +1,39 @@
+#ifndef LM_RETURN__
+#define LM_RETURN__
+
+#include <inttypes.h>
+
+namespace lm {
+/* Structure returned by scoring routines. */
+struct FullScoreReturn {
+ // log10 probability
+ float prob;
+
+ /* The length of n-gram matched. Do not use this for recombination.
+ * Consider a model containing only the following n-grams:
+ * -1 foo
+ * -3.14 bar
+ * -2.718 baz -5
+ * -6 foo bar
+ *
+ * If you score ``bar'' then ngram_length is 1 and recombination state is the
+ * empty string because bar has zero backoff and does not extend to the
+ * right.
+ * If you score ``foo'' then ngram_length is 1 and recombination state is
+ * ``foo''.
+ *
+ * Ideally, keep output states around and compare them. Failing that,
+ * get out_state.ValidLength() and use that length for recombination.
+ */
+ unsigned char ngram_length;
+
+ /* Left extension information. If independent_left is set, then prob is
+ * independent of words to the left (up to additional backoff). Otherwise,
+ * extend_left indicates how to efficiently extend further to the left.
+ */
+ bool independent_left;
+ uint64_t extend_left; // Defined only if independent_left
+};
+
+} // namespace lm
+#endif // LM_RETURN__