RecognitionResult.ModifyTopAlternate Method
Modifies the RecognitionResult object with a known RecognitionAlternate object.
Namespace: Microsoft.Ink
Assembly: Microsoft.Ink (in microsoft.ink.dll)
Syntax
'Declaration
Public Sub ModifyTopAlternate ( _
alternate As RecognitionAlternate _
)
'Usage
Dim instance As RecognitionResult
Dim alternate As RecognitionAlternate
instance.ModifyTopAlternate(alternate)
public void ModifyTopAlternate (
RecognitionAlternate alternate
)
public:
void ModifyTopAlternate (
RecognitionAlternate^ alternate
)
public void ModifyTopAlternate (
RecognitionAlternate alternate
)
public function ModifyTopAlternate (
alternate : RecognitionAlternate
)
Not applicable.
Parameters
- alternate
The RecognitionAlternate object to use to modify the RecognitionResult object.
Remarks
By default, the TopString property of the RecognitionResult object corresponds to the TopAlternate property; however, you can use this method to use alternates other than the top alternate in the result. When you choose an alternate other than the top alternate, you are essentially choosing a different path through the lattice of alternates that are associated with the results.
To retrieve the RecognitionAlternate objects that can be used to modify the RecognitionResult object, call the GetAlternatesFromSelection method.
The alternate used in this method can be a word alternate within an entire sentence. For example, calling the ModifyTopAlternate method on an alternate obtained by calling GetAlternatesFromSelection(0,5) for "Hello World" changes "Hello" and leaves "World" unaltered.
Note
A call to the ModifyTopAlternate method may modify the TopString and TopAlternate properties of the RecognitionResult object.
Example
This C# example tracks the RecognitionResult object and its RecognitionAlternate objects. The example then saves the RecognitionResult objects with the Stroke objects that are recognized by using the SetResultOnStrokes method. Finally, the example modifies the TopAlternate property of the RecognitionResult object based on user input.
[C#]
// Declarations...
InkCollector theInkCollector;
Strokes theStrokes;
RecognizerContext theRecognizerContext;
RecognitionResult theRecognitionResult;
// Initialization...
// Initialize the recognizer's strokes
// and assign them to the context.
theStrokes = theInkCollector.Ink.Strokes;
theRecognizerContext = new RecognizerContext();
theRecognizerContext.Strokes = theStrokes;
// Install event handlers.
theRecognizerContext.RecognitionWithAlternates +=
new RecognizerContextRecognitionWithAlternatesEventHandler(
RecognitionWithAlternates_Event);
//...
// Recognition Event Handler
private void RecognitionWithAlternates_Event(
object sender,
RecognizerContextRecognitionWithAlternatesEventArgs e)
{
// Save the RecognitionResult, and copy it to the strokes
theRecognitionResult = e.Result;
theRecognitionResult.SetResultOnStrokes();
}
// Modify the TopAlternate of the result
private void buttonAlt2_Click(object sender, System.EventArgs e)
{
RecognitionAlternates theRecognitionAlternates =
theRecognitionResult.GetAlternatesFromSelection(0, -1);
theRecognitionResult.ModifyTopAlternate(theRecognitionAlternates[2]);
}
This Microsoft® Visual Basic® .NET example tracks the RecognitionResult object and its RecognitionAlternate objects. The example then saves the RecognitionResult objects with the Stroke objects that are recognized by using the SetResultOnStrokes method. Finally, the example modifies the TopAlternate property of the RecognitionResult object based on user input.
[Visual Basic]
'Declarations...
Dim theInkCollector As InkCollector
Dim theStrokes As Strokes
Dim theRecognizerContext As RecognizerContext
Dim theRecognitionResult As RecognitionResult
'Initialization...
'Initialize the recognizer's strokes
'and assign them to the context.
theStrokes = theInkCollector.Ink.Strokes
theRecognizerContext = new RecognizerContext()
theRecognizerContext.Strokes = theStrokes
'Install event handlers.
AddHandler theRecognizerContext.RecognitionWithAlternates, _
AddressOf RecognitionWithAlternates_Event
'...
'Recognition Event Handler
Private Sub RecognitionWithAlternates_Event( _
ByVal sender As Object, _
ByVal e As RecognizerContextRecognitionWithAlternatesEventArgs)
'Save the RecognitionResult, and copy it to the strokes.
theRecognitionResult = e.Result
theRecognitionResult.SetResultOnStrokes()
End Sub
'Modify the TopAlternate of the result
Private Sub ButtonAlt2_Click(object sender, System.EventArgs e) _
Handles ButtonAlt2.Click
RecognitionAlternates theRecognitionAlternates =
theRecognitionResult.GetAlternatesFromSelection(0, -1)
theRecognitionResult.ModifyTopAlternate(theRecognitionAlternates(2))
End Sub
Platforms
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.
Version Information
.NET Framework
Supported in: 3.0
See Also
Reference
RecognitionResult Class
RecognitionResult Members
Microsoft.Ink Namespace
RecognitionAlternate
Microsoft.Ink.RecognitionResult.GetAlternatesFromSelection
RecognitionResult.TopAlternate
RecognitionResult.TopString