LexicalAutomaton - Lexical automaton structure module
[Lexical tools level]

Definition and handling of lexical automaton data structure. (former automatelex module). More...

Data Structures

struct  LexicalAutomaton
 Lexical automaton data structure. More...

Functions

void lexicalAutomatonImplementAssociativeMemory (LexicalAssocMem *lam)
LexicalAutomatonlexicalAutomatonCreate (const LexicalDataType type)
void lexicalAutomatonFree (LexicalAutomaton *lexical_memory)
int lexicalAutomatonExport (const LexicalAutomaton *lexical_memory, const char *filename)
int lexicalAutomatonImport (LexicalAutomaton *lexical_memory, const char *filename)
int lexicalAutomatonSave (const LexicalAutomaton *lexical_memory, const char *filename)
int lexicalAutomatonLoad (LexicalAutomaton *lexical_memory, const char *filename)
int lexicalAutomatonDump (const LexicalAutomaton *lexical_memory, int(*print)(const char *,...))
InsertionResult lexicalAutomatonAdd (LexicalAutomaton *lexical_memory, const LexicalEntry entry)
size_t lexicalAutomatonGetSize (const LexicalAutomaton *lexical_memory)
LexicalSearch lexicalAutomatonSearchFirst (const LexicalAutomaton *lexical_memory, const LexicalEntry entry)
gboolean lexicalAutomatonSearchNext (LexicalSearch *search)
void lexicalAutomatonUniqIdToLexicalSearch (const LexicalAutomaton *lexical_memory, const UniqId uid, LexicalSearch *output)
LexicalEntry lexicalAutomatonGetNextEntry (LexicalAutomaton *lexical_memory)
void lexicalAutomatonGoToFirstEntry (LexicalAutomaton *lexical_memory)
LexicalCharacter lexicalAutomatonGetNextAvailableCharacter (LexicalAutomaton *lexical_memory)
void lexicalAutomatonGoToRoot (LexicalAutomaton *lexical_memory)
void lexicalAutomatonGoCharacterForward (LexicalAutomaton *lexical_memory)
void lexicalAutomatonGoCharacterBackward (LexicalAutomaton *lexical_memory)
gboolean lexicalAutomatonIsAtEndOfGraphy (const LexicalAutomaton *lexical_memory)
UniqId lexicalAutomatonGetCurrentGraphyId (const LexicalAutomaton *lexical_memory)
size_t lexicalAutomatonGetCurrentGraphyLength (const LexicalAutomaton *lexical_memory)
LexicalDataType lexicalAutomatonGetDataType (const LexicalAutomaton *lexical_memory)
LexicalEntry lexicalAutomatonAccess (const LexicalAutomaton *lexical_memory, const LexicalEntryIndex index)
LexicalEntry lexicalAutomatonGetGraphyFromUniqId (const LexicalAutomaton *lexical_memory, const UniqId identifier)

Detailed Description

Definition and handling of lexical automaton data structure. (former automatelex module).

SlpTK Library 0.6.0

Required header
<lexicalautomaton.h>
Author:
Claudia Craciun (creation on 01.06.1999)

Martin Keschenau (revision on 14.11.2000)

Cédric Luthi (revision on 16.02.2006)

Date:
1st December 2005
Version:
0.6.0

Function Documentation

LexicalEntry lexicalAutomatonAccess ( const LexicalAutomaton lexical_memory,
const LexicalEntryIndex  index 
)

Return the lexical entry associated to a given key

Remarks:
The function returns NULL if the specified key is not used
Parameters:
[in] lexical_memory The related lexical automaton
[in] index The key value
Returns:
The lexical entry indexed by the given key. It must be deallocated with the appropriate function call. For example, with g_string_free()

InsertionResult lexicalAutomatonAdd ( LexicalAutomaton lexical_memory,
const LexicalEntry  entry 
)

Insert a new entry in a lexical memory.

Insert a new lexical entry (graphy) into lexical memory. The function returns an insertion result whose nature may vary from one implementation to another.

Parameters:
[in] lexical_memory The lexical memory
[in] entry The graphy of the entry to insert
Returns:
The insertion result
See also:
getSize()

Remarks:
WARNING: this operation is very costly, try to avoid it if you can. Don't ever construct a lexical automaton by iteratively calling this function, consider using lexicalAutomatonImport instead

LexicalAutomaton * lexicalAutomatonCreate ( const LexicalDataType  type  ) 

Lexical memory constructor.

Allocate the memory and initialize a new lexical memory implementation.

Parameters:
[in] type The data type entries to store in the memory
Returns:
The new lexical memory instance
See also:
free()

See also:
lexicalAutomatonFree()
Former functions:
InitLexicalAutomatonChar and InitLexicalAutomatonUlong

int lexicalAutomatonDump ( const LexicalAutomaton lexical_memory,
int(*)(const char *,...)  print 
)

Dump the content of a lexical memory.

Dump the content of a lexical memory using a given print function. The function returns a not null error code if operation fails.

Parameters:
[in] lexical_memory The lexical memory to dump
[in] print The print function to use
Returns:
An error code

