Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Related Pages

Cdgdb - Get lexical entries out of a berkeley database


Detailed Description

Author:
Othello Maurer
Date:
unknown
This file provides an interface for retrieving lexical entries out of a berkeley database. The database file contains only references to an underlying cdg file which actually holds the entries. For loading the requested lexical entries, a temp file will be created out of the cdg file, containing only these entries. This file will then be parsed with inpuLoad() into the memory.


Data Structures

struct  entryStruct

Typedefs

typedef entryStructdbEntry

Functions

Boolean dbAvailable (void)
Boolean dbClose (void)
void dbFinalize (void)
List dbGetEntries (String word)
void dbInitialize (void)
Boolean dbLoad (String key)
Boolean dbLoadAll (List forms)
Boolean dbLoadEntries (List entries)
Boolean dbOpen (String name)
Boolean dbOpenCdgFile (String filename)
Boolean dbOpenIndexFile (String filename)
dbEntry newDbEntry ()

Variables

FILE * cdgstream
DB * database
time_t dbAge
String dbFileName
String dbIndexName
Hashtable done = NULL
String tmpFilename = NULL


Typedef Documentation

typedef entryStruct* dbEntry
 

a pointer to the entryStruct Definition at line 85 of file cdgdb.c.

Referenced by dbGetEntries(), dbLoadEntries(), and newDbEntry().


Function Documentation

Boolean dbAvailable void   ) 
 

checks if there is a database handle available.

Returns:
TRUE if there is a database opened, else FALSE
Definition at line 228 of file cdgdb.c.

References CDG_WARNING, cdgPrintf(), database, dbAge, dbClose(), dbFileName, dbIndexName, dbOpenCdgFile(), dbOpenIndexFile(), FALSE, and TRUE.

Referenced by cmdAnno2Parse(), dbFinalize(), dbLoad(), and dbLoadAll().

Boolean dbClose void   ) 
 

close the database. writes database to disk and closes it.

Returns:
TRUE if success, FALSE otherwise
Definition at line 160 of file cdgdb.c.

References CDG_ERROR, cdgPrintf(), database, FALSE, NULL, and TRUE.

Referenced by cmdCloseDB(), dbAvailable(), and dbFinalize().

void dbFinalize void   ) 
 

finalize close the database, delete done hash, remove temporary file Definition at line 457 of file cdgdb.c.

References dbAvailable(), dbClose(), done, and tmpFilename.

Referenced by cdgFinalize().

List dbGetEntries String  word  ) 
 

gets lexical entries from the database. gets a result list of LexiconItem matching the given word (the key) from the database. This function succeeds only once for a given word form.

Parameters:
word the word which is the key
Returns:
a list of dbEntry struct, all of them having the same key and NULL if there was an Error
Definition at line 274 of file cdgdb.c.

References CDG_ERROR, cdgPrintf(), database, dbEntry, entryStruct::key, newDbEntry(), NULL, entryStruct::oBegin, and entryStruct::oEnd.

Referenced by dbLoad(), and dbLoadAll().

void dbInitialize void   ) 
 

Initialize Definition at line 447 of file cdgdb.c.

References done.

Referenced by cdgInitialize().

Boolean dbLoad String  key  ) 
 

wrapper for dbLoadEntries(). generates a temp file which holds lexical entries and parses them into the memory

Parameters:
key the key of the lex entries which have to be parsed
Returns:
TRUE if success, else FALSE
Definition at line 385 of file cdgdb.c.

References CDG_INFO, cdgPrintf(), dbAvailable(), dbGetEntries(), dbLoadEntries(), done, FALSE, NULL, and TRUE.

Boolean dbLoadAll List  forms  ) 
 

Another wrapper for dbLoadEntries().

It loads all known lexicon items for words in the list FORMS. This has exactly the same effect as calling dbLoad() repeatedly, but is faster because there will be only one file system operation instead of n. Definition at line 415 of file cdgdb.c.

