/* trigram-decoder.c generated by valac 0.26.0.83-ed603, the Vala compiler
 * generated from trigram-decoder.vala, do not modify */

/*
 * Copyright (C) 2012-2014 Daiki Ueno <ueno@gnu.org>
 * Copyright (C) 2012-2014 Red Hat, Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <gee.h>
#include <gobject/gvaluecollector.h>


#define KKC_TYPE_PATH_COST_FUNC (kkc_path_cost_func_get_type ())
#define KKC_PATH_COST_FUNC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_PATH_COST_FUNC, KkcPathCostFunc))
#define KKC_PATH_COST_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_PATH_COST_FUNC, KkcPathCostFuncClass))
#define KKC_IS_PATH_COST_FUNC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_PATH_COST_FUNC))
#define KKC_IS_PATH_COST_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_PATH_COST_FUNC))
#define KKC_PATH_COST_FUNC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_PATH_COST_FUNC, KkcPathCostFuncClass))

typedef struct _KkcPathCostFunc KkcPathCostFunc;
typedef struct _KkcPathCostFuncClass KkcPathCostFuncClass;
typedef struct _KkcPathCostFuncPrivate KkcPathCostFuncPrivate;

#define KKC_TYPE_LANGUAGE_MODEL (kkc_language_model_get_type ())
#define KKC_LANGUAGE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_LANGUAGE_MODEL, KkcLanguageModel))
#define KKC_LANGUAGE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_LANGUAGE_MODEL, KkcLanguageModelClass))
#define KKC_IS_LANGUAGE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_LANGUAGE_MODEL))
#define KKC_IS_LANGUAGE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_LANGUAGE_MODEL))
#define KKC_LANGUAGE_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_LANGUAGE_MODEL, KkcLanguageModelClass))

typedef struct _KkcLanguageModel KkcLanguageModel;
typedef struct _KkcLanguageModelClass KkcLanguageModelClass;

#define KKC_TYPE_UNIGRAM_LANGUAGE_MODEL (kkc_unigram_language_model_get_type ())
#define KKC_UNIGRAM_LANGUAGE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_UNIGRAM_LANGUAGE_MODEL, KkcUnigramLanguageModel))
#define KKC_IS_UNIGRAM_LANGUAGE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_UNIGRAM_LANGUAGE_MODEL))
#define KKC_UNIGRAM_LANGUAGE_MODEL_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), KKC_TYPE_UNIGRAM_LANGUAGE_MODEL, KkcUnigramLanguageModelIface))

typedef struct _KkcUnigramLanguageModel KkcUnigramLanguageModel;
typedef struct _KkcUnigramLanguageModelIface KkcUnigramLanguageModelIface;

#define KKC_TYPE_LANGUAGE_MODEL_ENTRY (kkc_language_model_entry_get_type ())
typedef struct _KkcLanguageModelEntry KkcLanguageModelEntry;

#define KKC_TYPE_BIGRAM_LANGUAGE_MODEL (kkc_bigram_language_model_get_type ())
#define KKC_BIGRAM_LANGUAGE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_BIGRAM_LANGUAGE_MODEL, KkcBigramLanguageModel))
#define KKC_IS_BIGRAM_LANGUAGE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_BIGRAM_LANGUAGE_MODEL))
#define KKC_BIGRAM_LANGUAGE_MODEL_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), KKC_TYPE_BIGRAM_LANGUAGE_MODEL, KkcBigramLanguageModelIface))

typedef struct _KkcBigramLanguageModel KkcBigramLanguageModel;
typedef struct _KkcBigramLanguageModelIface KkcBigramLanguageModelIface;

#define KKC_TYPE_TRIGRAM_LANGUAGE_MODEL (kkc_trigram_language_model_get_type ())
#define KKC_TRIGRAM_LANGUAGE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_TRIGRAM_LANGUAGE_MODEL, KkcTrigramLanguageModel))
#define KKC_IS_TRIGRAM_LANGUAGE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_TRIGRAM_LANGUAGE_MODEL))
#define KKC_TRIGRAM_LANGUAGE_MODEL_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), KKC_TYPE_TRIGRAM_LANGUAGE_MODEL, KkcTrigramLanguageModelIface))

typedef struct _KkcTrigramLanguageModel KkcTrigramLanguageModel;
typedef struct _KkcTrigramLanguageModelIface KkcTrigramLanguageModelIface;

#define KKC_TYPE_TRELLIS_NODE (kkc_trellis_node_get_type ())
#define KKC_TRELLIS_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_TRELLIS_NODE, KkcTrellisNode))
#define KKC_TRELLIS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_TRELLIS_NODE, KkcTrellisNodeClass))
#define KKC_IS_TRELLIS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_TRELLIS_NODE))
#define KKC_IS_TRELLIS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_TRELLIS_NODE))
#define KKC_TRELLIS_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_TRELLIS_NODE, KkcTrellisNodeClass))

typedef struct _KkcTrellisNode KkcTrellisNode;
typedef struct _KkcTrellisNodeClass KkcTrellisNodeClass;
typedef struct _KkcParamSpecPathCostFunc KkcParamSpecPathCostFunc;

#define KKC_TYPE_UNIGRAM_TO_UNIGRAM_PATH_COST_FUNC (kkc_unigram_to_unigram_path_cost_func_get_type ())
#define KKC_UNIGRAM_TO_UNIGRAM_PATH_COST_FUNC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_UNIGRAM_TO_UNIGRAM_PATH_COST_FUNC, KkcUnigramToUnigramPathCostFunc))
#define KKC_UNIGRAM_TO_UNIGRAM_PATH_COST_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_UNIGRAM_TO_UNIGRAM_PATH_COST_FUNC, KkcUnigramToUnigramPathCostFuncClass))
#define KKC_IS_UNIGRAM_TO_UNIGRAM_PATH_COST_FUNC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_UNIGRAM_TO_UNIGRAM_PATH_COST_FUNC))
#define KKC_IS_UNIGRAM_TO_UNIGRAM_PATH_COST_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_UNIGRAM_TO_UNIGRAM_PATH_COST_FUNC))
#define KKC_UNIGRAM_TO_UNIGRAM_PATH_COST_FUNC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_UNIGRAM_TO_UNIGRAM_PATH_COST_FUNC, KkcUnigramToUnigramPathCostFuncClass))

typedef struct _KkcUnigramToUnigramPathCostFunc KkcUnigramToUnigramPathCostFunc;
typedef struct _KkcUnigramToUnigramPathCostFuncClass KkcUnigramToUnigramPathCostFuncClass;
typedef struct _KkcUnigramToUnigramPathCostFuncPrivate KkcUnigramToUnigramPathCostFuncPrivate;

#define KKC_TYPE_UNIGRAM_TRELLIS_NODE (kkc_unigram_trellis_node_get_type ())
#define KKC_UNIGRAM_TRELLIS_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_UNIGRAM_TRELLIS_NODE, KkcUnigramTrellisNode))
#define KKC_UNIGRAM_TRELLIS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_UNIGRAM_TRELLIS_NODE, KkcUnigramTrellisNodeClass))
#define KKC_IS_UNIGRAM_TRELLIS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_UNIGRAM_TRELLIS_NODE))
#define KKC_IS_UNIGRAM_TRELLIS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_UNIGRAM_TRELLIS_NODE))
#define KKC_UNIGRAM_TRELLIS_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_UNIGRAM_TRELLIS_NODE, KkcUnigramTrellisNodeClass))

typedef struct _KkcUnigramTrellisNode KkcUnigramTrellisNode;
typedef struct _KkcUnigramTrellisNodeClass KkcUnigramTrellisNodeClass;
typedef struct _KkcTrellisNodePrivate KkcTrellisNodePrivate;

#define KKC_TYPE_BIGRAM_TRELLIS_NODE (kkc_bigram_trellis_node_get_type ())
#define KKC_BIGRAM_TRELLIS_NODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_BIGRAM_TRELLIS_NODE, KkcBigramTrellisNode))
#define KKC_BIGRAM_TRELLIS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_BIGRAM_TRELLIS_NODE, KkcBigramTrellisNodeClass))
#define KKC_IS_BIGRAM_TRELLIS_NODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_BIGRAM_TRELLIS_NODE))
#define KKC_IS_BIGRAM_TRELLIS_NODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_BIGRAM_TRELLIS_NODE))
#define KKC_BIGRAM_TRELLIS_NODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_BIGRAM_TRELLIS_NODE, KkcBigramTrellisNodeClass))

typedef struct _KkcBigramTrellisNode KkcBigramTrellisNode;
typedef struct _KkcBigramTrellisNodeClass KkcBigramTrellisNodeClass;
#define _kkc_trellis_node_unref0(var) ((var == NULL) ? NULL : (var = (kkc_trellis_node_unref (var), NULL)))

#define KKC_TYPE_UNIGRAM_TO_BIGRAM_PATH_COST_FUNC (kkc_unigram_to_bigram_path_cost_func_get_type ())
#define KKC_UNIGRAM_TO_BIGRAM_PATH_COST_FUNC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_UNIGRAM_TO_BIGRAM_PATH_COST_FUNC, KkcUnigramToBigramPathCostFunc))
#define KKC_UNIGRAM_TO_BIGRAM_PATH_COST_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_UNIGRAM_TO_BIGRAM_PATH_COST_FUNC, KkcUnigramToBigramPathCostFuncClass))
#define KKC_IS_UNIGRAM_TO_BIGRAM_PATH_COST_FUNC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_UNIGRAM_TO_BIGRAM_PATH_COST_FUNC))
#define KKC_IS_UNIGRAM_TO_BIGRAM_PATH_COST_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_UNIGRAM_TO_BIGRAM_PATH_COST_FUNC))
#define KKC_UNIGRAM_TO_BIGRAM_PATH_COST_FUNC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_UNIGRAM_TO_BIGRAM_PATH_COST_FUNC, KkcUnigramToBigramPathCostFuncClass))

typedef struct _KkcUnigramToBigramPathCostFunc KkcUnigramToBigramPathCostFunc;
typedef struct _KkcUnigramToBigramPathCostFuncClass KkcUnigramToBigramPathCostFuncClass;
typedef struct _KkcUnigramToBigramPathCostFuncPrivate KkcUnigramToBigramPathCostFuncPrivate;

#define KKC_TYPE_BIGRAM_TO_UNIGRAM_PATH_COST_FUNC (kkc_bigram_to_unigram_path_cost_func_get_type ())
#define KKC_BIGRAM_TO_UNIGRAM_PATH_COST_FUNC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_BIGRAM_TO_UNIGRAM_PATH_COST_FUNC, KkcBigramToUnigramPathCostFunc))
#define KKC_BIGRAM_TO_UNIGRAM_PATH_COST_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_BIGRAM_TO_UNIGRAM_PATH_COST_FUNC, KkcBigramToUnigramPathCostFuncClass))
#define KKC_IS_BIGRAM_TO_UNIGRAM_PATH_COST_FUNC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_BIGRAM_TO_UNIGRAM_PATH_COST_FUNC))
#define KKC_IS_BIGRAM_TO_UNIGRAM_PATH_COST_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_BIGRAM_TO_UNIGRAM_PATH_COST_FUNC))
#define KKC_BIGRAM_TO_UNIGRAM_PATH_COST_FUNC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_BIGRAM_TO_UNIGRAM_PATH_COST_FUNC, KkcBigramToUnigramPathCostFuncClass))

typedef struct _KkcBigramToUnigramPathCostFunc KkcBigramToUnigramPathCostFunc;
typedef struct _KkcBigramToUnigramPathCostFuncClass KkcBigramToUnigramPathCostFuncClass;
typedef struct _KkcBigramToUnigramPathCostFuncPrivate KkcBigramToUnigramPathCostFuncPrivate;

#define KKC_TYPE_BIGRAM_TO_BIGRAM_PATH_COST_FUNC (kkc_bigram_to_bigram_path_cost_func_get_type ())
#define KKC_BIGRAM_TO_BIGRAM_PATH_COST_FUNC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_BIGRAM_TO_BIGRAM_PATH_COST_FUNC, KkcBigramToBigramPathCostFunc))
#define KKC_BIGRAM_TO_BIGRAM_PATH_COST_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_BIGRAM_TO_BIGRAM_PATH_COST_FUNC, KkcBigramToBigramPathCostFuncClass))
#define KKC_IS_BIGRAM_TO_BIGRAM_PATH_COST_FUNC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_BIGRAM_TO_BIGRAM_PATH_COST_FUNC))
#define KKC_IS_BIGRAM_TO_BIGRAM_PATH_COST_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_BIGRAM_TO_BIGRAM_PATH_COST_FUNC))
#define KKC_BIGRAM_TO_BIGRAM_PATH_COST_FUNC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_BIGRAM_TO_BIGRAM_PATH_COST_FUNC, KkcBigramToBigramPathCostFuncClass))

typedef struct _KkcBigramToBigramPathCostFunc KkcBigramToBigramPathCostFunc;
typedef struct _KkcBigramToBigramPathCostFuncClass KkcBigramToBigramPathCostFuncClass;
typedef struct _KkcBigramToBigramPathCostFuncPrivate KkcBigramToBigramPathCostFuncPrivate;

#define KKC_TYPE_DECODER (kkc_decoder_get_type ())
#define KKC_DECODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_DECODER, KkcDecoder))
#define KKC_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_DECODER, KkcDecoderClass))
#define KKC_IS_DECODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_DECODER))
#define KKC_IS_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_DECODER))
#define KKC_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_DECODER, KkcDecoderClass))

typedef struct _KkcDecoder KkcDecoder;
typedef struct _KkcDecoderClass KkcDecoderClass;
typedef struct _KkcDecoderPrivate KkcDecoderPrivate;

#define KKC_TYPE_SEGMENT (kkc_segment_get_type ())
#define KKC_SEGMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_SEGMENT, KkcSegment))
#define KKC_SEGMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_SEGMENT, KkcSegmentClass))
#define KKC_IS_SEGMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_SEGMENT))
#define KKC_IS_SEGMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_SEGMENT))
#define KKC_SEGMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_SEGMENT, KkcSegmentClass))

typedef struct _KkcSegment KkcSegment;
typedef struct _KkcSegmentClass KkcSegmentClass;

#define KKC_TYPE_BIGRAM_DECODER (kkc_bigram_decoder_get_type ())
#define KKC_BIGRAM_DECODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_BIGRAM_DECODER, KkcBigramDecoder))
#define KKC_BIGRAM_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_BIGRAM_DECODER, KkcBigramDecoderClass))
#define KKC_IS_BIGRAM_DECODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_BIGRAM_DECODER))
#define KKC_IS_BIGRAM_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_BIGRAM_DECODER))
#define KKC_BIGRAM_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_BIGRAM_DECODER, KkcBigramDecoderClass))

typedef struct _KkcBigramDecoder KkcBigramDecoder;
typedef struct _KkcBigramDecoderClass KkcBigramDecoderClass;
typedef struct _KkcBigramDecoderPrivate KkcBigramDecoderPrivate;

#define KKC_TYPE_TRIGRAM_DECODER (kkc_trigram_decoder_get_type ())
#define KKC_TRIGRAM_DECODER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KKC_TYPE_TRIGRAM_DECODER, KkcTrigramDecoder))
#define KKC_TRIGRAM_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KKC_TYPE_TRIGRAM_DECODER, KkcTrigramDecoderClass))
#define KKC_IS_TRIGRAM_DECODER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KKC_TYPE_TRIGRAM_DECODER))
#define KKC_IS_TRIGRAM_DECODER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KKC_TYPE_TRIGRAM_DECODER))
#define KKC_TRIGRAM_DECODER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KKC_TYPE_TRIGRAM_DECODER, KkcTrigramDecoderClass))

typedef struct _KkcTrigramDecoder KkcTrigramDecoder;
typedef struct _KkcTrigramDecoderClass KkcTrigramDecoderClass;
typedef struct _KkcTrigramDecoderPrivate KkcTrigramDecoderPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _kkc_path_cost_func_unref0(var) ((var == NULL) ? NULL : (var = (kkc_path_cost_func_unref (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _KkcLanguageModelEntry {
	gchar* input;
	gchar* output;
	guint id;
};

struct _KkcUnigramLanguageModelIface {
	GTypeInterface parent_iface;
	gdouble (*unigram_cost) (KkcUnigramLanguageModel* self, KkcLanguageModelEntry* entry);
	gdouble (*unigram_backoff) (KkcUnigramLanguageModel* self, KkcLanguageModelEntry* entry);
};

struct _KkcBigramLanguageModelIface {
	GTypeInterface parent_iface;
	gboolean (*has_bigram) (KkcBigramLanguageModel* self, KkcLanguageModelEntry* pentry, KkcLanguageModelEntry* entry);
	gdouble (*bigram_cost) (KkcBigramLanguageModel* self, KkcLanguageModelEntry* pentry, KkcLanguageModelEntry* entry);
	gdouble (*bigram_backoff) (KkcBigramLanguageModel* self, KkcLanguageModelEntry* pentry, KkcLanguageModelEntry* entry);
};

struct _KkcTrigramLanguageModelIface {
	GTypeInterface parent_iface;
	gboolean (*has_trigram) (KkcTrigramLanguageModel* self, KkcLanguageModelEntry* ppentry, KkcLanguageModelEntry* pentry, KkcLanguageModelEntry* entry);
	gdouble (*trigram_cost) (KkcTrigramLanguageModel* self, KkcLanguageModelEntry* ppentry, KkcLanguageModelEntry* pentry, KkcLanguageModelEntry* entry);
};

struct _KkcPathCostFunc {
	GTypeInstance parent_instance;
	volatile int ref_count;
	KkcPathCostFuncPrivate * priv;
};

struct _KkcPathCostFuncClass {
	GTypeClass parent_class;
	void (*finalize) (KkcPathCostFunc *self);
	gdouble (*path_cost) (KkcPathCostFunc* self, KkcTrigramLanguageModel* model, KkcTrellisNode* pnode, KkcTrellisNode* node);
};

struct _KkcParamSpecPathCostFunc {
	GParamSpec parent_instance;
};

struct _KkcUnigramToUnigramPathCostFunc {
	KkcPathCostFunc parent_instance;
	KkcUnigramToUnigramPathCostFuncPrivate * priv;
};

struct _KkcUnigramToUnigramPathCostFuncClass {
	KkcPathCostFuncClass parent_class;
};

struct _KkcTrellisNode {
	GTypeInstance parent_instance;
	volatile int ref_count;
	KkcTrellisNodePrivate * priv;
	KkcTrellisNode* previous;
	gdouble cumulative_cost;
};

struct _KkcTrellisNodeClass {
	GTypeClass parent_class;
	void (*finalize) (KkcTrellisNode *self);
	gchar* (*to_string) (KkcTrellisNode* self);
	guint (*get_endpos) (KkcTrellisNode* self);
	guint (*get_length) (KkcTrellisNode* self);
	const gchar* (*get_input) (KkcTrellisNode* self);
	const gchar* (*get_output) (KkcTrellisNode* self);
	KkcLanguageModelEntry* (*get_entries) (KkcTrellisNode* self, int* result_length1);
};

struct _KkcUnigramToBigramPathCostFunc {
	KkcPathCostFunc parent_instance;
	KkcUnigramToBigramPathCostFuncPrivate * priv;
};

struct _KkcUnigramToBigramPathCostFuncClass {
	KkcPathCostFuncClass parent_class;
};

struct _KkcBigramToUnigramPathCostFunc {
	KkcPathCostFunc parent_instance;
	KkcBigramToUnigramPathCostFuncPrivate * priv;
};

struct _KkcBigramToUnigramPathCostFuncClass {
	KkcPathCostFuncClass parent_class;
};

struct _KkcBigramToBigramPathCostFunc {
	KkcPathCostFunc parent_instance;
	KkcBigramToBigramPathCostFuncPrivate * priv;
};

struct _KkcBigramToBigramPathCostFuncClass {
	KkcPathCostFuncClass parent_class;
};

struct _KkcDecoder {
	GObject parent_instance;
	KkcDecoderPrivate * priv;
};

struct _KkcDecoderClass {
	GObjectClass parent_class;
	KkcSegment** (*decode) (KkcDecoder* self, const gchar* input, gint nbest, gint* constraint, int constraint_length1, int* result_length1);
	KkcSegment** (*decode_with_costs) (KkcDecoder* self, const gchar* input, gint nbest, gint* constraint, int constraint_length1, gdouble max_distance, gdouble min_path_cost, int* result_length1);
};

struct _KkcBigramDecoder {
	KkcDecoder parent_instance;
	KkcBigramDecoderPrivate * priv;
};

struct _KkcBigramDecoderClass {
	KkcDecoderClass parent_class;
	gdouble (*path_cost) (KkcBigramDecoder* self, KkcTrellisNode* pnode, KkcTrellisNode* node, gint endpos);
};

struct _KkcTrigramDecoder {
	KkcBigramDecoder parent_instance;
	KkcTrigramDecoderPrivate * priv;
};

struct _KkcTrigramDecoderClass {
	KkcBigramDecoderClass parent_class;
};

struct _KkcTrigramDecoderPrivate {
	KkcPathCostFunc* path_cost_funcs[4];
};


static gpointer kkc_path_cost_func_parent_class = NULL;
static gpointer kkc_unigram_to_unigram_path_cost_func_parent_class = NULL;
static gpointer kkc_unigram_to_bigram_path_cost_func_parent_class = NULL;
static gpointer kkc_bigram_to_unigram_path_cost_func_parent_class = NULL;
static gpointer kkc_bigram_to_bigram_path_cost_func_parent_class = NULL;
static gpointer kkc_trigram_decoder_parent_class = NULL;

gpointer kkc_path_cost_func_ref (gpointer instance);
void kkc_path_cost_func_unref (gpointer instance);
GParamSpec* kkc_param_spec_path_cost_func (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void kkc_value_set_path_cost_func (GValue* value, gpointer v_object);
void kkc_value_take_path_cost_func (GValue* value, gpointer v_object);
gpointer kkc_value_get_path_cost_func (const GValue* value);
GType kkc_path_cost_func_get_type (void) G_GNUC_CONST;
GType kkc_language_model_get_type (void) G_GNUC_CONST;
GType kkc_language_model_entry_get_type (void) G_GNUC_CONST;
KkcLanguageModelEntry* kkc_language_model_entry_dup (const KkcLanguageModelEntry* self);
void kkc_language_model_entry_free (KkcLanguageModelEntry* self);
void kkc_language_model_entry_copy (const KkcLanguageModelEntry* self, KkcLanguageModelEntry* dest);
void kkc_language_model_entry_destroy (KkcLanguageModelEntry* self);
GType kkc_unigram_language_model_get_type (void) G_GNUC_CONST;
GType kkc_bigram_language_model_get_type (void) G_GNUC_CONST;
GType kkc_trigram_language_model_get_type (void) G_GNUC_CONST;
gpointer kkc_trellis_node_ref (gpointer instance);
void kkc_trellis_node_unref (gpointer instance);
GParamSpec* kkc_param_spec_trellis_node (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void kkc_value_set_trellis_node (GValue* value, gpointer v_object);
void kkc_value_take_trellis_node (GValue* value, gpointer v_object);
gpointer kkc_value_get_trellis_node (const GValue* value);
GType kkc_trellis_node_get_type (void) G_GNUC_CONST;
enum  {
	KKC_PATH_COST_FUNC_DUMMY_PROPERTY
};
gdouble kkc_path_cost_func_path_cost (KkcPathCostFunc* self, KkcTrigramLanguageModel* model, KkcTrellisNode* pnode, KkcTrellisNode* node);
static gdouble kkc_path_cost_func_real_path_cost (KkcPathCostFunc* self, KkcTrigramLanguageModel* model, KkcTrellisNode* pnode, KkcTrellisNode* node);
KkcPathCostFunc* kkc_path_cost_func_construct (GType object_type);
static void kkc_path_cost_func_finalize (KkcPathCostFunc* obj);
GType kkc_unigram_to_unigram_path_cost_func_get_type (void) G_GNUC_CONST;
enum  {
	KKC_UNIGRAM_TO_UNIGRAM_PATH_COST_FUNC_DUMMY_PROPERTY
};
static gdouble kkc_unigram_to_unigram_path_cost_func_real_path_cost (KkcPathCostFunc* base, KkcTrigramLanguageModel* model, KkcTrellisNode* pnode, KkcTrellisNode* node);
GType kkc_unigram_trellis_node_get_type (void) G_GNUC_CONST;
void kkc_unigram_trellis_node_get_entry (KkcUnigramTrellisNode* self, KkcLanguageModelEntry* result);
void kkc_language_model_get_bos (KkcLanguageModel* self, KkcLanguageModelEntry* result);
static gboolean _kkc_language_model_entry_equal (const KkcLanguageModelEntry* s1, const KkcLanguageModelEntry* s2);
gdouble kkc_bigram_language_model_bigram_backoff_cost (KkcBigramLanguageModel* self, KkcLanguageModelEntry* pentry, KkcLanguageModelEntry* entry);
gdouble kkc_trigram_language_model_trigram_backoff_cost (KkcTrigramLanguageModel* self, KkcLanguageModelEntry* ppentry, KkcLanguageModelEntry* pentry, KkcLanguageModelEntry* entry);
GType kkc_bigram_trellis_node_get_type (void) G_GNUC_CONST;
KkcUnigramTrellisNode* kkc_bigram_trellis_node_get_right_node (KkcBigramTrellisNode* self);
KkcUnigramToUnigramPathCostFunc* kkc_unigram_to_unigram_path_cost_func_new (void);
KkcUnigramToUnigramPathCostFunc* kkc_unigram_to_unigram_path_cost_func_construct (GType object_type);
GType kkc_unigram_to_bigram_path_cost_func_get_type (void) G_GNUC_CONST;
enum  {
	KKC_UNIGRAM_TO_BIGRAM_PATH_COST_FUNC_DUMMY_PROPERTY
};
static gdouble kkc_unigram_to_bigram_path_cost_func_real_path_cost (KkcPathCostFunc* base, KkcTrigramLanguageModel* model, KkcTrellisNode* pnode, KkcTrellisNode* node);
KkcUnigramTrellisNode* kkc_bigram_trellis_node_get_left_node (KkcBigramTrellisNode* self);
KkcUnigramToBigramPathCostFunc* kkc_unigram_to_bigram_path_cost_func_new (void);
KkcUnigramToBigramPathCostFunc* kkc_unigram_to_bigram_path_cost_func_construct (GType object_type);
GType kkc_bigram_to_unigram_path_cost_func_get_type (void) G_GNUC_CONST;
enum  {
	KKC_BIGRAM_TO_UNIGRAM_PATH_COST_FUNC_DUMMY_PROPERTY
};
static gdouble kkc_bigram_to_unigram_path_cost_func_real_path_cost (KkcPathCostFunc* base, KkcTrigramLanguageModel* model, KkcTrellisNode* pnode, KkcTrellisNode* node);
KkcBigramToUnigramPathCostFunc* kkc_bigram_to_unigram_path_cost_func_new (void);
KkcBigramToUnigramPathCostFunc* kkc_bigram_to_unigram_path_cost_func_construct (GType object_type);
GType kkc_bigram_to_bigram_path_cost_func_get_type (void) G_GNUC_CONST;
enum  {
	KKC_BIGRAM_TO_BIGRAM_PATH_COST_FUNC_DUMMY_PROPERTY
};
static gdouble kkc_bigram_to_bigram_path_cost_func_real_path_cost (KkcPathCostFunc* base, KkcTrigramLanguageModel* model, KkcTrellisNode* pnode, KkcTrellisNode* node);
KkcBigramToBigramPathCostFunc* kkc_bigram_to_bigram_path_cost_func_new (void);
KkcBigramToBigramPathCostFunc* kkc_bigram_to_bigram_path_cost_func_construct (GType object_type);
GType kkc_decoder_get_type (void) G_GNUC_CONST;
GType kkc_segment_get_type (void) G_GNUC_CONST;
GType kkc_bigram_decoder_get_type (void) G_GNUC_CONST;
GType kkc_trigram_decoder_get_type (void) G_GNUC_CONST;
#define KKC_TRIGRAM_DECODER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), KKC_TYPE_TRIGRAM_DECODER, KkcTrigramDecoderPrivate))
enum  {
	KKC_TRIGRAM_DECODER_DUMMY_PROPERTY
};
static KkcSegment** kkc_trigram_decoder_real_decode (KkcDecoder* base, const gchar* input, gint nbest, gint* constraint, int constraint_length1, int* result_length1);
KkcSegment** kkc_decoder_decode_with_costs (KkcDecoder* self, const gchar* input, gint nbest, gint* constraint, int constraint_length1, gdouble max_distance, gdouble min_path_cost, int* result_length1);
static KkcSegment** kkc_trigram_decoder_real_decode_with_costs (KkcDecoder* base, const gchar* input, gint nbest, gint* constraint, int constraint_length1, gdouble max_distance, gdouble min_path_cost, int* result_length1);
GeeArrayList** kkc_bigram_decoder_build_trellis (KkcBigramDecoder* self, const gchar* input, gint* constraint, int constraint_length1, int* result_length1);
static void kkc_trigram_decoder_add_trigram_nodes (KkcTrigramDecoder* self, GeeArrayList** trellis, int trellis_length1);
void kkc_bigram_decoder_add_unknown_nodes (KkcBigramDecoder* self, GeeArrayList** trellis, int trellis_length1, const gchar* input, gint* constraint, int constraint_length1);
void kkc_bigram_decoder_forward_search (KkcBigramDecoder* self, GeeArrayList** trellis, int trellis_length1, const gchar* input);
KkcSegment** kkc_bigram_decoder_backward_search (KkcBigramDecoder* self, GeeArrayList** trellis, int trellis_length1, gint nbest, gdouble max_distance, gdouble min_path_cost, int* result_length1);
guint kkc_trellis_node_get_length (KkcTrellisNode* self);
KkcBigramLanguageModel* kkc_bigram_decoder_get_model (KkcBigramDecoder* self);
gboolean kkc_bigram_language_model_has_bigram (KkcBigramLanguageModel* self, KkcLanguageModelEntry* pentry, KkcLanguageModelEntry* entry);
gboolean kkc_trigram_language_model_has_trigram (KkcTrigramLanguageModel* self, KkcLanguageModelEntry* ppentry, KkcLanguageModelEntry* pentry, KkcLanguageModelEntry* entry);
KkcBigramTrellisNode* kkc_bigram_trellis_node_new (KkcUnigramTrellisNode* left_node, KkcUnigramTrellisNode* right_node, guint endpos);
KkcBigramTrellisNode* kkc_bigram_trellis_node_construct (GType object_type, KkcUnigramTrellisNode* left_node, KkcUnigramTrellisNode* right_node, guint endpos);
static gint kkc_trigram_decoder_path_to_func_index (KkcTrigramDecoder* self, KkcTrellisNode* pnode, KkcTrellisNode* node);
static gdouble kkc_trigram_decoder_real_path_cost (KkcBigramDecoder* base, KkcTrellisNode* pnode, KkcTrellisNode* node, gint endpos);
KkcTrigramDecoder* kkc_trigram_decoder_new (KkcTrigramLanguageModel* model);
KkcTrigramDecoder* kkc_trigram_decoder_construct (GType object_type, KkcTrigramLanguageModel* model);
KkcBigramDecoder* kkc_bigram_decoder_new (KkcBigramLanguageModel* model);
KkcBigramDecoder* kkc_bigram_decoder_construct (GType object_type, KkcBigramLanguageModel* model);
static void kkc_trigram_decoder_finalize (GObject* obj);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);


static gdouble kkc_path_cost_func_real_path_cost (KkcPathCostFunc* self, KkcTrigramLanguageModel* model, KkcTrellisNode* pnode, KkcTrellisNode* node) {
	g_critical ("Type `%s' does not implement abstract method `kkc_path_cost_func_path_cost'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return 0.0;
}


gdouble kkc_path_cost_func_path_cost (KkcPathCostFunc* self, KkcTrigramLanguageModel* model, KkcTrellisNode* pnode, KkcTrellisNode* node) {
	g_return_val_if_fail (self != NULL, 0.0);
	return KKC_PATH_COST_FUNC_GET_CLASS (self)->path_cost (self, model, pnode, node);
}


KkcPathCostFunc* kkc_path_cost_func_construct (GType object_type) {
	KkcPathCostFunc* self = NULL;
	self = (KkcPathCostFunc*) g_type_create_instance (object_type);
	return self;
}


static void kkc_value_path_cost_func_init (GValue* value) {
	value->data[0].v_pointer = NULL;
}


static void kkc_value_path_cost_func_free_value (GValue* value) {
	if (value->data[0].v_pointer) {
		kkc_path_cost_func_unref (value->data[0].v_pointer);
	}
}


static void kkc_value_path_cost_func_copy_value (const GValue* src_value, GValue* dest_value) {
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = kkc_path_cost_func_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}


static gpointer kkc_value_path_cost_func_peek_pointer (const GValue* value) {
	return value->data[0].v_pointer;
}


static gchar* kkc_value_path_cost_func_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	if (collect_values[0].v_pointer) {
		KkcPathCostFunc* object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = kkc_path_cost_func_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}


static gchar* kkc_value_path_cost_func_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
	KkcPathCostFunc** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = kkc_path_cost_func_ref (value->data[0].v_pointer);
	}
	return NULL;
}


GParamSpec* kkc_param_spec_path_cost_func (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
	KkcParamSpecPathCostFunc* spec;
	g_return_val_if_fail (g_type_is_a (object_type, KKC_TYPE_PATH_COST_FUNC), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}


gpointer kkc_value_get_path_cost_func (const GValue* value) {
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, KKC_TYPE_PATH_COST_FUNC), NULL);
	return value->data[0].v_pointer;
}


void kkc_value_set_path_cost_func (GValue* value, gpointer v_object) {
	KkcPathCostFunc* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, KKC_TYPE_PATH_COST_FUNC));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, KKC_TYPE_PATH_COST_FUNC));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		kkc_path_cost_func_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		kkc_path_cost_func_unref (old);
	}
}


void kkc_value_take_path_cost_func (GValue* value, gpointer v_object) {
	KkcPathCostFunc* old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, KKC_TYPE_PATH_COST_FUNC));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, KKC_TYPE_PATH_COST_FUNC));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		kkc_path_cost_func_unref (old);
	}
}


static void kkc_path_cost_func_class_init (KkcPathCostFuncClass * klass) {
	kkc_path_cost_func_parent_class = g_type_class_peek_parent (klass);
	((KkcPathCostFuncClass *) klass)->finalize = kkc_path_cost_func_finalize;
	((KkcPathCostFuncClass *) klass)->path_cost = kkc_path_cost_func_real_path_cost;
}


static void kkc_path_cost_func_instance_init (KkcPathCostFunc * self) {
	self->ref_count = 1;
}


static void kkc_path_cost_func_finalize (KkcPathCostFunc* obj) {
	KkcPathCostFunc * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KKC_TYPE_PATH_COST_FUNC, KkcPathCostFunc);
	g_signal_handlers_destroy (self);
}


GType kkc_path_cost_func_get_type (void) {
	static volatile gsize kkc_path_cost_func_type_id__volatile = 0;
	if (g_once_init_enter (&kkc_path_cost_func_type_id__volatile)) {
		static const GTypeValueTable g_define_type_value_table = { kkc_value_path_cost_func_init, kkc_value_path_cost_func_free_value, kkc_value_path_cost_func_copy_value, kkc_value_path_cost_func_peek_pointer, "p", kkc_value_path_cost_func_collect_value, "p", kkc_value_path_cost_func_lcopy_value };
		static const GTypeInfo g_define_type_info = { sizeof (KkcPathCostFuncClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_path_cost_func_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcPathCostFunc), 0, (GInstanceInitFunc) kkc_path_cost_func_instance_init, &g_define_type_value_table };
		static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
		GType kkc_path_cost_func_type_id;
		kkc_path_cost_func_type_id = g_type_register_fundamental (g_type_fundamental_next (), "KkcPathCostFunc", &g_define_type_info, &g_define_type_fundamental_info, G_TYPE_FLAG_ABSTRACT);
		g_once_init_leave (&kkc_path_cost_func_type_id__volatile, kkc_path_cost_func_type_id);
	}
	return kkc_path_cost_func_type_id__volatile;
}


gpointer kkc_path_cost_func_ref (gpointer instance) {
	KkcPathCostFunc* self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}


void kkc_path_cost_func_unref (gpointer instance) {
	KkcPathCostFunc* self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		KKC_PATH_COST_FUNC_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}


static gpointer _kkc_trellis_node_ref0 (gpointer self) {
	return self ? kkc_trellis_node_ref (self) : NULL;
}


static gboolean _kkc_language_model_entry_equal (const KkcLanguageModelEntry* s1, const KkcLanguageModelEntry* s2) {
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	if (g_strcmp0 (s1->input, s2->input)) {
		return FALSE;
	}
	if (g_strcmp0 (s1->output, s2->output)) {
		return FALSE;
	}
	if (s1->id != s2->id) {
		return FALSE;
	}
	return TRUE;
}


static gdouble kkc_unigram_to_unigram_path_cost_func_real_path_cost (KkcPathCostFunc* base, KkcTrigramLanguageModel* model, KkcTrellisNode* pnode, KkcTrellisNode* node) {
	KkcUnigramToUnigramPathCostFunc * self;
	gdouble result = 0.0;
	KkcTrellisNode* _tmp0_ = NULL;
	KkcTrellisNode* _tmp1_ = NULL;
	KkcUnigramTrellisNode* upnode = NULL;
	KkcTrellisNode* _tmp2_ = NULL;
	KkcUnigramTrellisNode* _tmp3_ = NULL;
	KkcUnigramTrellisNode* unode = NULL;
	KkcTrellisNode* _tmp4_ = NULL;
	KkcUnigramTrellisNode* _tmp5_ = NULL;
	gdouble cost = 0.0;
	KkcUnigramTrellisNode* _tmp6_ = NULL;
	KkcLanguageModelEntry _tmp7_ = {0};
	KkcLanguageModelEntry _tmp8_ = {0};
	KkcTrigramLanguageModel* _tmp9_ = NULL;
	KkcLanguageModelEntry _tmp10_ = {0};
	KkcLanguageModelEntry _tmp11_ = {0};
	self = (KkcUnigramToUnigramPathCostFunc*) base;
	g_return_val_if_fail (model != NULL, 0.0);
	g_return_val_if_fail (pnode != NULL, 0.0);
	g_return_val_if_fail (node != NULL, 0.0);
	_tmp0_ = pnode;
	_vala_assert (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, KKC_TYPE_UNIGRAM_TRELLIS_NODE), "pnode is UnigramTrellisNode");
	_tmp1_ = node;
	_vala_assert (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, KKC_TYPE_UNIGRAM_TRELLIS_NODE), "node is UnigramTrellisNode");
	_tmp2_ = pnode;
	_tmp3_ = _kkc_trellis_node_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, KKC_TYPE_UNIGRAM_TRELLIS_NODE, KkcUnigramTrellisNode));
	upnode = _tmp3_;
	_tmp4_ = node;
	_tmp5_ = _kkc_trellis_node_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, KKC_TYPE_UNIGRAM_TRELLIS_NODE, KkcUnigramTrellisNode));
	unode = _tmp5_;
	cost = 0.0;
	_tmp6_ = upnode;
	kkc_unigram_trellis_node_get_entry (_tmp6_, &_tmp7_);
	_tmp8_ = _tmp7_;
	_tmp9_ = model;
	kkc_language_model_get_bos ((KkcLanguageModel*) _tmp9_, &_tmp10_);
	_tmp11_ = _tmp10_;
	if (_kkc_language_model_entry_equal (&_tmp8_, &_tmp11_) == TRUE) {
		KkcTrigramLanguageModel* _tmp12_ = NULL;
		KkcUnigramTrellisNode* _tmp13_ = NULL;
		KkcLanguageModelEntry _tmp14_ = {0};
		KkcLanguageModelEntry _tmp15_ = {0};
		KkcUnigramTrellisNode* _tmp16_ = NULL;
		KkcLanguageModelEntry _tmp17_ = {0};
		KkcLanguageModelEntry _tmp18_ = {0};
		gdouble _tmp19_ = 0.0;
		_tmp12_ = model;
		_tmp13_ = upnode;
		kkc_unigram_trellis_node_get_entry (_tmp13_, &_tmp14_);
		_tmp15_ = _tmp14_;
		_tmp16_ = unode;
		kkc_unigram_trellis_node_get_entry (_tmp16_, &_tmp17_);
		_tmp18_ = _tmp17_;
		_tmp19_ = kkc_bigram_language_model_bigram_backoff_cost ((KkcBigramLanguageModel*) _tmp12_, &_tmp15_, &_tmp18_);
		cost = _tmp19_;
	} else {
		KkcUnigramTrellisNode* _tmp20_ = NULL;
		KkcTrellisNode* _tmp21_ = NULL;
		_tmp20_ = upnode;
		_tmp21_ = ((KkcTrellisNode*) _tmp20_)->previous;
		if (_tmp21_ != NULL) {
			KkcUnigramTrellisNode* _tmp22_ = NULL;
			KkcTrellisNode* _tmp23_ = NULL;
			_tmp22_ = upnode;
			_tmp23_ = ((KkcTrellisNode*) _tmp22_)->previous;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp23_, KKC_TYPE_UNIGRAM_TRELLIS_NODE)) {
				KkcTrigramLanguageModel* _tmp24_ = NULL;
				KkcUnigramTrellisNode* _tmp25_ = NULL;
				KkcTrellisNode* _tmp26_ = NULL;
				KkcLanguageModelEntry _tmp27_ = {0};
				KkcLanguageModelEntry _tmp28_ = {0};
				KkcUnigramTrellisNode* _tmp29_ = NULL;
				KkcLanguageModelEntry _tmp30_ = {0};
				KkcLanguageModelEntry _tmp31_ = {0};
				KkcUnigramTrellisNode* _tmp32_ = NULL;
				KkcLanguageModelEntry _tmp33_ = {0};
				KkcLanguageModelEntry _tmp34_ = {0};
				gdouble _tmp35_ = 0.0;
				_tmp24_ = model;
				_tmp25_ = upnode;
				_tmp26_ = ((KkcTrellisNode*) _tmp25_)->previous;
				kkc_unigram_trellis_node_get_entry (G_TYPE_CHECK_INSTANCE_CAST (_tmp26_, KKC_TYPE_UNIGRAM_TRELLIS_NODE, KkcUnigramTrellisNode), &_tmp27_);
				_tmp28_ = _tmp27_;
				_tmp29_ = upnode;
				kkc_unigram_trellis_node_get_entry (_tmp29_, &_tmp30_);
				_tmp31_ = _tmp30_;
				_tmp32_ = unode;
				kkc_unigram_trellis_node_get_entry (_tmp32_, &_tmp33_);
				_tmp34_ = _tmp33_;
				_tmp35_ = kkc_trigram_language_model_trigram_backoff_cost (_tmp24_, &_tmp28_, &_tmp31_, &_tmp34_);
				cost = _tmp35_;
			} else {
				KkcTrigramLanguageModel* _tmp36_ = NULL;
				KkcUnigramTrellisNode* _tmp37_ = NULL;
				KkcTrellisNode* _tmp38_ = NULL;
				KkcUnigramTrellisNode* _tmp39_ = NULL;
				KkcUnigramTrellisNode* _tmp40_ = NULL;
				KkcLanguageModelEntry _tmp41_ = {0};
				KkcLanguageModelEntry _tmp42_ = {0};
				KkcUnigramTrellisNode* _tmp43_ = NULL;
				KkcLanguageModelEntry _tmp44_ = {0};
				KkcLanguageModelEntry _tmp45_ = {0};
				KkcUnigramTrellisNode* _tmp46_ = NULL;
				KkcLanguageModelEntry _tmp47_ = {0};
				KkcLanguageModelEntry _tmp48_ = {0};
				gdouble _tmp49_ = 0.0;
				_tmp36_ = model;
				_tmp37_ = upnode;
				_tmp38_ = ((KkcTrellisNode*) _tmp37_)->previous;
				_tmp39_ = kkc_bigram_trellis_node_get_right_node (G_TYPE_CHECK_INSTANCE_CAST (_tmp38_, KKC_TYPE_BIGRAM_TRELLIS_NODE, KkcBigramTrellisNode));
				_tmp40_ = _tmp39_;
				kkc_unigram_trellis_node_get_entry (_tmp40_, &_tmp41_);
				_tmp42_ = _tmp41_;
				_tmp43_ = upnode;
				kkc_unigram_trellis_node_get_entry (_tmp43_, &_tmp44_);
				_tmp45_ = _tmp44_;
				_tmp46_ = unode;
				kkc_unigram_trellis_node_get_entry (_tmp46_, &_tmp47_);
				_tmp48_ = _tmp47_;
				_tmp49_ = kkc_trigram_language_model_trigram_backoff_cost (_tmp36_, &_tmp42_, &_tmp45_, &_tmp48_);
				cost = _tmp49_;
			}
		}
	}
	result = cost;
	_kkc_trellis_node_unref0 (unode);
	_kkc_trellis_node_unref0 (upnode);
	return result;
}


KkcUnigramToUnigramPathCostFunc* kkc_unigram_to_unigram_path_cost_func_construct (GType object_type) {
	KkcUnigramToUnigramPathCostFunc* self = NULL;
	self = (KkcUnigramToUnigramPathCostFunc*) kkc_path_cost_func_construct (object_type);
	return self;
}


KkcUnigramToUnigramPathCostFunc* kkc_unigram_to_unigram_path_cost_func_new (void) {
	return kkc_unigram_to_unigram_path_cost_func_construct (KKC_TYPE_UNIGRAM_TO_UNIGRAM_PATH_COST_FUNC);
}


static void kkc_unigram_to_unigram_path_cost_func_class_init (KkcUnigramToUnigramPathCostFuncClass * klass) {
	kkc_unigram_to_unigram_path_cost_func_parent_class = g_type_class_peek_parent (klass);
	((KkcPathCostFuncClass *) klass)->path_cost = kkc_unigram_to_unigram_path_cost_func_real_path_cost;
}


static void kkc_unigram_to_unigram_path_cost_func_instance_init (KkcUnigramToUnigramPathCostFunc * self) {
}


GType kkc_unigram_to_unigram_path_cost_func_get_type (void) {
	static volatile gsize kkc_unigram_to_unigram_path_cost_func_type_id__volatile = 0;
	if (g_once_init_enter (&kkc_unigram_to_unigram_path_cost_func_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (KkcUnigramToUnigramPathCostFuncClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_unigram_to_unigram_path_cost_func_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcUnigramToUnigramPathCostFunc), 0, (GInstanceInitFunc) kkc_unigram_to_unigram_path_cost_func_instance_init, NULL };
		GType kkc_unigram_to_unigram_path_cost_func_type_id;
		kkc_unigram_to_unigram_path_cost_func_type_id = g_type_register_static (KKC_TYPE_PATH_COST_FUNC, "KkcUnigramToUnigramPathCostFunc", &g_define_type_info, 0);
		g_once_init_leave (&kkc_unigram_to_unigram_path_cost_func_type_id__volatile, kkc_unigram_to_unigram_path_cost_func_type_id);
	}
	return kkc_unigram_to_unigram_path_cost_func_type_id__volatile;
}


static gdouble kkc_unigram_to_bigram_path_cost_func_real_path_cost (KkcPathCostFunc* base, KkcTrigramLanguageModel* model, KkcTrellisNode* pnode, KkcTrellisNode* node) {
	KkcUnigramToBigramPathCostFunc * self;
	gdouble result = 0.0;
	KkcTrellisNode* _tmp0_ = NULL;
	KkcTrellisNode* _tmp1_ = NULL;
	KkcUnigramTrellisNode* upnode = NULL;
	KkcTrellisNode* _tmp2_ = NULL;
	KkcUnigramTrellisNode* _tmp3_ = NULL;
	KkcBigramTrellisNode* bnode = NULL;
	KkcTrellisNode* _tmp4_ = NULL;
	KkcBigramTrellisNode* _tmp5_ = NULL;
	gdouble cost = 0.0;
	KkcUnigramTrellisNode* _tmp6_ = NULL;
	KkcLanguageModelEntry _tmp7_ = {0};
	KkcLanguageModelEntry _tmp8_ = {0};
	KkcTrigramLanguageModel* _tmp9_ = NULL;
	KkcLanguageModelEntry _tmp10_ = {0};
	KkcLanguageModelEntry _tmp11_ = {0};
	gdouble _tmp23_ = 0.0;
	KkcTrigramLanguageModel* _tmp24_ = NULL;
	KkcUnigramTrellisNode* _tmp25_ = NULL;
	KkcLanguageModelEntry _tmp26_ = {0};
	KkcLanguageModelEntry _tmp27_ = {0};
	KkcBigramTrellisNode* _tmp28_ = NULL;
	KkcUnigramTrellisNode* _tmp29_ = NULL;
	KkcUnigramTrellisNode* _tmp30_ = NULL;
	KkcLanguageModelEntry _tmp31_ = {0};
	KkcLanguageModelEntry _tmp32_ = {0};
	KkcBigramTrellisNode* _tmp33_ = NULL;
	KkcUnigramTrellisNode* _tmp34_ = NULL;
	KkcUnigramTrellisNode* _tmp35_ = NULL;
	KkcLanguageModelEntry _tmp36_ = {0};
	KkcLanguageModelEntry _tmp37_ = {0};
	gdouble _tmp38_ = 0.0;
	KkcUnigramTrellisNode* _tmp39_ = NULL;
	KkcTrellisNode* _tmp40_ = NULL;
	self = (KkcUnigramToBigramPathCostFunc*) base;
	g_return_val_if_fail (model != NULL, 0.0);
	g_return_val_if_fail (pnode != NULL, 0.0);
	g_return_val_if_fail (node != NULL, 0.0);
	_tmp0_ = pnode;
	_vala_assert (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, KKC_TYPE_UNIGRAM_TRELLIS_NODE), "pnode is UnigramTrellisNode");
	_tmp1_ = node;
	_vala_assert (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, KKC_TYPE_BIGRAM_TRELLIS_NODE), "node is BigramTrellisNode");
	_tmp2_ = pnode;
	_tmp3_ = _kkc_trellis_node_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, KKC_TYPE_UNIGRAM_TRELLIS_NODE, KkcUnigramTrellisNode));
	upnode = _tmp3_;
	_tmp4_ = node;
	_tmp5_ = _kkc_trellis_node_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, KKC_TYPE_BIGRAM_TRELLIS_NODE, KkcBigramTrellisNode));
	bnode = _tmp5_;
	cost = 0.0;
	_tmp6_ = upnode;
	kkc_unigram_trellis_node_get_entry (_tmp6_, &_tmp7_);
	_tmp8_ = _tmp7_;
	_tmp9_ = model;
	kkc_language_model_get_bos ((KkcLanguageModel*) _tmp9_, &_tmp10_);
	_tmp11_ = _tmp10_;
	if (_kkc_language_model_entry_equal (&_tmp8_, &_tmp11_) == TRUE) {
		gdouble _tmp12_ = 0.0;
		KkcTrigramLanguageModel* _tmp13_ = NULL;
		KkcUnigramTrellisNode* _tmp14_ = NULL;
		KkcLanguageModelEntry _tmp15_ = {0};
		KkcLanguageModelEntry _tmp16_ = {0};
		KkcBigramTrellisNode* _tmp17_ = NULL;
		KkcUnigramTrellisNode* _tmp18_ = NULL;
		KkcUnigramTrellisNode* _tmp19_ = NULL;
		KkcLanguageModelEntry _tmp20_ = {0};
		KkcLanguageModelEntry _tmp21_ = {0};
		gdouble _tmp22_ = 0.0;
		_tmp12_ = cost;
		_tmp13_ = model;
		_tmp14_ = upnode;
		kkc_unigram_trellis_node_get_entry (_tmp14_, &_tmp15_);
		_tmp16_ = _tmp15_;
		_tmp17_ = bnode;
		_tmp18_ = kkc_bigram_trellis_node_get_left_node (_tmp17_);
		_tmp19_ = _tmp18_;
		kkc_unigram_trellis_node_get_entry (_tmp19_, &_tmp20_);
		_tmp21_ = _tmp20_;
		_tmp22_ = kkc_bigram_language_model_bigram_backoff_cost ((KkcBigramLanguageModel*) _tmp13_, &_tmp16_, &_tmp21_);
		cost = _tmp12_ + _tmp22_;
	}
	_tmp23_ = cost;
	_tmp24_ = model;
	_tmp25_ = upnode;
	kkc_unigram_trellis_node_get_entry (_tmp25_, &_tmp26_);
	_tmp27_ = _tmp26_;
	_tmp28_ = bnode;
	_tmp29_ = kkc_bigram_trellis_node_get_left_node (_tmp28_);
	_tmp30_ = _tmp29_;
	kkc_unigram_trellis_node_get_entry (_tmp30_, &_tmp31_);
	_tmp32_ = _tmp31_;
	_tmp33_ = bnode;
	_tmp34_ = kkc_bigram_trellis_node_get_right_node (_tmp33_);
	_tmp35_ = _tmp34_;
	kkc_unigram_trellis_node_get_entry (_tmp35_, &_tmp36_);
	_tmp37_ = _tmp36_;
	_tmp38_ = kkc_trigram_language_model_trigram_backoff_cost (_tmp24_, &_tmp27_, &_tmp32_, &_tmp37_);
	cost = _tmp23_ + _tmp38_;
	_tmp39_ = upnode;
	_tmp40_ = ((KkcTrellisNode*) _tmp39_)->previous;
	if (_tmp40_ != NULL) {
		KkcUnigramTrellisNode* _tmp41_ = NULL;
		KkcTrellisNode* _tmp42_ = NULL;
		_tmp41_ = upnode;
		_tmp42_ = ((KkcTrellisNode*) _tmp41_)->previous;
		if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp42_, KKC_TYPE_UNIGRAM_TRELLIS_NODE)) {
			gdouble _tmp43_ = 0.0;
			KkcTrigramLanguageModel* _tmp44_ = NULL;
			KkcUnigramTrellisNode* _tmp45_ = NULL;
			KkcTrellisNode* _tmp46_ = NULL;
			KkcLanguageModelEntry _tmp47_ = {0};
			KkcLanguageModelEntry _tmp48_ = {0};
			KkcUnigramTrellisNode* _tmp49_ = NULL;
			KkcLanguageModelEntry _tmp50_ = {0};
			KkcLanguageModelEntry _tmp51_ = {0};
			KkcBigramTrellisNode* _tmp52_ = NULL;
			KkcUnigramTrellisNode* _tmp53_ = NULL;
			KkcUnigramTrellisNode* _tmp54_ = NULL;
			KkcLanguageModelEntry _tmp55_ = {0};
			KkcLanguageModelEntry _tmp56_ = {0};
			gdouble _tmp57_ = 0.0;
			_tmp43_ = cost;
			_tmp44_ = model;
			_tmp45_ = upnode;
			_tmp46_ = ((KkcTrellisNode*) _tmp45_)->previous;
			kkc_unigram_trellis_node_get_entry (G_TYPE_CHECK_INSTANCE_CAST (_tmp46_, KKC_TYPE_UNIGRAM_TRELLIS_NODE, KkcUnigramTrellisNode), &_tmp47_);
			_tmp48_ = _tmp47_;
			_tmp49_ = upnode;
			kkc_unigram_trellis_node_get_entry (_tmp49_, &_tmp50_);
			_tmp51_ = _tmp50_;
			_tmp52_ = bnode;
			_tmp53_ = kkc_bigram_trellis_node_get_left_node (_tmp52_);
			_tmp54_ = _tmp53_;
			kkc_unigram_trellis_node_get_entry (_tmp54_, &_tmp55_);
			_tmp56_ = _tmp55_;
			_tmp57_ = kkc_trigram_language_model_trigram_backoff_cost (_tmp44_, &_tmp48_, &_tmp51_, &_tmp56_);
			cost = _tmp43_ + _tmp57_;
		} else {
			gdouble _tmp58_ = 0.0;
			KkcTrigramLanguageModel* _tmp59_ = NULL;
			KkcUnigramTrellisNode* _tmp60_ = NULL;
			KkcTrellisNode* _tmp61_ = NULL;
			KkcUnigramTrellisNode* _tmp62_ = NULL;
			KkcUnigramTrellisNode* _tmp63_ = NULL;
			KkcLanguageModelEntry _tmp64_ = {0};
			KkcLanguageModelEntry _tmp65_ = {0};
			KkcUnigramTrellisNode* _tmp66_ = NULL;
			KkcLanguageModelEntry _tmp67_ = {0};
			KkcLanguageModelEntry _tmp68_ = {0};
			KkcBigramTrellisNode* _tmp69_ = NULL;
			KkcUnigramTrellisNode* _tmp70_ = NULL;
			KkcUnigramTrellisNode* _tmp71_ = NULL;
			KkcLanguageModelEntry _tmp72_ = {0};
			KkcLanguageModelEntry _tmp73_ = {0};
			gdouble _tmp74_ = 0.0;
			_tmp58_ = cost;
			_tmp59_ = model;
			_tmp60_ = upnode;
			_tmp61_ = ((KkcTrellisNode*) _tmp60_)->previous;
			_tmp62_ = kkc_bigram_trellis_node_get_right_node (G_TYPE_CHECK_INSTANCE_CAST (_tmp61_, KKC_TYPE_BIGRAM_TRELLIS_NODE, KkcBigramTrellisNode));
			_tmp63_ = _tmp62_;
			kkc_unigram_trellis_node_get_entry (_tmp63_, &_tmp64_);
			_tmp65_ = _tmp64_;
			_tmp66_ = upnode;
			kkc_unigram_trellis_node_get_entry (_tmp66_, &_tmp67_);
			_tmp68_ = _tmp67_;
			_tmp69_ = bnode;
			_tmp70_ = kkc_bigram_trellis_node_get_left_node (_tmp69_);
			_tmp71_ = _tmp70_;
			kkc_unigram_trellis_node_get_entry (_tmp71_, &_tmp72_);
			_tmp73_ = _tmp72_;
			_tmp74_ = kkc_trigram_language_model_trigram_backoff_cost (_tmp59_, &_tmp65_, &_tmp68_, &_tmp73_);
			cost = _tmp58_ + _tmp74_;
		}
	}
	result = cost;
	_kkc_trellis_node_unref0 (bnode);
	_kkc_trellis_node_unref0 (upnode);
	return result;
}


KkcUnigramToBigramPathCostFunc* kkc_unigram_to_bigram_path_cost_func_construct (GType object_type) {
	KkcUnigramToBigramPathCostFunc* self = NULL;
	self = (KkcUnigramToBigramPathCostFunc*) kkc_path_cost_func_construct (object_type);
	return self;
}


KkcUnigramToBigramPathCostFunc* kkc_unigram_to_bigram_path_cost_func_new (void) {
	return kkc_unigram_to_bigram_path_cost_func_construct (KKC_TYPE_UNIGRAM_TO_BIGRAM_PATH_COST_FUNC);
}


static void kkc_unigram_to_bigram_path_cost_func_class_init (KkcUnigramToBigramPathCostFuncClass * klass) {
	kkc_unigram_to_bigram_path_cost_func_parent_class = g_type_class_peek_parent (klass);
	((KkcPathCostFuncClass *) klass)->path_cost = kkc_unigram_to_bigram_path_cost_func_real_path_cost;
}


static void kkc_unigram_to_bigram_path_cost_func_instance_init (KkcUnigramToBigramPathCostFunc * self) {
}


GType kkc_unigram_to_bigram_path_cost_func_get_type (void) {
	static volatile gsize kkc_unigram_to_bigram_path_cost_func_type_id__volatile = 0;
	if (g_once_init_enter (&kkc_unigram_to_bigram_path_cost_func_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (KkcUnigramToBigramPathCostFuncClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_unigram_to_bigram_path_cost_func_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcUnigramToBigramPathCostFunc), 0, (GInstanceInitFunc) kkc_unigram_to_bigram_path_cost_func_instance_init, NULL };
		GType kkc_unigram_to_bigram_path_cost_func_type_id;
		kkc_unigram_to_bigram_path_cost_func_type_id = g_type_register_static (KKC_TYPE_PATH_COST_FUNC, "KkcUnigramToBigramPathCostFunc", &g_define_type_info, 0);
		g_once_init_leave (&kkc_unigram_to_bigram_path_cost_func_type_id__volatile, kkc_unigram_to_bigram_path_cost_func_type_id);
	}
	return kkc_unigram_to_bigram_path_cost_func_type_id__volatile;
}


static gdouble kkc_bigram_to_unigram_path_cost_func_real_path_cost (KkcPathCostFunc* base, KkcTrigramLanguageModel* model, KkcTrellisNode* pnode, KkcTrellisNode* node) {
	KkcBigramToUnigramPathCostFunc * self;
	gdouble result = 0.0;
	KkcTrellisNode* _tmp0_ = NULL;
	KkcTrellisNode* _tmp1_ = NULL;
	KkcBigramTrellisNode* bpnode = NULL;
	KkcTrellisNode* _tmp2_ = NULL;
	KkcBigramTrellisNode* _tmp3_ = NULL;
	KkcUnigramTrellisNode* unode = NULL;
	KkcTrellisNode* _tmp4_ = NULL;
	KkcUnigramTrellisNode* _tmp5_ = NULL;
	gdouble cost = 0.0;
	KkcBigramTrellisNode* _tmp6_ = NULL;
	KkcUnigramTrellisNode* _tmp7_ = NULL;
	KkcUnigramTrellisNode* _tmp8_ = NULL;
	KkcLanguageModelEntry _tmp9_ = {0};
	KkcLanguageModelEntry _tmp10_ = {0};
	KkcTrigramLanguageModel* _tmp11_ = NULL;
	KkcLanguageModelEntry _tmp12_ = {0};
	KkcLanguageModelEntry _tmp13_ = {0};
	gdouble _tmp27_ = 0.0;
	KkcTrigramLanguageModel* _tmp28_ = NULL;
	KkcBigramTrellisNode* _tmp29_ = NULL;
	KkcUnigramTrellisNode* _tmp30_ = NULL;
	KkcUnigramTrellisNode* _tmp31_ = NULL;
	KkcLanguageModelEntry _tmp32_ = {0};
	KkcLanguageModelEntry _tmp33_ = {0};
	KkcBigramTrellisNode* _tmp34_ = NULL;
	KkcUnigramTrellisNode* _tmp35_ = NULL;
	KkcUnigramTrellisNode* _tmp36_ = NULL;
	KkcLanguageModelEntry _tmp37_ = {0};
	KkcLanguageModelEntry _tmp38_ = {0};
	KkcUnigramTrellisNode* _tmp39_ = NULL;
	KkcLanguageModelEntry _tmp40_ = {0};
	KkcLanguageModelEntry _tmp41_ = {0};
	gdouble _tmp42_ = 0.0;
	self = (KkcBigramToUnigramPathCostFunc*) base;
	g_return_val_if_fail (model != NULL, 0.0);
	g_return_val_if_fail (pnode != NULL, 0.0);
	g_return_val_if_fail (node != NULL, 0.0);
	_tmp0_ = pnode;
	_vala_assert (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, KKC_TYPE_BIGRAM_TRELLIS_NODE), "pnode is BigramTrellisNode");
	_tmp1_ = node;
	_vala_assert (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, KKC_TYPE_UNIGRAM_TRELLIS_NODE), "node is UnigramTrellisNode");
	_tmp2_ = pnode;
	_tmp3_ = _kkc_trellis_node_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, KKC_TYPE_BIGRAM_TRELLIS_NODE, KkcBigramTrellisNode));
	bpnode = _tmp3_;
	_tmp4_ = node;
	_tmp5_ = _kkc_trellis_node_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, KKC_TYPE_UNIGRAM_TRELLIS_NODE, KkcUnigramTrellisNode));
	unode = _tmp5_;
	cost = 0.0;
	_tmp6_ = bpnode;
	_tmp7_ = kkc_bigram_trellis_node_get_left_node (_tmp6_);
	_tmp8_ = _tmp7_;
	kkc_unigram_trellis_node_get_entry (_tmp8_, &_tmp9_);
	_tmp10_ = _tmp9_;
	_tmp11_ = model;
	kkc_language_model_get_bos ((KkcLanguageModel*) _tmp11_, &_tmp12_);
	_tmp13_ = _tmp12_;
	if (_kkc_language_model_entry_equal (&_tmp10_, &_tmp13_) == TRUE) {
		gdouble _tmp14_ = 0.0;
		KkcTrigramLanguageModel* _tmp15_ = NULL;
		KkcBigramTrellisNode* _tmp16_ = NULL;
		KkcUnigramTrellisNode* _tmp17_ = NULL;
		KkcUnigramTrellisNode* _tmp18_ = NULL;
		KkcLanguageModelEntry _tmp19_ = {0};
		KkcLanguageModelEntry _tmp20_ = {0};
		KkcBigramTrellisNode* _tmp21_ = NULL;
		KkcUnigramTrellisNode* _tmp22_ = NULL;
		KkcUnigramTrellisNode* _tmp23_ = NULL;
		KkcLanguageModelEntry _tmp24_ = {0};
		KkcLanguageModelEntry _tmp25_ = {0};
		gdouble _tmp26_ = 0.0;
		_tmp14_ = cost;
		_tmp15_ = model;
		_tmp16_ = bpnode;
		_tmp17_ = kkc_bigram_trellis_node_get_left_node (_tmp16_);
		_tmp18_ = _tmp17_;
		kkc_unigram_trellis_node_get_entry (_tmp18_, &_tmp19_);
		_tmp20_ = _tmp19_;
		_tmp21_ = bpnode;
		_tmp22_ = kkc_bigram_trellis_node_get_right_node (_tmp21_);
		_tmp23_ = _tmp22_;
		kkc_unigram_trellis_node_get_entry (_tmp23_, &_tmp24_);
		_tmp25_ = _tmp24_;
		_tmp26_ = kkc_bigram_language_model_bigram_backoff_cost ((KkcBigramLanguageModel*) _tmp15_, &_tmp20_, &_tmp25_);
		cost = _tmp14_ + _tmp26_;
	}
	_tmp27_ = cost;
	_tmp28_ = model;
	_tmp29_ = bpnode;
	_tmp30_ = kkc_bigram_trellis_node_get_left_node (_tmp29_);
	_tmp31_ = _tmp30_;
	kkc_unigram_trellis_node_get_entry (_tmp31_, &_tmp32_);
	_tmp33_ = _tmp32_;
	_tmp34_ = bpnode;
	_tmp35_ = kkc_bigram_trellis_node_get_right_node (_tmp34_);
	_tmp36_ = _tmp35_;
	kkc_unigram_trellis_node_get_entry (_tmp36_, &_tmp37_);
	_tmp38_ = _tmp37_;
	_tmp39_ = unode;
	kkc_unigram_trellis_node_get_entry (_tmp39_, &_tmp40_);
	_tmp41_ = _tmp40_;
	_tmp42_ = kkc_trigram_language_model_trigram_backoff_cost (_tmp28_, &_tmp33_, &_tmp38_, &_tmp41_);
	cost = _tmp27_ + _tmp42_;
	result = cost;
	_kkc_trellis_node_unref0 (unode);
	_kkc_trellis_node_unref0 (bpnode);
	return result;
}


KkcBigramToUnigramPathCostFunc* kkc_bigram_to_unigram_path_cost_func_construct (GType object_type) {
	KkcBigramToUnigramPathCostFunc* self = NULL;
	self = (KkcBigramToUnigramPathCostFunc*) kkc_path_cost_func_construct (object_type);
	return self;
}


KkcBigramToUnigramPathCostFunc* kkc_bigram_to_unigram_path_cost_func_new (void) {
	return kkc_bigram_to_unigram_path_cost_func_construct (KKC_TYPE_BIGRAM_TO_UNIGRAM_PATH_COST_FUNC);
}


static void kkc_bigram_to_unigram_path_cost_func_class_init (KkcBigramToUnigramPathCostFuncClass * klass) {
	kkc_bigram_to_unigram_path_cost_func_parent_class = g_type_class_peek_parent (klass);
	((KkcPathCostFuncClass *) klass)->path_cost = kkc_bigram_to_unigram_path_cost_func_real_path_cost;
}


static void kkc_bigram_to_unigram_path_cost_func_instance_init (KkcBigramToUnigramPathCostFunc * self) {
}


GType kkc_bigram_to_unigram_path_cost_func_get_type (void) {
	static volatile gsize kkc_bigram_to_unigram_path_cost_func_type_id__volatile = 0;
	if (g_once_init_enter (&kkc_bigram_to_unigram_path_cost_func_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (KkcBigramToUnigramPathCostFuncClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_bigram_to_unigram_path_cost_func_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcBigramToUnigramPathCostFunc), 0, (GInstanceInitFunc) kkc_bigram_to_unigram_path_cost_func_instance_init, NULL };
		GType kkc_bigram_to_unigram_path_cost_func_type_id;
		kkc_bigram_to_unigram_path_cost_func_type_id = g_type_register_static (KKC_TYPE_PATH_COST_FUNC, "KkcBigramToUnigramPathCostFunc", &g_define_type_info, 0);
		g_once_init_leave (&kkc_bigram_to_unigram_path_cost_func_type_id__volatile, kkc_bigram_to_unigram_path_cost_func_type_id);
	}
	return kkc_bigram_to_unigram_path_cost_func_type_id__volatile;
}


static gdouble kkc_bigram_to_bigram_path_cost_func_real_path_cost (KkcPathCostFunc* base, KkcTrigramLanguageModel* model, KkcTrellisNode* pnode, KkcTrellisNode* node) {
	KkcBigramToBigramPathCostFunc * self;
	gdouble result = 0.0;
	KkcTrellisNode* _tmp0_ = NULL;
	KkcTrellisNode* _tmp1_ = NULL;
	KkcBigramTrellisNode* bpnode = NULL;
	KkcTrellisNode* _tmp2_ = NULL;
	KkcBigramTrellisNode* _tmp3_ = NULL;
	KkcBigramTrellisNode* bnode = NULL;
	KkcTrellisNode* _tmp4_ = NULL;
	KkcBigramTrellisNode* _tmp5_ = NULL;
	gdouble cost = 0.0;
	KkcBigramTrellisNode* _tmp6_ = NULL;
	KkcUnigramTrellisNode* _tmp7_ = NULL;
	KkcUnigramTrellisNode* _tmp8_ = NULL;
	KkcLanguageModelEntry _tmp9_ = {0};
	KkcLanguageModelEntry _tmp10_ = {0};
	KkcTrigramLanguageModel* _tmp11_ = NULL;
	KkcLanguageModelEntry _tmp12_ = {0};
	KkcLanguageModelEntry _tmp13_ = {0};
	gdouble _tmp27_ = 0.0;
	KkcTrigramLanguageModel* _tmp28_ = NULL;
	KkcBigramTrellisNode* _tmp29_ = NULL;
	KkcUnigramTrellisNode* _tmp30_ = NULL;
	KkcUnigramTrellisNode* _tmp31_ = NULL;
	KkcLanguageModelEntry _tmp32_ = {0};
	KkcLanguageModelEntry _tmp33_ = {0};
	KkcBigramTrellisNode* _tmp34_ = NULL;
	KkcUnigramTrellisNode* _tmp35_ = NULL;
	KkcUnigramTrellisNode* _tmp36_ = NULL;
	KkcLanguageModelEntry _tmp37_ = {0};
	KkcLanguageModelEntry _tmp38_ = {0};
	KkcBigramTrellisNode* _tmp39_ = NULL;
	KkcUnigramTrellisNode* _tmp40_ = NULL;
	KkcUnigramTrellisNode* _tmp41_ = NULL;
	KkcLanguageModelEntry _tmp42_ = {0};
	KkcLanguageModelEntry _tmp43_ = {0};
	gdouble _tmp44_ = 0.0;
	gdouble _tmp45_ = 0.0;
	KkcTrigramLanguageModel* _tmp46_ = NULL;
	KkcBigramTrellisNode* _tmp47_ = NULL;
	KkcUnigramTrellisNode* _tmp48_ = NULL;
	KkcUnigramTrellisNode* _tmp49_ = NULL;
	KkcLanguageModelEntry _tmp50_ = {0};
	KkcLanguageModelEntry _tmp51_ = {0};
	KkcBigramTrellisNode* _tmp52_ = NULL;
	KkcUnigramTrellisNode* _tmp53_ = NULL;
	KkcUnigramTrellisNode* _tmp54_ = NULL;
	KkcLanguageModelEntry _tmp55_ = {0};
	KkcLanguageModelEntry _tmp56_ = {0};
	KkcBigramTrellisNode* _tmp57_ = NULL;
	KkcUnigramTrellisNode* _tmp58_ = NULL;
	KkcUnigramTrellisNode* _tmp59_ = NULL;
	KkcLanguageModelEntry _tmp60_ = {0};
	KkcLanguageModelEntry _tmp61_ = {0};
	gdouble _tmp62_ = 0.0;
	self = (KkcBigramToBigramPathCostFunc*) base;
	g_return_val_if_fail (model != NULL, 0.0);
	g_return_val_if_fail (pnode != NULL, 0.0);
	g_return_val_if_fail (node != NULL, 0.0);
	_tmp0_ = pnode;
	_vala_assert (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, KKC_TYPE_BIGRAM_TRELLIS_NODE), "pnode is BigramTrellisNode");
	_tmp1_ = node;
	_vala_assert (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, KKC_TYPE_BIGRAM_TRELLIS_NODE), "node is BigramTrellisNode");
	_tmp2_ = pnode;
	_tmp3_ = _kkc_trellis_node_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, KKC_TYPE_BIGRAM_TRELLIS_NODE, KkcBigramTrellisNode));
	bpnode = _tmp3_;
	_tmp4_ = node;
	_tmp5_ = _kkc_trellis_node_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, KKC_TYPE_BIGRAM_TRELLIS_NODE, KkcBigramTrellisNode));
	bnode = _tmp5_;
	cost = 0.0;
	_tmp6_ = bpnode;
	_tmp7_ = kkc_bigram_trellis_node_get_left_node (_tmp6_);
	_tmp8_ = _tmp7_;
	kkc_unigram_trellis_node_get_entry (_tmp8_, &_tmp9_);
	_tmp10_ = _tmp9_;
	_tmp11_ = model;
	kkc_language_model_get_bos ((KkcLanguageModel*) _tmp11_, &_tmp12_);
	_tmp13_ = _tmp12_;
	if (_kkc_language_model_entry_equal (&_tmp10_, &_tmp13_) == TRUE) {
		gdouble _tmp14_ = 0.0;
		KkcTrigramLanguageModel* _tmp15_ = NULL;
		KkcBigramTrellisNode* _tmp16_ = NULL;
		KkcUnigramTrellisNode* _tmp17_ = NULL;
		KkcUnigramTrellisNode* _tmp18_ = NULL;
		KkcLanguageModelEntry _tmp19_ = {0};
		KkcLanguageModelEntry _tmp20_ = {0};
		KkcBigramTrellisNode* _tmp21_ = NULL;
		KkcUnigramTrellisNode* _tmp22_ = NULL;
		KkcUnigramTrellisNode* _tmp23_ = NULL;
		KkcLanguageModelEntry _tmp24_ = {0};
		KkcLanguageModelEntry _tmp25_ = {0};
		gdouble _tmp26_ = 0.0;
		_tmp14_ = cost;
		_tmp15_ = model;
		_tmp16_ = bpnode;
		_tmp17_ = kkc_bigram_trellis_node_get_left_node (_tmp16_);
		_tmp18_ = _tmp17_;
		kkc_unigram_trellis_node_get_entry (_tmp18_, &_tmp19_);
		_tmp20_ = _tmp19_;
		_tmp21_ = bpnode;
		_tmp22_ = kkc_bigram_trellis_node_get_right_node (_tmp21_);
		_tmp23_ = _tmp22_;
		kkc_unigram_trellis_node_get_entry (_tmp23_, &_tmp24_);
		_tmp25_ = _tmp24_;
		_tmp26_ = kkc_bigram_language_model_bigram_backoff_cost ((KkcBigramLanguageModel*) _tmp15_, &_tmp20_, &_tmp25_);
		cost = _tmp14_ + _tmp26_;
	}
	_tmp27_ = cost;
	_tmp28_ = model;
	_tmp29_ = bpnode;
	_tmp30_ = kkc_bigram_trellis_node_get_left_node (_tmp29_);
	_tmp31_ = _tmp30_;
	kkc_unigram_trellis_node_get_entry (_tmp31_, &_tmp32_);
	_tmp33_ = _tmp32_;
	_tmp34_ = bpnode;
	_tmp35_ = kkc_bigram_trellis_node_get_right_node (_tmp34_);
	_tmp36_ = _tmp35_;
	kkc_unigram_trellis_node_get_entry (_tmp36_, &_tmp37_);
	_tmp38_ = _tmp37_;
	_tmp39_ = bnode;
	_tmp40_ = kkc_bigram_trellis_node_get_left_node (_tmp39_);
	_tmp41_ = _tmp40_;
	kkc_unigram_trellis_node_get_entry (_tmp41_, &_tmp42_);
	_tmp43_ = _tmp42_;
	_tmp44_ = kkc_trigram_language_model_trigram_backoff_cost (_tmp28_, &_tmp33_, &_tmp38_, &_tmp43_);
	cost = _tmp27_ + _tmp44_;
	_tmp45_ = cost;
	_tmp46_ = model;
	_tmp47_ = bpnode;
	_tmp48_ = kkc_bigram_trellis_node_get_right_node (_tmp47_);
	_tmp49_ = _tmp48_;
	kkc_unigram_trellis_node_get_entry (_tmp49_, &_tmp50_);
	_tmp51_ = _tmp50_;
	_tmp52_ = bnode;
	_tmp53_ = kkc_bigram_trellis_node_get_left_node (_tmp52_);
	_tmp54_ = _tmp53_;
	kkc_unigram_trellis_node_get_entry (_tmp54_, &_tmp55_);
	_tmp56_ = _tmp55_;
	_tmp57_ = bnode;
	_tmp58_ = kkc_bigram_trellis_node_get_right_node (_tmp57_);
	_tmp59_ = _tmp58_;
	kkc_unigram_trellis_node_get_entry (_tmp59_, &_tmp60_);
	_tmp61_ = _tmp60_;
	_tmp62_ = kkc_trigram_language_model_trigram_backoff_cost (_tmp46_, &_tmp51_, &_tmp56_, &_tmp61_);
	cost = _tmp45_ + _tmp62_;
	result = cost;
	_kkc_trellis_node_unref0 (bnode);
	_kkc_trellis_node_unref0 (bpnode);
	return result;
}


KkcBigramToBigramPathCostFunc* kkc_bigram_to_bigram_path_cost_func_construct (GType object_type) {
	KkcBigramToBigramPathCostFunc* self = NULL;
	self = (KkcBigramToBigramPathCostFunc*) kkc_path_cost_func_construct (object_type);
	return self;
}


KkcBigramToBigramPathCostFunc* kkc_bigram_to_bigram_path_cost_func_new (void) {
	return kkc_bigram_to_bigram_path_cost_func_construct (KKC_TYPE_BIGRAM_TO_BIGRAM_PATH_COST_FUNC);
}


static void kkc_bigram_to_bigram_path_cost_func_class_init (KkcBigramToBigramPathCostFuncClass * klass) {
	kkc_bigram_to_bigram_path_cost_func_parent_class = g_type_class_peek_parent (klass);
	((KkcPathCostFuncClass *) klass)->path_cost = kkc_bigram_to_bigram_path_cost_func_real_path_cost;
}


static void kkc_bigram_to_bigram_path_cost_func_instance_init (KkcBigramToBigramPathCostFunc * self) {
}


GType kkc_bigram_to_bigram_path_cost_func_get_type (void) {
	static volatile gsize kkc_bigram_to_bigram_path_cost_func_type_id__volatile = 0;
	if (g_once_init_enter (&kkc_bigram_to_bigram_path_cost_func_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (KkcBigramToBigramPathCostFuncClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_bigram_to_bigram_path_cost_func_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcBigramToBigramPathCostFunc), 0, (GInstanceInitFunc) kkc_bigram_to_bigram_path_cost_func_instance_init, NULL };
		GType kkc_bigram_to_bigram_path_cost_func_type_id;
		kkc_bigram_to_bigram_path_cost_func_type_id = g_type_register_static (KKC_TYPE_PATH_COST_FUNC, "KkcBigramToBigramPathCostFunc", &g_define_type_info, 0);
		g_once_init_leave (&kkc_bigram_to_bigram_path_cost_func_type_id__volatile, kkc_bigram_to_bigram_path_cost_func_type_id);
	}
	return kkc_bigram_to_bigram_path_cost_func_type_id__volatile;
}


static KkcSegment** kkc_trigram_decoder_real_decode (KkcDecoder* base, const gchar* input, gint nbest, gint* constraint, int constraint_length1, int* result_length1) {
	KkcTrigramDecoder * self;
	KkcSegment** result = NULL;
	const gchar* _tmp0_ = NULL;
	gint _tmp1_ = 0;
	gint* _tmp2_ = NULL;
	gint _tmp2__length1 = 0;
	gint _tmp3_ = 0;
	KkcSegment** _tmp4_ = NULL;
	KkcSegment** _tmp5_ = NULL;
	gint _tmp5__length1 = 0;
	self = (KkcTrigramDecoder*) base;
	g_return_val_if_fail (input != NULL, NULL);
	_tmp0_ = input;
	_tmp1_ = nbest;
	_tmp2_ = constraint;
	_tmp2__length1 = constraint_length1;
	_tmp4_ = kkc_decoder_decode_with_costs ((KkcDecoder*) self, _tmp0_, _tmp1_, _tmp2_, _tmp2__length1, DBL_MAX, -DBL_MAX, &_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp5__length1 = _tmp3_;
	if (result_length1) {
		*result_length1 = _tmp5__length1;
	}
	result = _tmp5_;
	return result;
}


static KkcSegment** kkc_trigram_decoder_real_decode_with_costs (KkcDecoder* base, const gchar* input, gint nbest, gint* constraint, int constraint_length1, gdouble max_distance, gdouble min_path_cost, int* result_length1) {
	KkcTrigramDecoder * self;
	KkcSegment** result = NULL;
	GeeArrayList** trellis = NULL;
	const gchar* _tmp0_ = NULL;
	gint* _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	gint _tmp2_ = 0;
	GeeArrayList** _tmp3_ = NULL;
	gint trellis_length1 = 0;
	gint _trellis_size_ = 0;
	const gchar* _tmp4_ = NULL;
	gint* _tmp5_ = NULL;
	gint _tmp5__length1 = 0;
	const gchar* _tmp6_ = NULL;
	gint _tmp7_ = 0;
	gdouble _tmp8_ = 0.0;
	gdouble _tmp9_ = 0.0;
	gint _tmp10_ = 0;
	KkcSegment** _tmp11_ = NULL;
	KkcSegment** _tmp12_ = NULL;
	gint _tmp12__length1 = 0;
	self = (KkcTrigramDecoder*) base;
	g_return_val_if_fail (input != NULL, NULL);
	_tmp0_ = input;
	_tmp1_ = constraint;
	_tmp1__length1 = constraint_length1;
	_tmp3_ = kkc_bigram_decoder_build_trellis ((KkcBigramDecoder*) self, _tmp0_, _tmp1_, _tmp1__length1, &_tmp2_);
	trellis = _tmp3_;
	trellis_length1 = _tmp2_;
	_trellis_size_ = trellis_length1;
	kkc_trigram_decoder_add_trigram_nodes (self, trellis, trellis_length1);
	_tmp4_ = input;
	_tmp5_ = constraint;
	_tmp5__length1 = constraint_length1;
	kkc_bigram_decoder_add_unknown_nodes ((KkcBigramDecoder*) self, trellis, trellis_length1, _tmp4_, _tmp5_, _tmp5__length1);
	_tmp6_ = input;
	kkc_bigram_decoder_forward_search ((KkcBigramDecoder*) self, trellis, trellis_length1, _tmp6_);
	_tmp7_ = nbest;
	_tmp8_ = max_distance;
	_tmp9_ = min_path_cost;
	_tmp11_ = kkc_bigram_decoder_backward_search ((KkcBigramDecoder*) self, trellis, trellis_length1, _tmp7_, _tmp8_, _tmp9_, &_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp12__length1 = _tmp10_;
	if (result_length1) {
		*result_length1 = _tmp12__length1;
	}
	result = _tmp12_;
	trellis = (_vala_array_free (trellis, trellis_length1, (GDestroyNotify) g_object_unref), NULL);
	return result;
}


static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


static void kkc_trigram_decoder_add_trigram_nodes (KkcTrigramDecoder* self, GeeArrayList** trellis, int trellis_length1) {
	GeeArrayList** trigram_trellis = NULL;
	GeeArrayList** _tmp0_ = NULL;
	gint _tmp0__length1 = 0;
	GeeArrayList** _tmp1_ = NULL;
	gint trigram_trellis_length1 = 0;
	gint _trigram_trellis_size_ = 0;
	GeeHashSet** overlapped_nodes = NULL;
	GeeArrayList** _tmp10_ = NULL;
	gint _tmp10__length1 = 0;
	GeeHashSet** _tmp11_ = NULL;
	gint overlapped_nodes_length1 = 0;
	gint _overlapped_nodes_size_ = 0;
	g_return_if_fail (self != NULL);
	_tmp0_ = trellis;
	_tmp0__length1 = trellis_length1;
	_tmp1_ = g_new0 (GeeArrayList*, _tmp0__length1 + 1);
	trigram_trellis = _tmp1_;
	trigram_trellis_length1 = _tmp0__length1;
	_trigram_trellis_size_ = trigram_trellis_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				gint _tmp4_ = 0;
				GeeArrayList** _tmp5_ = NULL;
				gint _tmp5__length1 = 0;
				GeeArrayList** _tmp6_ = NULL;
				gint _tmp6__length1 = 0;
				gint _tmp7_ = 0;
				GeeArrayList* _tmp8_ = NULL;
				GeeArrayList* _tmp9_ = NULL;
				if (!_tmp2_) {
					gint _tmp3_ = 0;
					_tmp3_ = i;
					i = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = i;
				_tmp5_ = trigram_trellis;
				_tmp5__length1 = trigram_trellis_length1;
				if (!(_tmp4_ < _tmp5__length1)) {
					break;
				}
				_tmp6_ = trigram_trellis;
				_tmp6__length1 = trigram_trellis_length1;
				_tmp7_ = i;
				_tmp8_ = gee_array_list_new (KKC_TYPE_TRELLIS_NODE, (GBoxedCopyFunc) kkc_trellis_node_ref, kkc_trellis_node_unref, NULL, NULL, NULL);
				_g_object_unref0 (_tmp6_[_tmp7_]);
				_tmp6_[_tmp7_] = _tmp8_;
				_tmp9_ = _tmp6_[_tmp7_];
			}
		}
	}
	_tmp10_ = trellis;
	_tmp10__length1 = trellis_length1;
	_tmp11_ = g_new0 (GeeHashSet*, _tmp10__length1 + 1);
	overlapped_nodes = _tmp11_;
	overlapped_nodes_length1 = _tmp10__length1;
	_overlapped_nodes_size_ = overlapped_nodes_length1;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp12_ = FALSE;
			_tmp12_ = TRUE;
			while (TRUE) {
				gint _tmp14_ = 0;
				GeeHashSet** _tmp15_ = NULL;
				gint _tmp15__length1 = 0;
				GeeHashSet** _tmp16_ = NULL;
				gint _tmp16__length1 = 0;
				gint _tmp17_ = 0;
				GeeHashSet* _tmp18_ = NULL;
				GeeHashSet* _tmp19_ = NULL;
				if (!_tmp12_) {
					gint _tmp13_ = 0;
					_tmp13_ = i;
					i = _tmp13_ + 1;
				}
				_tmp12_ = FALSE;
				_tmp14_ = i;
				_tmp15_ = overlapped_nodes;
				_tmp15__length1 = overlapped_nodes_length1;
				if (!(_tmp14_ < _tmp15__length1)) {
					break;
				}
				_tmp16_ = overlapped_nodes;
				_tmp16__length1 = overlapped_nodes_length1;
				_tmp17_ = i;
				_tmp18_ = gee_hash_set_new (KKC_TYPE_TRELLIS_NODE, (GBoxedCopyFunc) kkc_trellis_node_ref, kkc_trellis_node_unref, NULL, NULL, NULL, NULL, NULL, NULL);
				_g_object_unref0 (_tmp16_[_tmp17_]);
				_tmp16_[_tmp17_] = _tmp18_;
				_tmp19_ = _tmp16_[_tmp17_];
			}
		}
	}
	{
		gint i = 0;
		i = 1;
		{
			gboolean _tmp20_ = FALSE;
			_tmp20_ = TRUE;
			while (TRUE) {
				gint _tmp22_ = 0;
				GeeArrayList** _tmp23_ = NULL;
				gint _tmp23__length1 = 0;
				if (!_tmp20_) {
					gint _tmp21_ = 0;
					_tmp21_ = i;
					i = _tmp21_ + 1;
				}
				_tmp20_ = FALSE;
				_tmp22_ = i;
				_tmp23_ = trellis;
				_tmp23__length1 = trellis_length1;
				if (!(_tmp22_ < _tmp23__length1)) {
					break;
				}
				{
					GeeArrayList* _node_list = NULL;
					GeeArrayList** _tmp24_ = NULL;
					gint _tmp24__length1 = 0;
					gint _tmp25_ = 0;
					GeeArrayList* _tmp26_ = NULL;
					GeeArrayList* _tmp27_ = NULL;
					gint _node_size = 0;
					GeeArrayList* _tmp28_ = NULL;
					gint _tmp29_ = 0;
					gint _tmp30_ = 0;
					gint _node_index = 0;
					_tmp24_ = trellis;
					_tmp24__length1 = trellis_length1;
					_tmp25_ = i;
					_tmp26_ = _tmp24_[_tmp25_];
					_tmp27_ = _g_object_ref0 (_tmp26_);
					_node_list = _tmp27_;
					_tmp28_ = _node_list;
					_tmp29_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp28_);
					_tmp30_ = _tmp29_;
					_node_size = _tmp30_;
					_node_index = -1;
					while (TRUE) {
						gint _tmp31_ = 0;
						gint _tmp32_ = 0;
						gint _tmp33_ = 0;
						KkcTrellisNode* node = NULL;
						GeeArrayList* _tmp34_ = NULL;
						gint _tmp35_ = 0;
						gpointer _tmp36_ = NULL;
						KkcUnigramTrellisNode* unode = NULL;
						KkcTrellisNode* _tmp37_ = NULL;
						KkcUnigramTrellisNode* _tmp38_ = NULL;
						gint j = 0;
						gint _tmp39_ = 0;
						KkcTrellisNode* _tmp40_ = NULL;
						guint _tmp41_ = 0U;
						guint _tmp42_ = 0U;
						_tmp31_ = _node_index;
						_node_index = _tmp31_ + 1;
						_tmp32_ = _node_index;
						_tmp33_ = _node_size;
						if (!(_tmp32_ < _tmp33_)) {
							break;
						}
						_tmp34_ = _node_list;
						_tmp35_ = _node_index;
						_tmp36_ = gee_abstract_list_get ((GeeAbstractList*) _tmp34_, _tmp35_);
						node = (KkcTrellisNode*) _tmp36_;
						_tmp37_ = node;
						_tmp38_ = _kkc_trellis_node_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp37_, KKC_TYPE_UNIGRAM_TRELLIS_NODE) ? ((KkcUnigramTrellisNode*) _tmp37_) : NULL);
						unode = _tmp38_;
						_tmp39_ = i;
						_tmp40_ = node;
						_tmp41_ = kkc_trellis_node_get_length (_tmp40_);
						_tmp42_ = _tmp41_;
						j = _tmp39_ - ((gint) _tmp42_);
						{
							GeeArrayList* _pnode_list = NULL;
							GeeArrayList** _tmp43_ = NULL;
							gint _tmp43__length1 = 0;
							gint _tmp44_ = 0;
							GeeArrayList* _tmp45_ = NULL;
							GeeArrayList* _tmp46_ = NULL;
							gint _pnode_size = 0;
							GeeArrayList* _tmp47_ = NULL;
							gint _tmp48_ = 0;
							gint _tmp49_ = 0;
							gint _pnode_index = 0;
							_tmp43_ = trellis;
							_tmp43__length1 = trellis_length1;
							_tmp44_ = j;
							_tmp45_ = _tmp43_[_tmp44_];
							_tmp46_ = _g_object_ref0 (_tmp45_);
							_pnode_list = _tmp46_;
							_tmp47_ = _pnode_list;
							_tmp48_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp47_);
							_tmp49_ = _tmp48_;
							_pnode_size = _tmp49_;
							_pnode_index = -1;
							while (TRUE) {
								gint _tmp50_ = 0;
								gint _tmp51_ = 0;
								gint _tmp52_ = 0;
								KkcTrellisNode* pnode = NULL;
								GeeArrayList* _tmp53_ = NULL;
								gint _tmp54_ = 0;
								gpointer _tmp55_ = NULL;
								KkcUnigramTrellisNode* upnode = NULL;
								KkcTrellisNode* _tmp56_ = NULL;
								KkcUnigramTrellisNode* _tmp57_ = NULL;
								KkcBigramLanguageModel* _tmp58_ = NULL;
								KkcBigramLanguageModel* _tmp59_ = NULL;
								KkcUnigramTrellisNode* _tmp60_ = NULL;
								KkcLanguageModelEntry _tmp61_ = {0};
								KkcLanguageModelEntry _tmp62_ = {0};
								KkcUnigramTrellisNode* _tmp63_ = NULL;
								KkcLanguageModelEntry _tmp64_ = {0};
								KkcLanguageModelEntry _tmp65_ = {0};
								gboolean _tmp66_ = FALSE;
								gint k = 0;
								gint _tmp67_ = 0;
								KkcTrellisNode* _tmp68_ = NULL;
								guint _tmp69_ = 0U;
								guint _tmp70_ = 0U;
								gint _tmp71_ = 0;
								_tmp50_ = _pnode_index;
								_pnode_index = _tmp50_ + 1;
								_tmp51_ = _pnode_index;
								_tmp52_ = _pnode_size;
								if (!(_tmp51_ < _tmp52_)) {
									break;
								}
								_tmp53_ = _pnode_list;
								_tmp54_ = _pnode_index;
								_tmp55_ = gee_abstract_list_get ((GeeAbstractList*) _tmp53_, _tmp54_);
								pnode = (KkcTrellisNode*) _tmp55_;
								_tmp56_ = pnode;
								_tmp57_ = _kkc_trellis_node_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp56_, KKC_TYPE_UNIGRAM_TRELLIS_NODE) ? ((KkcUnigramTrellisNode*) _tmp56_) : NULL);
								upnode = _tmp57_;
								_tmp58_ = kkc_bigram_decoder_get_model ((KkcBigramDecoder*) self);
								_tmp59_ = _tmp58_;
								_tmp60_ = upnode;
								kkc_unigram_trellis_node_get_entry (_tmp60_, &_tmp61_);
								_tmp62_ = _tmp61_;
								_tmp63_ = unode;
								kkc_unigram_trellis_node_get_entry (_tmp63_, &_tmp64_);
								_tmp65_ = _tmp64_;
								_tmp66_ = kkc_bigram_language_model_has_bigram (_tmp59_, &_tmp62_, &_tmp65_);
								if (!_tmp66_) {
									_kkc_trellis_node_unref0 (upnode);
									_kkc_trellis_node_unref0 (pnode);
									continue;
								}
								_tmp67_ = j;
								_tmp68_ = pnode;
								_tmp69_ = kkc_trellis_node_get_length (_tmp68_);
								_tmp70_ = _tmp69_;
								k = _tmp67_ - ((gint) _tmp70_);
								_tmp71_ = k;
								if (_tmp71_ < 0) {
									_kkc_trellis_node_unref0 (upnode);
									_kkc_trellis_node_unref0 (pnode);
									continue;
								}
								{
									GeeArrayList* _ppnode_list = NULL;
									GeeArrayList** _tmp72_ = NULL;
									gint _tmp72__length1 = 0;
									gint _tmp73_ = 0;
									GeeArrayList* _tmp74_ = NULL;
									GeeArrayList* _tmp75_ = NULL;
									gint _ppnode_size = 0;
									GeeArrayList* _tmp76_ = NULL;
									gint _tmp77_ = 0;
									gint _tmp78_ = 0;
									gint _ppnode_index = 0;
									_tmp72_ = trellis;
									_tmp72__length1 = trellis_length1;
									_tmp73_ = k;
									_tmp74_ = _tmp72_[_tmp73_];
									_tmp75_ = _g_object_ref0 (_tmp74_);
									_ppnode_list = _tmp75_;
									_tmp76_ = _ppnode_list;
									_tmp77_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp76_);
									_tmp78_ = _tmp77_;
									_ppnode_size = _tmp78_;
									_ppnode_index = -1;
									while (TRUE) {
										gint _tmp79_ = 0;
										gint _tmp80_ = 0;
										gint _tmp81_ = 0;
										KkcTrellisNode* ppnode = NULL;
										GeeArrayList* _tmp82_ = NULL;
										gint _tmp83_ = 0;
										gpointer _tmp84_ = NULL;
										KkcUnigramTrellisNode* uppnode = NULL;
										KkcTrellisNode* _tmp85_ = NULL;
										KkcUnigramTrellisNode* _tmp86_ = NULL;
										gboolean _tmp87_ = FALSE;
										GeeHashSet** _tmp88_ = NULL;
										gint _tmp88__length1 = 0;
										gint _tmp89_ = 0;
										GeeHashSet* _tmp90_ = NULL;
										KkcUnigramTrellisNode* _tmp91_ = NULL;
										gboolean _tmp92_ = FALSE;
										_tmp79_ = _ppnode_index;
										_ppnode_index = _tmp79_ + 1;
										_tmp80_ = _ppnode_index;
										_tmp81_ = _ppnode_size;
										if (!(_tmp80_ < _tmp81_)) {
											break;
										}
										_tmp82_ = _ppnode_list;
										_tmp83_ = _ppnode_index;
										_tmp84_ = gee_abstract_list_get ((GeeAbstractList*) _tmp82_, _tmp83_);
										ppnode = (KkcTrellisNode*) _tmp84_;
										_tmp85_ = ppnode;
										_tmp86_ = _kkc_trellis_node_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp85_, KKC_TYPE_UNIGRAM_TRELLIS_NODE) ? ((KkcUnigramTrellisNode*) _tmp85_) : NULL);
										uppnode = _tmp86_;
										_tmp88_ = overlapped_nodes;
										_tmp88__length1 = overlapped_nodes_length1;
										_tmp89_ = k;
										_tmp90_ = _tmp88_[_tmp89_];
										_tmp91_ = uppnode;
										_tmp92_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp90_, (KkcTrellisNode*) _tmp91_);
										if (!_tmp92_) {
											KkcBigramLanguageModel* _tmp93_ = NULL;
											KkcBigramLanguageModel* _tmp94_ = NULL;
											KkcUnigramTrellisNode* _tmp95_ = NULL;
											KkcLanguageModelEntry _tmp96_ = {0};
											KkcLanguageModelEntry _tmp97_ = {0};
											KkcUnigramTrellisNode* _tmp98_ = NULL;
											KkcLanguageModelEntry _tmp99_ = {0};
											KkcLanguageModelEntry _tmp100_ = {0};
											KkcUnigramTrellisNode* _tmp101_ = NULL;
											KkcLanguageModelEntry _tmp102_ = {0};
											KkcLanguageModelEntry _tmp103_ = {0};
											gboolean _tmp104_ = FALSE;
											_tmp93_ = kkc_bigram_decoder_get_model ((KkcBigramDecoder*) self);
											_tmp94_ = _tmp93_;
											_tmp95_ = uppnode;
											kkc_unigram_trellis_node_get_entry (_tmp95_, &_tmp96_);
											_tmp97_ = _tmp96_;
											_tmp98_ = upnode;
											kkc_unigram_trellis_node_get_entry (_tmp98_, &_tmp99_);
											_tmp100_ = _tmp99_;
											_tmp101_ = unode;
											kkc_unigram_trellis_node_get_entry (_tmp101_, &_tmp102_);
											_tmp103_ = _tmp102_;
											_tmp104_ = kkc_trigram_language_model_has_trigram (G_TYPE_CHECK_INSTANCE_CAST (_tmp94_, KKC_TYPE_TRIGRAM_LANGUAGE_MODEL, KkcTrigramLanguageModel), &_tmp97_, &_tmp100_, &_tmp103_);
											_tmp87_ = _tmp104_;
										} else {
											_tmp87_ = FALSE;
										}
										if (_tmp87_) {
											KkcBigramTrellisNode* bigram_node = NULL;
											KkcUnigramTrellisNode* _tmp105_ = NULL;
											KkcUnigramTrellisNode* _tmp106_ = NULL;
											gint _tmp107_ = 0;
											KkcBigramTrellisNode* _tmp108_ = NULL;
											GeeArrayList** _tmp109_ = NULL;
											gint _tmp109__length1 = 0;
											gint _tmp110_ = 0;
											GeeArrayList* _tmp111_ = NULL;
											KkcBigramTrellisNode* _tmp112_ = NULL;
											GeeHashSet** _tmp113_ = NULL;
											gint _tmp113__length1 = 0;
											gint _tmp114_ = 0;
											GeeHashSet* _tmp115_ = NULL;
											KkcUnigramTrellisNode* _tmp116_ = NULL;
											_tmp105_ = uppnode;
											_tmp106_ = upnode;
											_tmp107_ = j;
											_tmp108_ = kkc_bigram_trellis_node_new (_tmp105_, _tmp106_, (guint) _tmp107_);
											bigram_node = _tmp108_;
											_tmp109_ = trigram_trellis;
											_tmp109__length1 = trigram_trellis_length1;
											_tmp110_ = j;
											_tmp111_ = _tmp109_[_tmp110_];
											_tmp112_ = bigram_node;
											gee_abstract_collection_add ((GeeAbstractCollection*) _tmp111_, (KkcTrellisNode*) _tmp112_);
											_tmp113_ = overlapped_nodes;
											_tmp113__length1 = overlapped_nodes_length1;
											_tmp114_ = j;
											_tmp115_ = _tmp113_[_tmp114_];
											_tmp116_ = upnode;
											gee_abstract_collection_add ((GeeAbstractCollection*) _tmp115_, (KkcTrellisNode*) _tmp116_);
											_kkc_trellis_node_unref0 (bigram_node);
										}
										_kkc_trellis_node_unref0 (uppnode);
										_kkc_trellis_node_unref0 (ppnode);
									}
									_g_object_unref0 (_ppnode_list);
								}
								_kkc_trellis_node_unref0 (upnode);
								_kkc_trellis_node_unref0 (pnode);
							}
							_g_object_unref0 (_pnode_list);
						}
						_kkc_trellis_node_unref0 (unode);
						_kkc_trellis_node_unref0 (node);
					}
					_g_object_unref0 (_node_list);
				}
			}
		}
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp117_ = FALSE;
			_tmp117_ = TRUE;
			while (TRUE) {
				gint _tmp119_ = 0;
				GeeArrayList** _tmp120_ = NULL;
				gint _tmp120__length1 = 0;
				GeeArrayList** _tmp121_ = NULL;
				gint _tmp121__length1 = 0;
				gint _tmp122_ = 0;
				GeeArrayList* _tmp123_ = NULL;
				GeeArrayList** _tmp124_ = NULL;
				gint _tmp124__length1 = 0;
				gint _tmp125_ = 0;
				GeeArrayList* _tmp126_ = NULL;
				if (!_tmp117_) {
					gint _tmp118_ = 0;
					_tmp118_ = i;
					i = _tmp118_ + 1;
				}
				_tmp117_ = FALSE;
				_tmp119_ = i;
				_tmp120_ = trellis;
				_tmp120__length1 = trellis_length1;
				if (!(_tmp119_ < _tmp120__length1)) {
					break;
				}
				_tmp121_ = trellis;
				_tmp121__length1 = trellis_length1;
				_tmp122_ = i;
				_tmp123_ = _tmp121_[_tmp122_];
				_tmp124_ = trigram_trellis;
				_tmp124__length1 = trigram_trellis_length1;
				_tmp125_ = i;
				_tmp126_ = _tmp124_[_tmp125_];
				gee_array_list_add_all (_tmp123_, (GeeCollection*) _tmp126_);
			}
		}
	}
	overlapped_nodes = (_vala_array_free (overlapped_nodes, overlapped_nodes_length1, (GDestroyNotify) g_object_unref), NULL);
	trigram_trellis = (_vala_array_free (trigram_trellis, trigram_trellis_length1, (GDestroyNotify) g_object_unref), NULL);
}


static gint kkc_trigram_decoder_path_to_func_index (KkcTrigramDecoder* self, KkcTrellisNode* pnode, KkcTrellisNode* node) {
	gint result = 0;
	gint _tmp0_ = 0;
	KkcTrellisNode* _tmp1_ = NULL;
	gint pnode_index = 0;
	gint _tmp2_ = 0;
	KkcTrellisNode* _tmp3_ = NULL;
	gint node_index = 0;
	gint _tmp4_ = 0;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (pnode != NULL, 0);
	g_return_val_if_fail (node != NULL, 0);
	_tmp1_ = pnode;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, KKC_TYPE_UNIGRAM_TRELLIS_NODE)) {
		_tmp0_ = 0;
	} else {
		_tmp0_ = 1;
	}
	pnode_index = _tmp0_;
	_tmp3_ = node;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, KKC_TYPE_UNIGRAM_TRELLIS_NODE)) {
		_tmp2_ = 0;
	} else {
		_tmp2_ = 1;
	}
	node_index = _tmp2_;
	_tmp4_ = pnode_index;
	result = (_tmp4_ << 1) + node_index;
	return result;
}


static gdouble kkc_trigram_decoder_real_path_cost (KkcBigramDecoder* base, KkcTrellisNode* pnode, KkcTrellisNode* node, gint endpos) {
	KkcTrigramDecoder * self;
	gdouble result = 0.0;
	gint index = 0;
	KkcTrellisNode* _tmp0_ = NULL;
	KkcTrellisNode* _tmp1_ = NULL;
	gint _tmp2_ = 0;
	KkcPathCostFunc* _tmp3_ = NULL;
	KkcBigramLanguageModel* _tmp4_ = NULL;
	KkcBigramLanguageModel* _tmp5_ = NULL;
	KkcTrellisNode* _tmp6_ = NULL;
	KkcTrellisNode* _tmp7_ = NULL;
	gdouble _tmp8_ = 0.0;
	self = (KkcTrigramDecoder*) base;
	g_return_val_if_fail (pnode != NULL, 0.0);
	g_return_val_if_fail (node != NULL, 0.0);
	_tmp0_ = pnode;
	_tmp1_ = node;
	_tmp2_ = kkc_trigram_decoder_path_to_func_index (self, _tmp0_, _tmp1_);
	index = _tmp2_;
	_tmp3_ = self->priv->path_cost_funcs[index];
	_tmp4_ = kkc_bigram_decoder_get_model ((KkcBigramDecoder*) self);
	_tmp5_ = _tmp4_;
	_tmp6_ = pnode;
	_tmp7_ = node;
	_tmp8_ = kkc_path_cost_func_path_cost (_tmp3_, G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, KKC_TYPE_TRIGRAM_LANGUAGE_MODEL, KkcTrigramLanguageModel), _tmp6_, _tmp7_);
	result = _tmp8_;
	return result;
}


KkcTrigramDecoder* kkc_trigram_decoder_construct (GType object_type, KkcTrigramLanguageModel* model) {
	KkcTrigramDecoder * self = NULL;
	KkcTrigramLanguageModel* _tmp0_ = NULL;
	KkcUnigramToUnigramPathCostFunc* _tmp1_ = NULL;
	KkcPathCostFunc* _tmp2_ = NULL;
	KkcUnigramToBigramPathCostFunc* _tmp3_ = NULL;
	KkcPathCostFunc* _tmp4_ = NULL;
	KkcBigramToUnigramPathCostFunc* _tmp5_ = NULL;
	KkcPathCostFunc* _tmp6_ = NULL;
	KkcBigramToBigramPathCostFunc* _tmp7_ = NULL;
	KkcPathCostFunc* _tmp8_ = NULL;
	g_return_val_if_fail (model != NULL, NULL);
	_tmp0_ = model;
	self = (KkcTrigramDecoder*) kkc_bigram_decoder_construct (object_type, (KkcBigramLanguageModel*) _tmp0_);
	_tmp1_ = kkc_unigram_to_unigram_path_cost_func_new ();
	_kkc_path_cost_func_unref0 (self->priv->path_cost_funcs[0]);
	self->priv->path_cost_funcs[0] = (KkcPathCostFunc*) _tmp1_;
	_tmp2_ = self->priv->path_cost_funcs[0];
	_tmp3_ = kkc_unigram_to_bigram_path_cost_func_new ();
	_kkc_path_cost_func_unref0 (self->priv->path_cost_funcs[1]);
	self->priv->path_cost_funcs[1] = (KkcPathCostFunc*) _tmp3_;
	_tmp4_ = self->priv->path_cost_funcs[1];
	_tmp5_ = kkc_bigram_to_unigram_path_cost_func_new ();
	_kkc_path_cost_func_unref0 (self->priv->path_cost_funcs[2]);
	self->priv->path_cost_funcs[2] = (KkcPathCostFunc*) _tmp5_;
	_tmp6_ = self->priv->path_cost_funcs[2];
	_tmp7_ = kkc_bigram_to_bigram_path_cost_func_new ();
	_kkc_path_cost_func_unref0 (self->priv->path_cost_funcs[3]);
	self->priv->path_cost_funcs[3] = (KkcPathCostFunc*) _tmp7_;
	_tmp8_ = self->priv->path_cost_funcs[3];
	return self;
}


KkcTrigramDecoder* kkc_trigram_decoder_new (KkcTrigramLanguageModel* model) {
	return kkc_trigram_decoder_construct (KKC_TYPE_TRIGRAM_DECODER, model);
}


static void kkc_trigram_decoder_class_init (KkcTrigramDecoderClass * klass) {
	kkc_trigram_decoder_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (KkcTrigramDecoderPrivate));
	((KkcDecoderClass *) klass)->decode = kkc_trigram_decoder_real_decode;
	((KkcDecoderClass *) klass)->decode_with_costs = kkc_trigram_decoder_real_decode_with_costs;
	((KkcBigramDecoderClass *) klass)->path_cost = kkc_trigram_decoder_real_path_cost;
	G_OBJECT_CLASS (klass)->finalize = kkc_trigram_decoder_finalize;
}


static void kkc_trigram_decoder_instance_init (KkcTrigramDecoder * self) {
	self->priv = KKC_TRIGRAM_DECODER_GET_PRIVATE (self);
}


static void kkc_trigram_decoder_finalize (GObject* obj) {
	KkcTrigramDecoder * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, KKC_TYPE_TRIGRAM_DECODER, KkcTrigramDecoder);
	_vala_array_destroy (self->priv->path_cost_funcs, 4, (GDestroyNotify) kkc_path_cost_func_unref);
	G_OBJECT_CLASS (kkc_trigram_decoder_parent_class)->finalize (obj);
}


GType kkc_trigram_decoder_get_type (void) {
	static volatile gsize kkc_trigram_decoder_type_id__volatile = 0;
	if (g_once_init_enter (&kkc_trigram_decoder_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (KkcTrigramDecoderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) kkc_trigram_decoder_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (KkcTrigramDecoder), 0, (GInstanceInitFunc) kkc_trigram_decoder_instance_init, NULL };
		GType kkc_trigram_decoder_type_id;
		kkc_trigram_decoder_type_id = g_type_register_static (KKC_TYPE_BIGRAM_DECODER, "KkcTrigramDecoder", &g_define_type_info, 0);
		g_once_init_leave (&kkc_trigram_decoder_type_id__volatile, kkc_trigram_decoder_type_id);
	}
	return kkc_trigram_decoder_type_id__volatile;
}


static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	if ((array != NULL) && (destroy_func != NULL)) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}


static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}



