ULAPI  8.0
Public Member Functions | List of all members
ULDefiner Class Reference

A worker that looks up words in bilingual or monolingual dictionary data sources and supplies definitions for those words. More...

#include <uldefiner.h>

Public Member Functions

 ULDefiner ()
 
 ULDefiner (const ULDefiner &other)
 
virtual ~ULDefiner ()
 
ULDefineroperator= (const ULDefiner &other)
 
virtual void clear ()
 
virtual bool isServiceAvailable (const ULServiceDescriptor &service)
 
virtual void getAvailableServices (ULList< ULServiceDescriptor > &serviceList)
 
void setDictionaryDataSource (ULDictionaryDataSource *dataSource)
 
ULDictionaryDataSourcegetDictionaryDataSource ()
 
void setFirstStemmer (ULStemmer *stemmer)
 
ULStemmergetFirstStemmer ()
 
void setSecondStemmer (ULStemmer *stemmer)
 
ULStemmergetSecondStemmer ()
 
virtual ULError begin (const ULLanguage &searchLanguage, uluint32 indexID, ULDictionaryIterator &iterator)
 
virtual ULError end (const ULLanguage &searchLanguage, uluint32 indexID, ULDictionaryIterator &iterator)
 
virtual ULError find (const ULString &s, const ULLanguage &searchLanguage, uluint32 indexID, ULDictionaryIterator &iterator)
 
ULError simpleFind (const ULString &s, const ULLanguage &searchLanguage, ULDictionaryIterator &iterator)
 
ULError find (const ULString &searchString, const ULLanguage &searchLanguage, ULDictionaryIterator &dictionaryIterator)
 
ULError getHeadwordSearchResults (const ULString &originalSearchString, const ULLanguage &searchLanguage, uluint32 maxBrowsingResults, uluint32 approximateRequiredPrefixLength, ULList< ULDerivation > &stemmingMatches, ULList< ULDerivation > &substringMatches, ULList< ULDerivation > &approximateMatches)
 
ULError lookUp (const ULString &searchString, const ULLanguage &searchLanguage, ULList< ULDictionaryIterator > &results)
 
- Public Member Functions inherited from ULDictionary
virtual ~ULDictionary ()
 
- Public Member Functions inherited from ULWorker
 ULWorker ()
 
virtual ~ULWorker ()
 
virtual void setCancelOperation (bool shouldCancel)
 
virtual bool shouldCancelOperation () const
 

Detailed Description

A worker that looks up words in bilingual or monolingual dictionary data sources and supplies definitions for those words.

Constructor & Destructor Documentation

ULDefiner::ULDefiner ( )

Default constructor.

ULDefiner::ULDefiner ( const ULDefiner other)

Copy constructor.

ULDefiner::~ULDefiner ( )
virtual

Destructor.

Member Function Documentation

ULError ULDefiner::begin ( const ULLanguage searchLanguage,
uluint32  indexID,
ULDictionaryIterator iterator 
)
virtual

Creates an iterator pointing to the first ULDictionaryNode in the set of nodes associated with the specified index. An "index" in this context refers to a sorted list of strings in the data source associated with this ULDictionary object. The most common index is the "headword" index, which is an alphabetized list of labels for dictionary entries. Other indexes may support searching for dictionary entries whose definitions contain the search string, or whose "domain" labels (e.g. "Cooking", "Botany", "Computers", "Sports") match the search string, etc.

Returns
ULError::NoError, ULError::MemoryAllocationFailed, or ULError::DataSourceOpenFailed.
Parameters
[in]searchLanguageFor bilingual dictionaries, this indicates the language of the index in question. (For example, an English-Spanish data source would have both an English headword index and a Spanish headword index, and searchLanguage would tell begin() which of these indexes to use.)
[in]indexIDAn enumerated value specifying which index to search.
[out]iteratorAn iterator pointing to the first ULDictionaryNode associated with the specified index.

