ULAPI  8.0
Public Types | Public Member Functions | List of all members
ULDictionaryDataSource Class Referenceabstract

ULDictionaryDataSource is the abstract parent for classes that interface with dictionary data stored somewhere like a .uld file or a database. More...

#include <uldictionarydatasource.h>

Public Types

enum  { HeadwordIndex, OntologyIndex, NCommonIndexIDs }
 

Public Member Functions

virtual ULError attach (const ULString &dataSourceIdentifier)=0
 
virtual ULError detach ()=0
 
virtual ULError load ()=0
 
virtual ULError close ()=0
 
virtual ULString getDataSourceIdentifier ()=0
 
virtual ULDataSourceVersion getVersion ()=0
 
virtual ULError begin (const ULLanguage &searchLanguage, uluint32 indexID, ULDictionaryIterator &iterator)=0
 
virtual ULError end (const ULLanguage &searchLanguage, uluint32 indexID, ULDictionaryIterator &iterator)=0
 
virtual ULError find (const ULString &s, const ULLanguage &searchLanguage, uluint32 indexID, ULDictionaryIterator &iterator)=0
 
virtual bool operator== (const ULDictionaryDataSource &dataSource) const =0
 
virtual ULDictionaryDescriptor getDictionaryDescriptor ()=0
 
virtual const ULLanguagegetFirstLanguage ()=0
 
virtual const ULLanguagegetSecondLanguage ()=0
 
virtual const ULLanguagegetOtherLanguage (const ULLanguage &language)=0
 
virtual ULForestType getForestType ()=0
 
virtual void setForester (ULForester *newForester)=0
 
virtual ULForester * getForester ()=0
 
virtual ULError getFeatureNameList (ULList< ULString > &featureNameList)=0
 
virtual ULError getLocalizationRuleList (const ULLanguage &language, ULList< ULLocalizationRule > &localizationRulesList)=0
 
virtual bool getULDAttribute (const ULString &key, ULString &value)=0
 
- Public Member Functions inherited from ULDictionary
virtual ~ULDictionary ()
 
- Public Member Functions inherited from ULWorker
 ULWorker ()
 
virtual ~ULWorker ()
 
virtual bool isServiceAvailable (const ULServiceDescriptor &service)=0
 
virtual void getAvailableServices (ULList< ULServiceDescriptor > &serviceList)=0
 
virtual void setCancelOperation (bool shouldCancel)
 
virtual bool shouldCancelOperation () const
 
- Public Member Functions inherited from ULDataSource
virtual ~ULDataSource ()
 
- Public Member Functions inherited from ULLockable
 ULLockable ()
 
 ULLockable (const ULLockable &lockable)
 
virtual ~ULLockable ()
 
const ULLockableoperator= (const ULLockable &lockable)
 
void clear ()
 
ULLockgetLock ()
 
void setLock (ULLock *newLock)
 

Additional Inherited Members

- Protected Attributes inherited from ULLockable
ULLocklock
 

Detailed Description

ULDictionaryDataSource is the abstract parent for classes that interface with dictionary data stored somewhere like a .uld file or a database.

Dictionary data sources also support a mapping between feature names and feature IDs that are native to the data source in question. For example, the terms and translations in an Ultralingua dataset might have features called "usage", "dialect", "tone", etc. corresponding to integer values stored in a .uld file or database, while Collins datasets might have some of the same features as Ultralingua plus some idiosyncratic ones like "biographicalinfo". getFeatureNameList enables the dictionary data source's associated ULForester object to map names to IDs as needed.

Warning: If you find yourself thinking about directly using one of the subclasses of this class, you should reconsider. It is much easier to use ULAPI's data sources correctly by working with a ULFactory and the associated higher-level tools such as ULConjugator or ULStemmer, which take care of the initialization and manipulation of the data sources for you.

Member Enumeration Documentation

anonymous enum
Enumerator:
HeadwordIndex 
OntologyIndex 
NCommonIndexIDs 

Member Function Documentation

virtual ULError ULDictionaryDataSource::attach ( const ULString dataSourceIdentifier)
pure virtual

Causes this ULDataSource object to be associated with the specified data source, and reads enough information from that data source to determine its language(s), etc.

The exact behavior of attach will be dependent on the nature of the data source. If the data source is a file, then attach will read header information from the file and then close the file to save memory until the data source is actually needed. On the other hand, if the data source is a remote database, then attach might open a connection, collect header information, and then close the connection.

Returns
ULError::NoError if the attachment is successful, or some other ULError value if not.
Parameters
[in]dataSourceIdentifierA string describing the data source (e.g. a file name, a database connection string, a URL, etc.).

Implements ULDataSource.

Implemented in ULJSONDictionaryDataSource.

virtual ULError ULDictionaryDataSource::begin ( const ULLanguage searchLanguage,
uluint32  indexID,
ULDictionaryIterator iterator 
)
pure 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.

Implemented in ULJSONDictionaryDataSource.

virtual ULError ULDictionaryDataSource::close ( )
pure virtual

Frees dynamically allocated memory associated with this data source while keeping it attached to the file, db, etc. to which it was previously attached. Also closes any relevant files, db connections, etc.

