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.
- TRuleBasedTransliterator ()
- TRuleBasedTransliterator (const TRuleBasedTransliterator & tran)
- TRuleBasedTransliterator (const TLocalizableName& name)
Interface Category:
API.
Purpose:
- Default constructor.
- Copy constructor.
- 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.
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.
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.
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.
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.
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.
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:
- TransliterateVariable variableName -Variable name.
- const TText & variableValue -Variable values.
- bool inverse =false -If inverse is true, then the reverse of the variable value would be matched. For example, if a variable has the value of a-z (alphabetic characters), than its inverse value would be everything outside that range, or non-alphabetic characters.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
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:
- TransliterateVariable ch -The UniChar to query.
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.
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.
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.
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.
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:
- TStream & fromWhere -The stream the object streams itself in from.
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.
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:
- TStream & toWhere -The stream the object streams itself out to.
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.
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:
- const TText & currentText -Current text which includes new input text.
- const TTextRange & newTextRange -The range of newly input text.
- TTextRange & rangeToTranslate -Result range.
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
This function is protected.
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.
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.
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:
- TText & sourceText -The text to translate back.
- const TTextRange & sourceRange -The range of text to translate back.
- TTextRange & replacementRange -The range of text replaced by the translation.
- TTextCount & numNewChars -The number of new characters introduced by the translation operation.
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.
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:
- TText & sourceText -The text to translate.
- const TTextRange & sourceRange -The range of text to translate.
- TTextRange & replacementRange -The range of text replaced by the translation.
- TTextCount & numNewChars -The number of new characters introduced by the translation operation.
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.