Data Structures | Macros | Typedefs
gfsmxlCascade.h File Reference

First stab at transducer cascade. More...

#include <gfsm.h>
#include <gfsmxlLabelIndex.h>
#include <gfsmxlSuffixIndex.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  gfsmxlCascade
 Type for an automaton cascade. More...
struct  gfsmxlCascadeArc
 Type for cascade arcs. More...
struct  gfsmxlCascadeArcIter
 Type for cascade arc iteration ?! More...
struct  gfsmxlCascadeHeader
 Header info for binary cascade files (gfsmAutomatonHeader pseudo-compatible) More...

Macros

#define CASCADE_USE_BLOCK_INDEX   1
#define CASCADE_USE_BLOCKS   1

Typedefs

typedef gfsmStateIdgfsmxlCascadeStateId
 Type for a raw cascade state id (array of csc->depth gfsmStateId, in cascade-order)

Functions

Constructors etc.
static gfsmxlCascadegfsmxl_cascade_new_full (guint depth, gfsmSRType srtype)
static gfsmxlCascadegfsmxl_cascade_new (void)
static void gfsmxl_cascade_free (gfsmxlCascade *csc, gboolean free_automata)
void gfsmxl_cascade_clear (gfsmxlCascade *csc, gboolean free_automata)
void gfsmxl_cascade_clear_nth (gfsmxlCascade *csc, guint n, gboolean free_automaton)
static gfsmIndexedAutomatongfsmxl_cascade_pop (gfsmxlCascade *csc)
static void gfsmxl_cascade_set_nth_indexed (gfsmxlCascade *csc, guint n, gfsmIndexedAutomaton *xfsm, gboolean free_old_automaton)
static void gfsmxl_cascade_append_indexed (gfsmxlCascade *csc, gfsmIndexedAutomaton *xfsm)
static void gfsmxl_cascade_append (gfsmxlCascade *csc, gfsmAutomaton *fsm)
State Utilities
static gfsmxlCascadeStateId gfsmxl_cascade_get_root (gfsmxlCascade *csc)
static gfsmxlCascadeStateId gfsmxl_cascade_stateid_sized_new (guint depth)
static gfsmxlCascadeStateId gfsmxl_cascade_stateid_new (gfsmxlCascade *csc)
static gfsmxlCascadeStateId gfsmxl_cascade_stateid_sized_copy (gfsmxlCascadeStateId dst, gfsmxlCascadeStateId src, guint depth)
static gfsmxlCascadeStateId gfsmxl_cascade_stateid_sized_clone (gfsmxlCascadeStateId src, guint depth)
static void gfsmxl_cascade_stateid_free (gfsmxlCascadeStateId qids, guint depth)
Arc Utilities: gfsmxlCascadeArc
static gfsmxlCascadeArcgfsmxl_cascade_arc_sized_new (guint depth)
static gfsmxlCascadeArcgfsmxl_cascade_arc_sized_copy (gfsmxlCascadeArc *dst, gfsmxlCascadeArc *src, guint depth)
static gfsmxlCascadeArcgfsmxl_cascade_arc_sized_clone (gfsmxlCascadeArc *src, guint depth)
static void gfsmxl_cascade_arc_free (gfsmxlCascadeArc *arc, guint depth)
Arc Iteration & Low-level Access
gfsmWeight gfsmxl_cascade_get_final_weight (gfsmxlCascade *csc, gfsmxlCascadeStateId qids)
gboolean gfsmxl_cascade_state_is_terminable (gfsmxlCascade *csc, gfsmxlCascadeStateId qids, gfsmxlSuffixLength ilen)
void gfsmxl_cascade_arciter_open (gfsmxlCascadeArcIter *cai, gfsmxlCascade *csc, gfsmxlCascadeStateId qids, gfsmLabelId lo)
void gfsmxl_cascade_arciter_close (gfsmxlCascadeArcIter *cai)
static gboolean gfsmxl_cascade_arciter_ok (gfsmxlCascadeArcIter *cai)
static gfsmxlCascadeArcgfsmxl_cascade_arciter_arc (gfsmxlCascadeArcIter *cai)
static void gfsmxl_cascade_arciter_next (gfsmxlCascadeArcIter *cai)
static void gfsmxl_cascade_arciter_reset (gfsmxlCascadeArcIter *cai)
static void gfsmxl_cascade_arciter_insert_arc_ (gfsmxlCascadeArcIter *cai, gfsmxlCascadeArc *carc)

