업데이트: 2007년 11월
RecognitionResult 개체의 최적 결과 문자열에서 RecognitionAlternates 컬렉션을 반환합니다. 이 컬렉션의 각 RecognitionAlternate 개체는 잉크 세그먼트 하나에만 해당합니다. 반환된 컬렉션의 요소 개수는 10개로 제한됩니다.
네임스페이스: Microsoft.Ink
어셈블리: Microsoft.Ink(Microsoft.Ink.dll)
구문
‘선언
Public Function GetAlternatesFromSelection As RecognitionAlternates
‘사용 방법
Dim instance As RecognitionResult
Dim returnValue As RecognitionAlternates
returnValue = instance.GetAlternatesFromSelection()
public RecognitionAlternates GetAlternatesFromSelection()
public:
RecognitionAlternates^ GetAlternatesFromSelection()
public RecognitionAlternates GetAlternatesFromSelection()
public function GetAlternatesFromSelection() : RecognitionAlternates
반환 값
형식: Microsoft.Ink.RecognitionAlternates
RecognitionResult 개체의 최적 결과 문자열 내에 있는 선택 영역에서 RecognitionAlternates 컬렉션을 반환합니다. 이 컬렉션의 각 RecognitionAlternate 개체는 잉크 세그먼트 하나에만 해당합니다.
설명
인식기는 세그먼트 사이의 간격에 따라 "how are you"를 각 단어에 하나씩 세그먼트 세 개로 분할합니다. GetAlternatesFromSelection 메서드를 호출하여 이 선택 영역의 세그먼트 하나에 대한 대체 항목을 반환합니다.
GetAlternatesFromSelection 메서드와 RecognitionAlternate의 AlternatesWithConstantPropertyValues, LineAlternates 및 ConfidenceAlternates 메서드 사이에는 차이점이 있습니다. GetAlternatesFromSelection 메서드는 각 RecognitionAlternate 개체가 선택 영역 내에서 잉크의 세그먼트 하나에만 해당하는 RecognitionAlternates 컬렉션을 반환하지만 AlternatesWithConstantPropertyValues, LineAlternates 및 ConfidenceAlternates 메서드는 RecognitionAlternate 개체가 선택 영역 내에서 잉크의 각 세그먼트에 해당하는 RecognitionAlternates 컬렉션을 반환합니다.
예제
이 예제에서는 메뉴 항목이나 단추를 클릭하는 등의 사용자 동작에 응답하여 동기적 인식을 처리합니다. 우선 InkOverlay 개체에 연결된 Strokes 컬렉션을 사용하여 RecognizerContext 개체의 Strokes 컬렉션을 할당하고 스트로크 개수를 확인합니다. Strokes 컬렉션에 Stroke 개체가 최소한 하나 이상 들어 있으면 Recognize 메서드를 호출하여 인식 프로세스를 시작합니다. 인식에 성공하면 인식 결과의 첫 번째 단어(TopString 속성에서 단어를 둘 이상 찾은 경우) 또는 전체 인식 결과에 대한 RecognitionAlternates 컬렉션을 가져옵니다. 마지막으로 RecognitionAlternates를 목록 상자에 추가하여 표시합니다.
' assign strokes collection from the collected strokes
Me.mRecognizerContext.Strokes = Me.mInkOverlay.Ink.Strokes
' check stroke count. Recognize() will throw exception if no strokes
If Me.mRecognizerContext.Strokes.Count > 0 Then
Dim status As RecognitionStatus
' perform the recognition
Dim rResult As RecognitionResult = Me.mRecognizerContext.Recognize(status)
' check status
If RecognitionStatus.NoError = status Then
Dim rAlts As RecognitionAlternates
' find the index of the first space in the top string
Dim idxOfSpace As Integer = rResult.TopString.IndexOf(" ")
If idxOfSpace <> -1 Then
' if we have a space (i.e. more than one word)
' get the alternates of the first segment (the first word)
rAlts = rResult.GetAlternatesFromSelection(0, idxOfSpace)
Else
' otherwise, get the alternates for the entire recognition result
rAlts = rResult.GetAlternatesFromSelection()
' Note: if (idxOfSpace <> -1) .. for illustrative purposes
' Could have uncondionally used:
' rAlts = rResult.GetAlternatesFromSelection(0, idxOfSpace)
' because:
' GetAlternatesFromSelection(0, -1)
' is the same as:
' GetAlternatesFromSelection()
End If
' display the alternates
For Each RA As RecognitionAlternate In rAlts
listBoxRecognitionResults.Items.Add(RA.ToString())
Next
End If
End If
// assign strokes collection from the collected strokes
this.mRecognizerContext.Strokes = this.mInkOverlay.Ink.Strokes;
// check stroke count. Recognize() will throw exception if no strokes
if (this.mRecognizerContext.Strokes.Count > 0)
{
RecognitionStatus status;
// perform the recognition
RecognitionResult rResult = this.mRecognizerContext.Recognize(out status);
// check status
if (RecognitionStatus.NoError == status)
{
RecognitionAlternates rAlts;
// find the index of the first space in the top string
int idxOfSpace = rResult.TopString.IndexOf(" ");
if (idxOfSpace != -1)
{
// if we have a space (i.e. more than one word)
// get the alternates of the first segment (the first word)
rAlts = rResult.GetAlternatesFromSelection(0, idxOfSpace);
}
else
{
// otherwise, get the alternates for the entire recognition result
rAlts = rResult.GetAlternatesFromSelection();
// Note: if (idxOfSpace != -1) .. for illustrative purposes
// Could have uncondionally used:
// rAlts = rResult.GetAlternatesFromSelection(0, idxOfSpace);
// because:
// GetAlternatesFromSelection(0, -1)
// is the same as:
// GetAlternatesFromSelection()
}
// display the alternates
foreach (RecognitionAlternate RA in rAlts)
{
listBoxRecognitionResults.Items.Add(RA.ToString());
}
}
}
플랫폼
Windows Vista
.NET Framework 및 .NET Compact Framework에서 모든 플랫폼의 전체 버전을 지원하지는 않습니다. 지원되는 버전의 목록을 보려면 .NET Framework 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Framework
3.0에서 지원