RecognitionResult オブジェクトの最適な結果文字列内の範囲から RecognitionAlternates コレクションを返します。コレクション内の RecognitionAlternate オブジェクトはそれぞれ、インクの 1 つのセグメントのみに対応します。返されるコレクションは、指定したサイズに制限されます。
名前空間 : Microsoft.Ink
アセンブリ : Microsoft.Ink (Microsoft.Ink.dll 内)
構文
'宣言
Public Function GetAlternatesFromSelection ( _
selectionStart As Integer, _
selectionLength As Integer, _
maximumAlternates As Integer _
) As RecognitionAlternates
'使用
Dim instance As RecognitionResult
Dim selectionStart As Integer
Dim selectionLength As Integer
Dim maximumAlternates As Integer
Dim returnValue As RecognitionAlternates
returnValue = instance.GetAlternatesFromSelection(selectionStart, _
selectionLength, maximumAlternates)
public RecognitionAlternates GetAlternatesFromSelection(
int selectionStart,
int selectionLength,
int maximumAlternates
)
public:
RecognitionAlternates^ GetAlternatesFromSelection(
int selectionStart,
int selectionLength,
int maximumAlternates
)
public RecognitionAlternates GetAlternatesFromSelection(
int selectionStart,
int selectionLength,
int maximumAlternates
)
public function GetAlternatesFromSelection(
selectionStart : int,
selectionLength : int,
maximumAlternates : int
) : RecognitionAlternates
パラメータ
- selectionStart
型 : System.Int32
テキスト選択範囲のうち、RecognitionAlternates コレクションとして返す部分の開始位置。既定値は 0 です。
- selectionLength
型 : System.Int32
テキスト選択範囲のうち、RecognitionAlternates コレクションとして返す部分の長さ。既定値は –1 です。この値は、選択範囲の開始位置から文字列の末尾までのテキストを示します。
- maximumAlternates
型 : System.Int32
返される代替候補の最大数。既定値は 10 です。難易度や時間の長さが理由で、認識エンジンが代替候補の数を計算できない場合は、返される代替候補の数は不定です。
戻り値
型 : Microsoft.Ink.RecognitionAlternates
RecognitionResult オブジェクトの最適な結果文字列内の選択範囲から RecognitionAlternates コレクションを返します。コレクション内の RecognitionAlternate オブジェクトはそれぞれ、インクの 1 つのセグメントのみに対応します。
解説
![]() |
---|
範囲が大きい場合や、一部の言語では、代替候補の数が非常に多くなります。アプリケーションでは、認識エンジンが返すことのできる代替候補の最大数を照会するのではなく、代替候補の数を指定するようにしてください。 |
認識エンジンは、多くの場合 "how are you" をセグメント間の空きに従って 3 つのセグメントに分割します。つまり、1 単語につき 1 セグメントです。この選択範囲の 1 つのセグメントだけについて代替候補を返すには、GetAlternatesFromSelection メソッドを呼び出します。
GetAlternatesFromSelection メソッドと、RecognitionAlternate オブジェクトの AlternatesWithConstantPropertyValues メソッド、LineAlternates メソッド、および ConfidenceAlternates メソッドの間の相違点に注意してください。GetAlternatesFromSelection メソッドから返される RecognitionAlternates コレクションでは、各 RecognitionAlternate オブジェクトは選択範囲内のインクの 1 つのセグメントだけに対応しますが、AlternatesWithConstantPropertyValues メソッド、LineAlternates メソッド、および ConfidenceAlternates メソッドから返される、RecognitionAlternates コレクションには、選択範囲内のインクの各セグメントに対応する RecognitionAlternate オブジェクトが含まれています。
例
この C# の例では、TextBox コントロール theTextBox 内でユーザーが選択した内容に対応する RecognitionAlternate オブジェクトを、最大 5 つ返します。このコントロールには、RecognitionResult オブジェクトから生成された最上位の結果が既に挿入されています。代替候補は、GetAlternatesFromSelection メソッドを使用して RecognitionAlternates コレクション theRecognitionAlternates に格納します。これは、認識されたテキストをユーザーが選択して、そのテキストに対応する代替候補の一覧を参照し、修正を挿入できるようにする場合に役立つ方法です。
[C#]
using Microsoft.Ink;
// . . .
try
{
if (theTextBox.SelectionLength != 0)
{
RecognitionAlternates theRecognitionAlternates =
theRecognitionResult.GetAlternatesFromSelection(
theTextBox.SelectionStart, theTextBox.SelectionLength, 5);
// Do something with theRecognitionAlternates here.
}
}
catch
{
// handle exceptions here.
}
この Microsoft® Visual Basic® .NET の例では、TextBox コントロール theTextBox 内でユーザーが選択した内容に対応するRecognitionAlternate オブジェクトを、最大 5 つ返します。このコントロールには、RecognitionResult オブジェクトから生成された最上位の結果が既に挿入されています。代替候補は、GetAlternatesFromSelection メソッドを使用してRecognitionAlternates コレクション theRecognitionAlternates に格納します。これは、認識されたテキストをユーザーが選択して、そのテキストに対応する代替候補の一覧を参照し、修正を挿入できるようにする場合に役立つ方法です。
[Visual Basic]
Imports Microsoft.Ink
' . . .
Try
If theTextBox.SelectionLength != 0 Then
Dim theRecognitionAlternates As RecognitionAlternates
theRecognitionAlternates = _
theRecognitionResult.GetAlternatesFromSelection( _
theTextBox.SelectionStart, _
theTextBox.SelectionLength, 5)
'Do something with theRecognitionAlternates here.
End If
Catch
'Handle exceptions here.
End Try
プラットフォーム
Windows Vista
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 3.0