High-level Access

#define gfsmxl_cascade_index(csc_, index_)   ((gfsmIndexedAutomaton*)g_ptr_array_index((csc_)->xfsms,(index_)))
static void gfsmxl_cascade_set_semiring_type (gfsmxlCascade *csc, gfsmSRType srtype)
static void gfsmxl_cascade_set_semiring (gfsmxlCascade *csc, gfsmSemiring *sr)
void gfsmxl_cascade_sort_all (gfsmxlCascade *csc, gfsmArcCompMask sort_mask)

Arc Utilities: gfsmxlArcPP

typedef gfsmArc ** gfsmxlArcPP
 Type for temporary cascade arcs (array of csc->depth gfsmArc*) a NULL value indicates a pure-epsilon move.
static gfsmxlArcPP gfsmxl_arcpp_sized_new (guint depth)
static gfsmxlArcPP gfsmxl_arcpp_sized_copy (gfsmxlArcPP dst, gfsmxlArcPP src, guint depth)
static gfsmxlArcPP gfsmxl_arcpp_sized_clone (gfsmxlArcPP src, guint depth)
static void gfsmxl_arcpp_free (gfsmxlArcPP arcpp, guint depth)
static gfsmLabelId gfsmxl_arcpp_lower (gfsmxlArcPP arcpp)
static gfsmLabelId gfsmxl_arcpp_upper (gfsmxlArcPP arcpp, guint depth)
static gfsmWeight gfsmxl_arcpp_weight (gfsmxlArcPP arcpp, guint depth, gfsmSemiring *sr)
static void gfsmxl_arcpp_target (gfsmxlArcPP arcpp, gfsmxlCascadeStateId src, gfsmxlCascadeStateId dst, guint depth)

Binary I/O

const gchar gfsm_cascade_header_magic [16]
const gfsmVersionInfo gfsm_cascade_version_bincompat_min_store
const gfsmVersionInfo gfsm_cascade_version_bincompat_min_check
gboolean gfsmxl_cascade_load_header (gfsmxlCascadeHeader *hdr, gfsmIOHandle *ioh, gfsmError **errp)
gboolean gfsmxl_cascade_load_bin_handle (gfsmxlCascade *csc, gfsmIOHandle *ioh, gfsmError **errp)
gboolean gfsmxl_cascade_load_bin_file (gfsmxlCascade *csc, FILE *f, gfsmError **errp)
gboolean gfsmxl_cascade_load_bin_filename (gfsmxlCascade *csc, const gchar *filename, gfsmError **errp)
gboolean gfsmxl_cascade_load_bin_gstring (gfsmxlCascade *csc, GString *gs, gfsmError **errp)
gboolean gfsmxl_cascade_save_bin_handle (gfsmxlCascade *csc, gfsmIOHandle *ioh, gfsmError **errp)
gboolean gfsmxl_cascade_save_bin_file (gfsmxlCascade *csc, FILE *f, gfsmError **errp)
gboolean gfsmxl_cascade_save_bin_filename_nc (gfsmxlCascade *csc, const gchar *filename, gfsmError **errp)
gboolean gfsmxl_cascade_save_bin_filename (gfsmxlCascade *csc, const gchar *filename, int zlevel, gfsmError **errp)
gboolean gfsmxl_cascade_save_bin_gstring (gfsmxlCascade *csc, GString *gs, gfsmError **errp)

