@@ -31,36 +31,36 @@ public SynonymViewModel(WordViewModel parent, Synonym synonym)
3131 private static double GetPracticeState ( IReadOnlyCollection < Practice > practices )
3232 {
3333 // Zipf's law weighted average for the last 5 practices
34- int lastN = 5 ;
34+ int maxPracticesToConsider = 5 ;
3535
36- double values = 0.0 , weights = 0.0 ;
37- int counter = 1 ;
36+ double weightedSum = 0.0 , sumOfWeights = 0.0 ;
37+ int practicePosition = 1 ;
3838
39- foreach ( Practice practice in practices . Reverse ( ) . Take ( lastN ) )
39+ foreach ( Practice practice in practices . Reverse ( ) . Take ( maxPracticesToConsider ) )
4040 {
41- double weight = 1.0 / counter ;
41+ double weight = 1.0 / practicePosition ;
4242 double result = practice . Result switch
4343 {
4444 PracticeResult2 . Correct => 1.0 ,
4545 PracticeResult2 . PartlyCorrect => 0.5 ,
4646 PracticeResult2 . Wrong => 0.0 ,
4747 _ => throw new ArgumentOutOfRangeException ( null , practice . Result , "Invalid practice result" )
4848 } ;
49- values += result * weight ;
50- weights += weight ;
51- counter ++ ;
49+ weightedSum += result * weight ;
50+ sumOfWeights += weight ;
51+ practicePosition ++ ;
5252 }
5353
54- if ( counter == 1 )
54+ if ( practicePosition == 1 )
5555 return - 1.0 ; // No practices
5656
57- for ( ; counter <= lastN ; counter ++ )
57+ for ( ; practicePosition <= maxPracticesToConsider ; practicePosition ++ )
5858 {
5959 // Assume 0.0 for missing practices
60- weights += 1.0 / counter ;
60+ sumOfWeights += 1.0 / practicePosition ;
6161 }
6262
63- return values / weights ;
63+ return weightedSum / sumOfWeights ;
6464 }
6565
6666 public void Dispose ( )
0 commit comments