Gfsm::Alphabet - object-oriented interface to libgfsm string alphabets.


(Back to Top)


NAME

Gfsm::Alphabet - object-oriented interface to libgfsm string alphabets.

(Back to Top)


SYNOPSIS

 use Gfsm;
 ##------------------------------------------------------------
 ## Constructors, etc.
 $abet = Gfsm::Alphabet->new(); # construct a new alphabet
 $abet->clear();                # empty the alphabet
 ##--------------------------------------------------------------
 ## Alphabet properties
 $lab  = $abet->lab_min();      # get first allocated LabelId
 $lab  = $abet->lab_max();      # get last allocated LabelId
 $n    = $abet->size();         # get number of defined labels
 $bool = $abet->utf8(?$bool);   # get/set alphabet UTF-8 flag
 ##--------------------------------------------------------------
 ## Lookup & Manipulation
 $lab = $abet->insert($key);       # insert a key string
 $lab = $abet->insert($key,$lab);  # insert a key string, requesting label $lab
 
 $lab = $abet->get_label($key);    # get or insert label for $key
 $lab = $abet->find_label($key);   # get label for $key, else Gfsm::noLabel
 
 $key = $abet->find_key($lab);     # get key for label, else undef
 
 $abet->remove_key($key);          # remove a key, if defined
 $abet->remove_label($lab);        # remove a label, if defined
 
 $abet->merge($abet2);             # add $abet2 keys to $abet1
 $labs = $abet->labels();          # get array-ref of all labels in $abet
 ##--------------------------------------------------------------
 ## I/O
 $abet->load($filename_or_handle); # load AT&T-style .lab file
 $abet->save($filename_or_handle); # save AT&T-style .lab file
 ##--------------------------------------------------------------
 ## String utilities
 $labs = $abet->string_to_labels($str, $emit_warnings=1,$att_style=0); # string->labels
 $str  = $abet->labels_to_string($labs,$emit_warnings=1,$att_style=0); # labels->string
 ##--------------------------------------------------------------
 ## Conversion
 $abet      = $abet->fromHash(\%string2id);  # add mappings from \%string2id_hash
 $string2id = $abet->toHash();               # export mappings to hash-ref
 $string2id = $abet->asHash();               # read-only access to underlying index
 
 $abet      = $abet->fromArray(\@id2string); # add mappings from \@id2string
 $id2string = $abet->toArray();              # export mappings to array-ref
 $id2string = $abet->asArray();              # read-only access to underlying index

(Back to Top)


DESCRIPTION

Gfsm::Alphabet provides an object-oriented interface to string symbol alphabets as used by the libgfsm library.

(Back to Top)


BUGS AND LIMITATIONS

Probably many.

(Back to Top)


SEE ALSO

Gfsm(3perl), gfsmutils(1).

(Back to Top)


AUTHOR

Bryan Jurish <moocow@cpan.org>

(Back to Top)


COPYRIGHT AND LICENSE

Copyright (C) 2005-2014 by Bryan Jurish

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.

(Back to Top)

 Gfsm::Alphabet - object-oriented interface to libgfsm string alphabets.