Detailed Description

Macro Definition Documentation

#define CASCADE_USE_BLOCK_INDEX   1
#define CASCADE_USE_BLOCKS   1
#define gfsmxl_cascade_index (   csc_,
  index_ 
)    ((gfsmIndexedAutomaton*)g_ptr_array_index((csc_)->xfsms,(index_)))

Macro to get a pointer to the gfsmIndexedAutomaton at depth index_ in csc_. csc_ must have depth at least index_+1 for this to work

Typedef Documentation

typedef gfsmArc** gfsmxlArcPP

Function Documentation

static gfsmxlCascade* gfsmxl_cascade_new_full ( guint  depth,
gfsmSRType  srtype 
)
inlinestatic

Create a new gfsmxlCascade

static gfsmxlCascade* gfsmxl_cascade_new ( void  )
inlinestatic

Create a new indexed automaton, using some default values

static void gfsmxl_cascade_free ( gfsmxlCascade csc,
gboolean  free_automata 
)
inlinestatic

Free a gfsmxlCascade

void gfsmxl_cascade_clear ( gfsmxlCascade csc,
gboolean  free_automata 
)

Clear a gfsmxlCascade

void gfsmxl_cascade_clear_nth ( gfsmxlCascade csc,
guint  n,
gboolean  free_automaton 
)

Clear the n-th element of a gfsmxlCascade (invalidates the cascade)

static gfsmIndexedAutomaton* gfsmxl_cascade_pop ( gfsmxlCascade csc)
inlinestatic

Steal the rightmost automaton from a cascade; calls gfsmxl_cascade_clear_nth(csc,csc->depth-1,FALSE)

static void gfsmxl_cascade_set_nth_indexed ( gfsmxlCascade csc,
guint  n,
gfsmIndexedAutomaton xfsm,
gboolean  free_old_automaton 
)
inlinestatic

Set the n-th element of a gfsmxlCascade; calls gfsm_cascade_clear_nth(csc,n,free_old_automaton)

static void gfsmxl_cascade_append_indexed ( gfsmxlCascade csc,
gfsmIndexedAutomaton xfsm 
)
inlinestatic

Append an indexed automaton to a cascade. Steals xfsm

static void gfsmxl_cascade_append ( gfsmxlCascade csc,
gfsmAutomaton fsm 
)
inlinestatic

Append an un-indexed automaton to a cascade. Calls gfsm_automaton_to_indexed()

static void gfsmxl_cascade_set_semiring_type ( gfsmxlCascade csc,
gfsmSRType  srtype 
)
inlinestatic

Set semiring type

static void gfsmxl_cascade_set_semiring ( gfsmxlCascade csc,
gfsmSemiring sr 
)
inlinestatic

Set semiring (copy)

void gfsmxl_cascade_sort_all ( gfsmxlCascade csc,
gfsmArcCompMask  sort_mask 
)

Sort arcs of all sub-automata

static gfsmxlCascadeStateId gfsmxl_cascade_get_root ( gfsmxlCascade csc)
inlinestatic

Get root-id of cascade (never free this yourself!)

static gfsmxlCascadeStateId gfsmxl_cascade_stateid_sized_new ( guint  depth)
inlinestatic

Allocate a new gfsmxlCascadeStateId suitable for a cascade of depth

static gfsmxlCascadeStateId gfsmxl_cascade_stateid_new ( gfsmxlCascade csc)
inlinestatic

Allocate a new gfsmxlCascadeStateId suitable for csc

static gfsmxlCascadeStateId gfsmxl_cascade_stateid_sized_copy ( gfsmxlCascadeStateId  dst,
gfsmxlCascadeStateId  src,
guint  depth 
)
inlinestatic

Copy a gfsmxlCascadeStateId src to dst.

