コード例 #1
0
        private double CalculateHardInterval(CardHistoryEntry lastHistoryEntry, CardHistoryEntry currentHistoryEntry, double lastInterval)
        {
            double reviewDelay = CalculateReviewDelay(lastHistoryEntry.EntryTime.TimeOfDay, currentHistoryEntry.EntryTime.TimeOfDay, lastInterval);

            return(Math.Max(lastInterval + 1,
                            ((lastInterval + (reviewDelay / 4.0)) * 1.2 * intervalModifier)));
        }
コード例 #2
0
        private double CalculateEasyInterval(CardHistoryEntry lastHistoryEntry, CardHistoryEntry currentHistoryEntry, double lastInterval, double understandingFactor)
        {
            double reviewDelay = CalculateReviewDelay(lastHistoryEntry.EntryTime.TimeOfDay, currentHistoryEntry.EntryTime.TimeOfDay, lastInterval);

            return(Math.Max(CalculateNormalInterval(lastHistoryEntry, currentHistoryEntry, lastInterval, understandingFactor) + 1,
                            ((lastInterval + reviewDelay) * (understandingFactor / 1000.0) * intervalModifier * easyIntervalModifier)));
        }
コード例 #3
0
        private AnkiCardIntervalData CalculateCardIntervalData(Card c)
        {
            IEnumerable <CardHistoryEntry> history = c.HistoryEntries;

            history = history.OrderBy(x => x.EntryTime);
            double           uf               = 0;
            double           interval         = 0;
            CardHistoryEntry lastHistoryEntry = null;

            foreach (CardHistoryEntry historyEntry in history)
            {
                if (lastHistoryEntry == null)
                {
                    interval         = newInterval;
                    lastHistoryEntry = historyEntry;
                }

                switch (historyEntry.TrialPerformance)
                {
                case TrialPerformance.Fail:
                    uf       = CalculateFailFactor(uf);
                    interval = interval * newInterval;
                    break;

                case TrialPerformance.Easy:
                    uf       = CalculateEasyFactor(uf);
                    interval = CalculateEasyInterval(lastHistoryEntry, historyEntry, interval, uf);
                    break;

                case TrialPerformance.Normal:
                    uf       = CalculateNormalFactor(uf);
                    interval = CalculateNormalInterval(lastHistoryEntry, historyEntry, interval, uf);
                    break;

                case TrialPerformance.Hard:
                    uf       = CalculateHardFactor(uf);
                    interval = CalculateHardInterval(lastHistoryEntry, historyEntry, interval);
                    break;

                default:
                    throw new InvalidDataBaseOperationException(String.Format("Unsupported TrialPerformance value in card history: {0}", historyEntry.TrialPerformance));
                }

                lastHistoryEntry = historyEntry;
            }

            var cardIntervalData = new AnkiCardIntervalData()
            {
                lastReview          = lastHistoryEntry?.EntryTime,
                card                = c,
                interval            = interval,
                understandingFactor = uf
            };

            return(cardIntervalData);
        }