Class: TRuleBasedTransliterator

Declaration: Transliterate.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

TTransliterator

Inherited By:

None.

Purpose:

TRuleBasedTransliterator, derived from TTransliterator, is a concrete class intended to be instantiated and used directly. It uses a set of context-sensitive rules to transform text, and a parallel set to reverse this action. These rules are designed such that a knowledgeable non-programmer can edit them for localization. Roman rule-based transliteration is available for Japanese (kana), Hebrew, Arabic, Greek, Russian, and Devanagari.

Instantiation:

TRuleBaseTransliterators can be large objects. If storage is a concern, the client should instantiate a TTransliteratorHandle instead.

Deriving Classes:

TRuleBasedTransliterator is a concrete class designed to be used directly. It can be derived to add functionality. There are no special requirements for deriving.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Member Function: TRuleBasedTransliterator::TRuleBasedTransliterator

  1. TRuleBasedTransliterator ()
  2. TRuleBasedTransliterator (const TRuleBasedTransliterator & tran)
  3. TRuleBasedTransliterator (const TLocalizableName& name)

Interface Category:

API.

Purpose:

  1. Default constructor.
  2. Copy constructor.
  3. Constructs a transliterator with a particular name. Finds a transliterator with this name. If not found, constructs an empty one with the argument as its name.

Calling Context:

This function is designed to be called directly and has no special requirements.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TRuleBasedTransliterator::~TRuleBasedTransliterator

virtual ~ TRuleBasedTransliterator ()

Interface Category:

API.

Purpose:

Destructor.

Calling Context:

This function is designed to be called directly and has no special requirements.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TRuleBasedTransliterator::GetMaxExpandFactor

virtual TTextCount GetMaxExpandFactor () const

Interface Category:

API.

Purpose:

Returns the maximum expansion possible for this transliterator when doing forward translation. For example, if any single character can turn into four characters, the expansion factor is 4.

Calling Context:

This function is designed to be called directly and has no special requirements.

Parameters:

Return Value:

The expansion factor.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Overrides inherited TTransliterator function. The maximum expansion cannot exceed 256 characters.

Member Function: TRuleBasedTransliterator::GetMaxBackExpandFactor

virtual TTextCount GetMaxBackExpandFactor () const

Interface Category:

API.

Purpose:

Return the maximum expansion possible for this transliterator when doing backward translation. For example, if any single character can turn into four characters, the expansion factor is 4.

Calling Context:

This function is designed to be called directly and has no special requirements.

Parameters:

Return Value:

The expansion factor.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

Overrides inherited TTransliterator function. The maximum expansion cannot exceed 256 characters.

Member Function: TRuleBasedTransliterator::AdoptTranslationRule

virtual void AdoptTranslationRule (TTransliterateRule * rule)

Interface Category:

API.

Purpose:

Adds a rule for forward translation to this object. Takes over the storage for the rule.

Calling Context:

This function is designed to be called directly and has no special requirements.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

If an identical rule already exists, the argument is not added and it is deleted. Duplicate rules are not allowed.

Member Function: TRuleBasedTransliterator::AdoptTranslationBackRule

virtual void AdoptTranslationBackRule (TTransliterateRule * rule)

Interface Category:

API.

Purpose:

Adds a rule for backward translation to this object. Takes over the storage for the rule.

Calling Context:

This function is designed to be called directly and has no special requirements.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

If an identical rule already exists, the argument is not added and it is deleted. Duplicate rules are not allowed.

Member Function: TRuleBasedTransliterator::AddVariable

virtual void AddVariable (TransliterateVariable variableName, const TText & variableValue, bool inverse =false)

Interface Category:

API.

Purpose:

Add a rule variable to this object. A rule variable denotes a range or set of characters. It can be used in the rules to match multiple characters. For example, you might create a variable that includes all vowels: v =aeiou. A rule variable name is a single UniChar.

Calling Context:

This function is designed to be called directly and has no special requirements.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TRuleBasedTransliterator::IsVariable

virtual bool IsVariable (TransliterateVariable ch) const

Interface Category:

API.

Purpose:

Checks to see if a particular unicode character represents a variable.

Calling Context:

This function is designed to be called directly and has no special requirements.

Parameters:

Return Value:

Returns true if the character represents a variable.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TRuleBasedTransliterator::CreateIterator

virtual TTransliterateRulesIterator * CreateIterator () const

Interface Category:

API.

Purpose:

Creates a TTransliterateRulesIterator object to iterate over the forward rules.

Calling Context:

This function is designed to be called directly and has no special requirements.

Parameters:

Return Value:

A TTransliterateRulesIterator object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TRuleBasedTransliterator::CreateTranslateBackIterator

virtual TTransliterateRulesIterator * CreateTranslateBackIterator () const

Interface Category:

API.

Purpose:

Creates a TTransliterateRulesIterator object to iterate over the backward rules.

Calling Context:

This function is designed to be called directly and has no special requirements.

Parameters:

Return Value:

A TTransliterateRulesIterator object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TRuleBasedTransliterator::operator=

TRuleBasedTransliterator & operator =(const TRuleBasedTransliterator & rule)

Interface Category:

API.

Purpose:

Assignment operator.

Calling Context:

This function is designed to be called directly and has no special requirements.

Parameters:

Return Value:

A non-const reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TRuleBasedTransliterator::operator<<=

virtual TStream & operator <<= (TStream & fromWhere)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

This function is designed to be called directly and has no special requirements.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself in from.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TRuleBasedTransliterator::operator>>=

virtual TStream & operator >>=(TStream & toWhere) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

This function is designed to be called directly and has no special requirements.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself out to.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TRuleBasedTransliterator::GetTranslateRange

virtual void GetTranslateRange (const TText & currentText, const TTextRange & newTextRange, TTextRange & rangeToTranslate) const

Interface Category:

API.

Purpose:

Given the current text, this function determines how much preceding/succeeding context is needed and returns the range that can be passed into the Translate functions as sourceRange.

Calling Context:

This function is called internally by TranslateInline.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This function is protected.

Member Function: TRuleBasedTransliterator::GetMaxPreceed

virtual TTextCount GetMaxPreceed () const

Interface Category:

API.

Purpose:

The maximum number of characters before the current offset that needs to be considered for correct forward translation.

Calling Context:

This function is called by GetTranslateRange.

Parameters:

Return Value:

Maximum number of preceding characters.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This function is protected.

Member Function: TRuleBasedTransliterator::GetMaxSucceed

virtual TTextCount GetMaxSucceed () const

Interface Category:

API.

Purpose:

The maximum number of characters after the current offset that needs to be considered for correct forward translation.

Calling Context:

This function is called by GetTranslateRange.

Parameters:

Return Value:

Maximum number of preceding characters.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This function is protected.

Member Function: TRuleBasedTransliterator::DoTranslateBack

virtual bool DoTranslateBack (TText & sourceText, const TTextRange & sourceRange, TTextRange & replacementRange, TTextCount & numNewChars) const

Interface Category:

API.

Purpose:

Performs the actual translate back operation.

Calling Context:

Called by the public translate back functions.

Parameters:

Return Value:

Returns true if text is translated back.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This function is protected.

Member Function: TRuleBasedTransliterator::DoTranslate

virtual bool DoTranslate (TText & sourceText, const TTextRange & sourceRange, TTextRange & replacementRange, TTextCount & numNewChars) const

Interface Category:

API.

Purpose:

Performs the actual translate operation.

Calling Context:

Called by the public translate functions.

Parameters:

Return Value:

Returns true if text is translated.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

This function is protected.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.