Returns
dst
static gfsmxlCascadeStateId gfsmxl_cascade_stateid_sized_clone ( gfsmxlCascadeStateId  src,
guint  depth 
)
inlinestatic

Clone a gfsmxlCascadeStateId of depth depth

static void gfsmxl_cascade_stateid_free ( gfsmxlCascadeStateId  qids,
guint  depth 
)
inlinestatic
static gfsmxlArcPP gfsmxl_arcpp_sized_new ( guint  depth)
inlinestatic

Allocate a new gfsmxlArcPP suitable for a cascade of depth

static gfsmxlArcPP gfsmxl_arcpp_sized_copy ( gfsmxlArcPP  dst,
gfsmxlArcPP  src,
guint  depth 
)
inlinestatic

Copy a gfsmxlArcPP src to dst.

Returns
dst
static gfsmxlArcPP gfsmxl_arcpp_sized_clone ( gfsmxlArcPP  src,
guint  depth 
)
inlinestatic

Clone a gfsmxlArcPP of depth depth

static void gfsmxl_arcpp_free ( gfsmxlArcPP  arcpp,
guint  depth 
)
inlinestatic

Free a gfsmxlArcPP as returned by gfsmxl_arcpp_sized_new()

static gfsmLabelId gfsmxl_arcpp_lower ( gfsmxlArcPP  arcpp)
inlinestatic

Get ultimate lower label of a gfsmxlArcPP

static gfsmLabelId gfsmxl_arcpp_upper ( gfsmxlArcPP  arcpp,
guint  depth 
)
inlinestatic

Get ultimate upper label of a gfsmxlArcPP

static gfsmWeight gfsmxl_arcpp_weight ( gfsmxlArcPP  arcpp,
guint  depth,
gfsmSemiring sr 
)
inlinestatic

Get total weight of a gfsmxlArcPP

static void gfsmxl_arcpp_target ( gfsmxlArcPP  arcpp,
gfsmxlCascadeStateId  src,
gfsmxlCascadeStateId  dst,
guint  depth 
)
inlinestatic

Copy target state of a gfsmxlArcPP to dst, assuming start state was src

static gfsmxlCascadeArc* gfsmxl_cascade_arc_sized_new ( guint  depth)
inlinestatic

Allocate a new gfsmxlCascadeArc suitable for a cascade csc

static gfsmxlCascadeArc* gfsmxl_cascade_arc_sized_copy ( gfsmxlCascadeArc dst,
gfsmxlCascadeArc src,
guint  depth 
)
inlinestatic

Copy a gfsmxlCascadeArc src for csc to dst.

Returns
dst
static gfsmxlCascadeArc* gfsmxl_cascade_arc_sized_clone ( gfsmxlCascadeArc src,
guint  depth 
)
inlinestatic

Clone a gfsmxlCascadeArc of depth depth

static void gfsmxl_cascade_arc_free ( gfsmxlCascadeArc arc,
guint  depth 
)
inlinestatic
gfsmWeight gfsmxl_cascade_get_final_weight ( gfsmxlCascade csc,
gfsmxlCascadeStateId  qids 
)

Get state final weight or csc->sr->zero if state is non-final

gboolean gfsmxl_cascade_state_is_terminable ( gfsmxlCascade csc,
gfsmxlCascadeStateId  qids,
gfsmxlSuffixLength  ilen 
)

Check whether a gfsmxlCascadeStateId is terminable Only useful if GFSMXL_USE_SUFFIX_INDEX is defined

void gfsmxl_cascade_arciter_open ( gfsmxlCascadeArcIter cai,
gfsmxlCascade csc,
gfsmxlCascadeStateId  qids,
gfsmLabelId  lo 
)

Open outgoing arcs from state qids in csc with ultimate lower label eithr epsilon or lo.

  • Clones qids into arcs->qids.
  • Allocates some temporaries, including any and all arcs found
void gfsmxl_cascade_arciter_close ( gfsmxlCascadeArcIter cai)

