コード例 #1
0
 /// <summary>
 /// Gets the score for an alternate using the specified scoring method.
 /// </summary>
 /// <param name="alternate">The alternate.</param>
 /// <param name="index">The index (rank) of the alternate.</param>
 /// <param name="useRank">A value indicating that the rank should be used to score the alternates.</param>
 /// <returns>The score of the alternate.</returns>
 private static double GetScore(ISpeechRecognitionAlternate alternate, int index, bool useRank)
 {
     return(useRank ? (1.0 / (index + 1)) : (alternate.Confidence ?? 0));
 }
コード例 #2
0
 /// <summary>
 /// Composes two scored alternates.
 /// </summary>
 /// <param name="alternate1">The first alternate.</param>
 /// <param name="score1">The score of the first alternate.</param>
 /// <param name="alternate2">The second alternate.</param>
 /// <param name="score2">The score of the second alternate.</param>
 /// <returns>The composed alternate and combined score.</returns>
 private static (SpeechRecognitionAlternate, double) Compose(ISpeechRecognitionAlternate alternate1, double score1, ISpeechRecognitionAlternate alternate2, double score2)
 {
     return(new SpeechRecognitionAlternate(Compose(alternate1.Text, alternate2.Text), Combine(alternate1.Confidence, alternate2.Confidence)), Combine(score1, score2));
 }