Words.h File Reference

#include "StringUtil.h"

Include dependency graph for Words.h:


Data Structures

struct  WordList

Functions

WordListnewWordList (nat length, string *words)
void deleteWordList (WordList *this)
void printWordList (WordList *this)
string readFile (string fileName)
boolean isAlpha (char c)
WordListwords (string str)
boolean contains (string *words, nat length, string w)
void nub (WordList *this)
void wordListToLower (WordList *this)
void sortWith (WordList *this, boolean le(string, string))
string findRhyme (WordList *this, string w)

Detailed Description


Function Documentation

boolean contains ( string *  words,
nat  length,
string  w 
)

Check, whether a string is contained within an array of strings.

Parameters:
words is an array containing strings
length is the number of elements contained in the array.
w is the string we are looking for in the array.
Returns:
is true when the word was contained in the array.

void deleteWordList ( WordList this  ) 

A destructor function for WordList-objects.

This functions frees every word stored within the list and furthermore the array, wich contained the strings. Finally it frees the WordList-object itself.

Parameters:
this is the word list to be deleted.

string findRhyme ( WordList this,
string  w 
)

For a given word this function tries to find a rhyme word within a word list. The passed word list is assumed to be sorted such that rhyming words can be found next to each other.

Parameters:
this a word list where rhyming words are searched within. The list is assumed to be sorted by a rhyming relation.
w The word we try to find a rhyme word for.
Returns:
a rhyme word as a string or a NULL pointer.

boolean isAlpha ( char  c  ) 

This function test, if the given argument is a letter of the roman alphabet or a German umlaut or the German s-z-ligature letter. For the German non-Ascii letters the latin-1 encoding is assumed.

Parameters:
c is the character which is tested to be an alphabetic character.
Returns:
true for Roman characters.

WordList* newWordList ( nat  length,
string *  words 
)

A constructor function for WordList-objects.

Parameters:
length The length of the newly created list.
words The allready initialized array with the words.
Returns:
a pointer to the newly created object.

void nub ( WordList this  ) 

A procedure for deleting duplicates from the word list.

Internally copies of the strings are being made. The old array and the the old strings get deleted!

A new length is calculated and a new array allocated.

Parameters:
this is the word list which gets modified.

void printWordList ( WordList this  ) 

A simple print procedure, which prints every word contained in the word list to standard out: Every word gets printed on a single line.

Parameters:
this is the word list to be printed.

string readFile ( string  fileName  ) 

This function reads in a text file from the filesystem and gives the contents of the file as a single large string in the memory.

Parameters:
fileName the name of the file to be read.

void sortWith ( WordList this,
boolean   lestring, string 
)

This procedure sorts the internal array of the word list by a given function for the less equal comparision. It uses bubble sort as internal sorting algorithm.

Parameters:
this the word list to be sorted.
le A function which test for to strings if the first one is smaller or equal to the second one in a certain relation.

void wordListToLower ( WordList this  ) 

This procedure modifies everery single string stored in the word list into a corresponding string of lower case letters. No new memory is allocated. Nothing gets deleted.

Parameters:
this is the word list which gets modified.

WordList* words ( string  str  ) 

Creates a new WordList-object from a string by splitting the string into words. The string is splitted whenever a charcter has been found, which is not a letter of the Roman alphabet.

Parameters:
A complete text, which is to be splitted into single words.
Returns:
The list of words found in the string including duplicates.


Generated on Wed Dec 2 19:59:59 2009 for Reimlexikon by  doxygen 1.5.5