Close a cascade arc iterator cai, freeing any data associated with it

static gboolean gfsmxl_cascade_arciter_ok ( gfsmxlCascadeArcIter cai)
inlinestatic

Check whether there are arcs remaining in a gfsmxlCascadeArcIter

static gfsmxlCascadeArc* gfsmxl_cascade_arciter_arc ( gfsmxlCascadeArcIter cai)
inlinestatic

Get current arc from a gfsmxlCascadeArcIter.

  • Assumes that cai is valid.
  • Returned arc will be freed when cai is closed
static void gfsmxl_cascade_arciter_next ( gfsmxlCascadeArcIter cai)
inlinestatic

Increment an open gfsmxlCascadeArcIter. Assumes that cai is valid.

static void gfsmxl_cascade_arciter_reset ( gfsmxlCascadeArcIter cai)
inlinestatic

Reset an open gfsmxlCascadeArcIter to the first arc for which it was opened.

static void gfsmxl_cascade_arciter_insert_arc_ ( gfsmxlCascadeArcIter cai,
gfsmxlCascadeArc carc 
)
inlinestatic

Low-level utility: insert an arc into a ->arclist, unsorted

gboolean gfsmxl_cascade_load_header ( gfsmxlCascadeHeader hdr,
gfsmIOHandle ioh,
gfsmError **  errp 
)

Load an automaton header from a stored binary file. Returns TRUE iff the header looks valid.

gboolean gfsmxl_cascade_load_bin_handle ( gfsmxlCascade csc,
gfsmIOHandle ioh,
gfsmError **  errp 
)

Load an automaton from a named binary file (implicitly clear()s fsm)

gboolean gfsmxl_cascade_load_bin_file ( gfsmxlCascade csc,
FILE *  f,
gfsmError **  errp 
)

Load an automaton from a stored binary file (implicitly clear()s fsm)

gboolean gfsmxl_cascade_load_bin_filename ( gfsmxlCascade csc,
const gchar *  filename,
gfsmError **  errp 
)

Load an automaton from a named binary file (implicitly clear()s fsm)

gboolean gfsmxl_cascade_load_bin_gstring ( gfsmxlCascade csc,
GString *  gs,
gfsmError **  errp 
)

Load an automaton from an in-memory buffer

gboolean gfsmxl_cascade_save_bin_handle ( gfsmxlCascade csc,
gfsmIOHandle ioh,
gfsmError **  errp 
)

Store an automaton in binary form to a gfsmIOHandle*

gboolean gfsmxl_cascade_save_bin_file ( gfsmxlCascade csc,
FILE *  f,
gfsmError **  errp 
)

Store an automaton in binary form to a file

gboolean gfsmxl_cascade_save_bin_filename_nc ( gfsmxlCascade csc,
const gchar *  filename,
gfsmError **  errp 
)

Store an automaton to a named binary file (no compression)

gboolean gfsmxl_cascade_save_bin_filename ( gfsmxlCascade csc,
const gchar *  filename,
int  zlevel,
gfsmError **  errp 
)

Store an automaton to a named binary file, possibly compressing. Set zlevel=-1 for default compression, and set zlevel=0 for no compression, otherwise should be as for zlib (1 <= zlevel <= 9)

gboolean gfsmxl_cascade_save_bin_gstring ( gfsmxlCascade csc,
GString *  gs,
gfsmError **  errp 
)

Append an uncompressed binary automaton to an in-memory buffer

Variable Documentation

const gchar gfsm_cascade_header_magic[16]

Magic header string for stored gfsmxlCascade files

const gfsmVersionInfo gfsm_cascade_version_bincompat_min_store

Minimum libgfsm version required for loading files stored by this version of libgfsm

const gfsmVersionInfo gfsm_cascade_version_bincompat_min_check

Minimum libgfsm version whose binary files this version of libgfsm can read