Returns
ULError::NoError if the memory freeing was successful.

Implements ULDataSource.

Implemented in ULJSONDictionaryDataSource.

virtual ULError ULDictionaryDataSource::detach ( )
pure virtual

Releases the connection between this ULDataSource object and the data source specified in the previous open() or attach() call, closing any relevant files or network connections and freeing memory in the process.

Returns
ULError::NoError if the attachment is successful, or some other ULError value if not.

Implements ULDataSource.

Implemented in ULJSONDictionaryDataSource.

virtual ULError ULDictionaryDataSource::end ( const ULLanguage searchLanguage,
uluint32  indexID,
ULDictionaryIterator iterator 
)
pure 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.

Implemented in ULJSONDictionaryDataSource.

virtual ULError ULDictionaryDataSource::find ( const ULString searchString,
const ULLanguage searchLanguage,
uluint32  indexID,
ULDictionaryIterator iterator 
)
pure 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.

Implemented in ULJSONDictionaryDataSource.

virtual ULString ULDictionaryDataSource::getDataSourceIdentifier ( )
pure virtual
Returns
the data source identifier for the data source attached to this ULDataSource object, or the empty string if no data source is attached.

Implements ULDataSource.

Implemented in ULJSONDictionaryDataSource.

virtual ULDictionaryDescriptor ULDictionaryDataSource::getDictionaryDescriptor ( )
pure virtual
Returns
a ULDictionaryDescriptor object describing the data source attached to this ULDictionaryDataSource.

Implemented in ULJSONDictionaryDataSource.

virtual ULError ULDictionaryDataSource::getFeatureNameList ( ULList< ULString > &  featureNameList)
pure virtual

Obtains the list of feature names stored in this data source. The feature names in this list are associated, in the data source itself, with integer IDs starting at 0 for the first string in featureNameList, and going up to featureNameList.length() - 1.

Returns
ULError::NoError if the list can be retrieved.
Parameters
[out]featureNameListthe list of feature names stored in this data source.

Implemented in ULJSONDictionaryDataSource.

virtual const ULLanguage& ULDictionaryDataSource::getFirstLanguage ( )
pure virtual
Returns
this data source's first language.

Implemented in ULJSONDictionaryDataSource.

virtual ULForester* ULDictionaryDataSource::getForester ( )
pure virtual
Returns
a pointer to the forester used by this data source.

Implemented in ULJSONDictionaryDataSource.

virtual ULForestType ULDictionaryDataSource::getForestType ( )
pure virtual
Returns
the forest type for this data source, which can be used (among other things) to decide which subclass of ULForester to assign to this data source.

Implemented in ULJSONDictionaryDataSource.

virtual ULError ULDictionaryDataSource::getLocalizationRuleList ( const ULLanguage language,
ULList< ULLocalizationRule > &  localizationRulesList 
)
pure virtual

Obtains the list of localization rules stored in this data source for the given language.

Returns
ULError::NoError if the list can be retrieved.
Parameters
[in]languageThe language for which to retrieve the rules.
[out]localizationRuleListThe list of localization rule stored in this data source for the given language

Implemented in ULJSONDictionaryDataSource.

virtual const ULLanguage& ULDictionaryDataSource::getOtherLanguage ( const ULLanguage language)
pure virtual
Returns
this data source's language that is not the parameter.

Implemented in ULJSONDictionaryDataSource.

virtual const ULLanguage& ULDictionaryDataSource::getSecondLanguage ( )
pure virtual
Returns
this data source's second language.

Implemented in ULJSONDictionaryDataSource.

virtual bool ULDictionaryDataSource::getULDAttribute ( const ULString key,
ULString value 
)
pure virtual

Retrieves the ULD attribute value associated with the given key if it exists for this ULD.

Returns
true if the uld has this attribute and false otherwise.
Parameters
[in]keyThe string that is the key for the attribute you want to retrieve.
[out]valueThe value of the attribute if it exists.

Implemented in ULJSONDictionaryDataSource.

virtual ULDataSourceVersion ULDictionaryDataSource::getVersion ( )
pure virtual
Returns
the ULDataSourceVersion associated with this data source.

Implements ULDataSource.

Implemented in ULJSONDictionaryDataSource.

virtual ULError ULDictionaryDataSource::load ( )
pure virtual

Perform one-time opening and loading operations. Normally, such operations are performed lazily, when the data source is first queried. If you would prefer to control the time at which loading is performed, call this method.

Returns
ULError::NoError if the loading was successful.

Implements ULDataSource.

Implemented in ULJSONDictionaryDataSource.

virtual bool ULDictionaryDataSource::operator== ( const ULDictionaryDataSource dataSource) const
pure virtual

Implemented in ULJSONDictionaryDataSource.

virtual void ULDictionaryDataSource::setForester ( ULForester *  newForester)
pure virtual

Assigns the forester to be used by this ULDictionaryDataSource. The data source takes responsibility for deleting the forester.

Parameters
[in]newForesterA pointer to the desired forester.

Implemented in ULJSONDictionaryDataSource.


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