Implements ULDictionary.

void ULDefiner::clear ( )
virtual

Sets this definer to its default state. This method does not delete the dictionary data source, if any, associated with this definer.

ULError ULDefiner::end ( const ULLanguage searchLanguage,
uluint32  indexID,
ULDictionaryIterator iterator 
)
virtual

Creates an iterator pointing to the end of the list of ULDictionaryNodes associated with the specified index. An "index" in this context refers to a sorted list of strings in the data source associated with this ULDictionary object. The most common index is the "headword" index, which is an alphabetized list of labels for dictionary entries. Other indexes may support searching for dictionary entries whose definitions contain the search string, or whose "domain" labels (e.g. "Cooking", "Botany", "Computers", "Sports") match the search string, etc.

Returns
ULError::NoError, ULError::MemoryAllocationFailed, or ULError::DataSourceOpenFailed.
Parameters
[in]searchLanguageFor bilingual dictionaries, this indicates the language of the index in question. (For example, an English-Spanish data source would have both an English headword index and a Spanish headword index, and searchLanguage would tell begin() which of these indexes to use.)
[in]indexIDAn enumerated value specifying which index to search.
[out]iteratorAn iterator pointing to the end of the ULDictionaryNode list associated with the specified index.

Implements ULDictionary.

ULError ULDefiner::find ( const ULString searchString,
const ULLanguage searchLanguage,
uluint32  indexID,
ULDictionaryIterator iterator 
)
virtual

Searches the data source(s) associated with this ULDictionary for the closest match to the specified search string, using the specified language and index. An "index" in this context refers to a sorted list of strings in the data source associated with this ULDictionary object. The most common index is the "headword" index, which is an alphabetized list of labels for dictionary entries. Other indexes may support searching for dictionary entries whose definitions contain the search string, or whose "domain" labels (e.g. "Cooking", "Botany", "Computers", "Sports") match the search string, etc.

The "closest match" found by this method is closest in the sense of a binary search on a sorted list. More specifically, the closest match is the lexicographically smallest item in the specified index that is greater than or equal to the search string. Thus, for example, if you search for "sp" in English, you'll get an iterator pointing to the first English word starting with "sp" or "Sp" (e.g. "spa").

Returns
ULError::NoError, ULError::MemoryAllocationFailed, or ULError::DataSourceOpenFailed.
Parameters
[in]searchStringThe string you're looking for.
[in]searchLanguageFor bilingual dictionaries, this specifies the direction in which to search–i.e. the language in which searchString is to be interpreted.
[in]indexIDAn enumerated value specifying which index to search.
[out]iteratorAn iterator pointing to the closest match in the specified index. This iterator will point to a top-level ULDictionaryNode (i.e. one with no parent node).

Implements ULDictionary.

ULError ULDefiner::find ( const ULString searchString,
const ULLanguage searchLanguage,
ULDictionaryIterator dictionaryIterator 
)

Searches this ULDefiner's data source for the term whose text matches the specified search string most closely, using the specified language.

The "closest match" found by this method is more complex than that found by ULDefiner::simpleFind. If searchString consists of a single word, the search of the data source's headword index is case- and accent-insensitive, but will favor an exact match over an inexact one. For example, if you search for "polish", the resulting iterator will typically point to "polish [noun]", while if you search for "Polish", it will point to "Polish [adjective]".

If searchString has more than one word, each token (defined roughly as non-stopword words in the string) is used in turn to search the headword index. If a case-/accent-insensitive match between token and headword is found, all terms filed under that headword are searched until a term whose text contains searchString (again, insensitively). For example, if you search for "wrong foot", a match would typically be found under "foot" at the term "get off on the wrong foot". If no multi-word match is found, then an ordinary binary search of the headword index is performed using searchString as a best-effort fall-back. For example, "wong foot" would likely land at "wont [noun]".