int lexicalAutomatonExport ( const LexicalAutomaton lexical_memory,
const char *  filename 
)

Export the content of a lexical memory.

Save the content of a lexical memory in a textual (human readable) file. The function returns a not null error code if operation fails.

Parameters:
[in] lexical_memory The lexical memory to export
[in] filename The name of the output file
Returns:
An error code
See also:
import()

See also:
lexicalAutomatonImport()

void lexicalAutomatonFree ( LexicalAutomaton lexical_memory  ) 

Free and destroy a lexical memory (destructor).

Destroy and free the memory allocated to a lexical memory

Parameters:
[in] lexical_memory The lexical memory to free
See also:
create()

See also:
lexicalAutomatonCreate()

UniqId lexicalAutomatonGetCurrentGraphyId ( const LexicalAutomaton lexical_memory  ) 

Return the unique identifier associated to the current position.

Return the identifier of the word corresponding to the current exploring position.

Remarks:
A call to this function makes sense only if the current position corresponds to the end of a stored word. The user must check this condition by using the isAtEndOfGraphy function. If the parsed word is not stored by the lexical memory, this function returns 0.
Parameters:
[in] lexical_memory The lexical memory to explore
Returns:
The identifier from currently explored word
See also:
isAtEndOfGraphy()

See also:
lexicalAutomatonIsAtEndOfGraphy()

size_t lexicalAutomatonGetCurrentGraphyLength ( const LexicalAutomaton lexical_memory  ) 

Return the length of the current word.

Return the length of the word associated to the current exploring position

Remarks:
The value returned is increment at every valid goCharacterForward call, decremented at every valid goCharacterBackward call, and reset to 0 at every goToRoot call.
Parameters:
[in] lexical_memory The lexical memory to explore
Returns:
The length of the word corresponding to the current exploring position

LexicalDataType lexicalAutomatonGetDataType ( const LexicalAutomaton lexical_memory  ) 

Tell the kind of lexical memory.

Return the data type of the entries stored in the lexical memory

Parameters:
[in] lexical_memory The lexical memory to identify
Returns:
The type of the stored entries
See also:
create()

See also:
lexicalAutomatonCreate()

LexicalEntry lexicalAutomatonGetGraphyFromUniqId ( const LexicalAutomaton lexical_memory,
const UniqId  identifier 
)

Return the graphy corresponding to its unique identifier.

Return the lexical entry given by its unique corresponding identifier.

Remarks:
In a given lexical memory, any stored entry corresponds to a unique identifier and any valid identifier corresponds to a unique stored entry.
Parameters:
[in] lexical_memory The lexical memory
[in] identifier The entry identifier
Returns:
The corresponding entry

See also:
lexicalAutomatonAccess()

LexicalCharacter lexicalAutomatonGetNextAvailableCharacter ( LexicalAutomaton lexical_memory  ) 

Return the next character available at the current position.

Iteratively return all the lexical characters available from the current exploring position. This function can be called until its returns NO_CHARACTER, signifying that all possible characters have been returned. At this point, a further call to getNextAvailableCharacter goes back to the first lexical character available.

Parameters:
[in] lexical_memory The lexical memory to explore
See also:
goCharacterForward() getCurrentGraphyLength() goToRoot()

See also:
lexicalAutomatonGoCharacterForward() lexicalAutomatonGetCurrentGraphyLength() lexicalAutomatonGoToRoot()

LexicalEntry lexicalAutomatonGetNextEntry ( LexicalAutomaton lexical_memory  ) 

Return the next graphy stored in a lexical memory.

Iteratively return all the graphies stored in a lexical memory. This function can be called until its returns NULL, signifying that all stored graphies have been returned.

Parameters:
[in] lexical_memory The lexical memory to make an inventory of
Returns:
The graphy of the next word stored
See also:
goToFirstEntry()

See also:
lexicalAutomatonGoToFirstEntry()

size_t lexicalAutomatonGetSize ( const LexicalAutomaton lexical_memory  ) 

Return the size of a lexical memory.

Return the number of entries stored in a lexical memory

Parameters:
[in] lexical_memory The lexical memory
Returns:
The number of entries stored

void lexicalAutomatonGoCharacterBackward ( LexicalAutomaton lexical_memory  ) 

Step one lexical character backward the current position.

Step backward the current exploring position from one lexical character. The exploring informations of the position before the call are lost so that when one goes back to that position, available characters inventory start again from the beginning.

Remarks:
This function has no effect if the current position is the root of the lexical memory
Parameters:
[in] lexical_memory The lexical memory to explore
See also:
goCharacterForward() goToRoot()

See also:
lexicalAutomatonGoCharacterForward() lexicalAutomatonGoToRoot()

void lexicalAutomatonGoCharacterForward ( LexicalAutomaton lexical_memory  ) 

Step one lexical character forward the current position.

Step forward the current exploring position from one lexical character, that is the value returned by the last call of getNextAvailableCharacter from the current exploring position. Each time this function is called, the current state is saved so that when one go back to a given exploring position using goCharacterBackward, the available characters inventory with getNextAvailableCharacter carries on as if the current position had not been left.

Remarks:
This function has no effect if getNextAvailableCharacter has not been called at least one time or no character is available from the current exploring position
Parameters:
[in] lexical_memory The lexical memory to explore
See also:
isAtEndOfGraphy() goToRoot()

See also:
lexicalAutomatonIsAtEndOfGraphy() lexicalAutomatonGoToRoot()

void lexicalAutomatonGoToFirstEntry ( LexicalAutomaton lexical_memory  ) 

Go back to the first graphy stored in a lexical memory.

This function can be called anytime to order to start again the lexical memory inventory (with getNextEntry) from the beginning.

Parameters:
[in] lexical_memory The lexical memory to make an inventory of

See also:
lexicalAutomatonGetNextEntry()

void lexicalAutomatonGoToRoot ( LexicalAutomaton lexical_memory  ) 

Set the current position to the root of the lexical memory.

Assign the current exploring position to the root of the lexical memory, i.e. before the first lexical character.

Parameters:
[in] lexical_memory The lexical memory to explore
See also:
goCharacterForward() goCharacterBackward()

See also:
lexicalAutomatonGoCharacterForward() lexicalAutomatonGoCharacterBackward()

void lexicalAutomatonImplementAssociativeMemory ( LexicalAssocMem lam  ) 

Implement a lexical associative memory instance with a lexical automaton data structure

Parameters:
[out] lam The lexical associative memory instance to implement

int lexicalAutomatonImport ( LexicalAutomaton lexical_memory,
const char *  filename 
)

Import the content of a lexical memory.

Load a lexical memory with the content of a textual (human readable) file. The function returns a not null error code if operation fails.

Parameters:
[out] lexical_memory The lexical memory where to import
[in] filename The name of the input file
Returns:
An error code
See also:
export()

See also:
lexicalAutomatonExport()

gboolean lexicalAutomatonIsAtEndOfGraphy ( const LexicalAutomaton lexical_memory  ) 

Tell if the current position corresponds to a stored entry.

Remarks:
The fact that the current position coincide with the end of a stored word doesn't imply that one can't carry on the exploration deeper (with goCharacterForward)
Parameters:
[in] lexical_memory The lexical memory to explore
Returns:
The current exploring position corresponds to the end of stoted word yes or not
See also:
getCurrentGraphyUniqId()

See also:
lexicalAutomatonGoCharacterBackward() lexicalAutomatonGoToRoot()

int lexicalAutomatonLoad ( LexicalAutomaton lexical_memory,
const char *  filename 
)

Load a lexical memory from a file.

Load a lexical memory from a binary (machine readable) save file. The function returns a not null error code if operation fails.

Parameters:
[out] lexical_memory The lexical memory where to load
[in] filename The name of the output file
Returns:
An error code
See also:
save()

See also:
lexicalAutomatonSave()

int lexicalAutomatonSave ( const LexicalAutomaton lexical_memory,
const char *  filename 
)

Save a lexical memory in a file.

Save the content of a lexical memory in a binary (machine readable) file. The function returns a not null error code if operation fails.

Remarks:
The binary file format is dependant of the lexical memory implementation and of the used platform
Parameters:
[in] lexical_memory The lexical memory to save
[in] filename The name of the output file
Returns:
An error code
See also:
load()

See also:
lexicalAutomatonLoad()

LexicalSearch lexicalAutomatonSearchFirst ( const LexicalAutomaton lexical_memory,
const LexicalEntry  entry 
)

Search the first occurence of a graphy in a lexical memory.

Search the information related to the first entry corresponding to a given graphy. The LexicalSearch::found field informs if such graphy has been found or not. If yes, other corresponding entries can be iteratively recovered using searchNext.

Parameters:
[in] lexical_memory The lexical memory where to search
[in] entry The graphy to search
Returns:
The search result

See also:
lexicalAutomatonSearchNext()

gboolean lexicalAutomatonSearchNext ( LexicalSearch search  ) 

Search the next occurence of a graphy in a lexical memory.

Carry on a search process initiate by searchFirst. This function can be iteratively called until its returns FALSE, signifying that all relevant entries have been returned.

Parameters:
[in] search The search result to update
Returns:
A new entry has been found yes or not

See also:
lexicalAutomatonSearchFirst()
Former function: RechercheSuivantDansLex

void lexicalAutomatonUniqIdToLexicalSearch ( const LexicalAutomaton lexical_memory,
const UniqId  uid,
LexicalSearch output 
)

Converts a UniqId to a LexicalSearch.

Converts an entry uniq identifier to the first corresponding LexicalSearch information. Notice however that the fields "found_length" and "specific.code" of the corresponding LexicalSearch are undefined in this context (and should thus not be used after).

Parameters:
[in] lexical_memory The corresponding lexical memory
[in] uid The UniqId to be converted
[in] output The LexicalSearch value to be updated
See also:
searchFirst()

See also:
lexicalAutomatonSearchFirst()


Generated on Thu Mar 22 17:46:31 2007 for SlpTk by  doxygen 1.4.7