References CDG_INFO, CDG_PROGRESS, cdgPrintf(), dbAvailable(), dbGetEntries(), dbLoadEntries(), done, FALSE, NULL, and TRUE.

Referenced by cmdAnno2Parse().

Boolean dbLoadEntries List  entries  ) 
 

loads lexical entries into the memory. generates a temp file which holds lexical entries and parses them into the memory

Parameters:
entries a list of dbEntry structs you want to parse
Returns:
True if success, else FALSE
Definition at line 333 of file cdgdb.c.

References CDG_ERROR, CDG_INFO, cdgPrintf(), cdgstream, dbEntry, FALSE, hkVerbosity, NULL, entryStruct::oBegin, entryStruct::oEnd, tmpFilename, and TRUE.

Referenced by dbLoad(), and dbLoadAll().

Boolean dbOpen String  name  ) 
 

Open the data base.

NAME is the base name of the cdg and the index file. Definition at line 182 of file cdgdb.c.

References CDG_ERROR, cdgPrintf(), dbFileName, dbIndexName, dbOpenCdgFile(), dbOpenIndexFile(), FALSE, NULL, and TRUE.

Referenced by cmdUseLexicon().

Boolean dbOpenCdgFile String  filename  ) 
 

open the cdg file. opens the cdg file, which the database is indexing you have to ensure that it is the right one, otherwise you will get crap

Parameters:
filename the name of the cdg file
Returns:
TRUE if success, else FALSE
Definition at line 139 of file cdgdb.c.

References cdgstream, database, dbAge, dbFileName, and NULL.

Referenced by dbAvailable(), and dbOpen().

Boolean dbOpenIndexFile String  filename  ) 
 

opens a database. this function opens a database, specified by the parameter 'filename' and stores the handle in the static variable 'database'. If there is no database file with this filename, a new database is created.

Parameters:
filename the filename of the database file
Returns:
TRUE if success, FALSE otherwise
Definition at line 100 of file cdgdb.c.

References CDG_ERROR, cdgPrintf(), database, dbIndexName, FALSE, NULL, and TRUE.

Referenced by dbAvailable(), and dbOpen().

dbEntry newDbEntry  ) 
 

constructor for dbEntry objects.

Returns:
a new dbEntry
Definition at line 257 of file cdgdb.c.

References dbEntry, entryStruct::key, NULL, entryStruct::oBegin, and entryStruct::oEnd.

Referenced by dbGetEntries().


Variable Documentation

FILE* cdgstream [static]
 

the underlying cdg file. This is actually the file, where the lexical entries are stored in. Definition at line 56 of file cdgdb.c.

Referenced by dbLoadEntries(), and dbOpenCdgFile().

DB* database [static]
 

database handle. The handle to the database struct Definition at line 52 of file cdgdb.c.

Referenced by dbAvailable(), dbClose(), dbGetEntries(), dbOpenCdgFile(), and dbOpenIndexFile().

time_t dbAge [static]
 

age of that file at the time of the last opening Definition at line 65 of file cdgdb.c.

Referenced by dbAvailable(), and dbOpenCdgFile().

String dbFileName [static]
 

file name of the file with CDG input in it Definition at line 59 of file cdgdb.c.

Referenced by dbAvailable(), dbOpen(), and dbOpenCdgFile().

String dbIndexName [static]
 

file name of the index Definition at line 62 of file cdgdb.c.

Referenced by dbAvailable(), dbOpen(), and dbOpenIndexFile().

Hashtable done = NULL [static]
 

table of words already loaded. Holds the word which are yet retrieved from the database, so that the database won't be questioned for them Definition at line 73 of file cdgdb.c.

Referenced by dbFinalize(), dbInitialize(), dbLoad(), and dbLoadAll().

String tmpFilename = NULL [static]
 

the filename of the temporary file. This temporary file will contain a set of lexical entries that can then be parsed into the memory. Definition at line 69 of file cdgdb.c.

Referenced by dbFinalize(), and dbLoadEntries().


CDG 0.95 (20 Oct 2004)