Returns
ULError::NoError, ULError::MemoryAllocationFailed, or ULError::DataSourceOpenFailed.
Parameters
[in]searchStringThe string you're looking for.
[in]searchLanguageFor bilingual dictionaries, this specifies the direction in which to search–i.e. the language in which searchString is to be interpreted.
[out]iteratorAn iterator pointing to the closest match. This iterator will point to a top-level ULDictionaryNode.
void ULDefiner::getAvailableServices ( ULList< ULServiceDescriptor > &  serviceList)
virtual
Parameters
[out]serviceListUsed to return a list of all the services this ULWorker can provide.

Implements ULWorker.

ULDictionaryDataSource * ULDefiner::getDictionaryDataSource ( )

Accessor.

ULStemmer * ULDefiner::getFirstStemmer ( )
Returns
a pointer to the ULStemmer object that supports this getHeadwordSearchResults for this ULDefiner for stemming in the first language.
ULError ULDefiner::getHeadwordSearchResults ( const ULString originalSearchString,
const ULLanguage searchLanguage,
uluint32  maxBrowsingResults,
uluint32  approximateRequiredPrefixLength,
ULList< ULDerivation > &  stemmingMatches,
ULList< ULDerivation > &  substringMatches,
ULList< ULDerivation > &  approximateMatches 
)
ULStemmer * ULDefiner::getSecondStemmer ( )
Returns
a pointer to the ULStemmer object that supports this getHeadwordSearchResults for this ULDefiner for stemming in the second language.
bool ULDefiner::isServiceAvailable ( const ULServiceDescriptor service)
virtual
Returns
true if the specified service can be performed by this ULWorker, and false otherwise.
Parameters
serviceThe desired service.

Implements ULWorker.

ULError ULDefiner::lookUp ( const ULString searchString,
const ULLanguage searchLanguage,
ULList< ULDictionaryIterator > &  dictionaryIteratorList 
)

Finds all exact or stemmed matches of the specified search string in this definer's dictionary data source.

ULDefiner & ULDefiner::operator= ( const ULDefiner other)

Assignment operator.

void ULDefiner::setDictionaryDataSource ( ULDictionaryDataSource dataSource)

Accessor. The ULDefiner does not take responsibility for deleting the data source. That will need to happen elsewhere (typically the ULFactory will take care of it if your application uses ULFactory to instantiate data sources and workers).

void ULDefiner::setFirstStemmer ( ULStemmer stemmer)

Sets this definer's stemmer for the first language as determined by the data source, which is used to stem the words provided to getHeadwordSearchResults to get any stemmed matches for the given search term if it is in the first language.

Parameters
[in]stemmerThe new ULStemmer for the first language.
void ULDefiner::setSecondStemmer ( ULStemmer stemmer)

Sets this definer's stemmer for the second language as determined by the data source, which is used to stem the words provided to getHeadwordSearchResults to get any stemmed matches for the given search term if it is in the second language.

Parameters
[in]stemmerThe new ULStemmer for the second language.
ULError ULDefiner::simpleFind ( const ULString s,
const ULLanguage searchLanguage,
ULDictionaryIterator iterator 
)

Searches this ULDefiner's data source for the headword that matches the specified search string most closely, using the specified language.

The "closest match" found by this method is closest in the sense of a binary search on a sorted list. More specifically, the closest match is the lexicographically smallest item in the specified index that is greater than or equal to the search string. Thus, for example, if you search for "sp" in English, you'll get an iterator pointing to the first English word starting with "sp" or "Sp" (e.g. "spa").

Returns
ULError::NoError, ULError::MemoryAllocationFailed, or ULError::DataSourceOpenFailed.
Parameters
[in]searchStringThe string you're looking for.
[in]searchLanguageFor bilingual dictionaries, this specifies the direction in which to search–i.e. the language in which searchString is to be interpreted.
[out]iteratorAn iterator pointing to the closest match. This iterator will point to a top-level ULDictionaryNode.

The documentation for this class was generated from the following files: