Add A-factor to E-factor conversion to SuperMemo import.
The SuperMemo XML importer assumed that the A-factors used by SuperMemo map 1-1 with E-factors (which correspond to Ease in Anki). This resulted in too large E-factors for imported items. This change adds an A-factor to E-factor conversion to the importer.
This commit is contained in:
parent
cdcd5eb651
commit
656698da83
@ -142,6 +142,28 @@ class SupermemoXmlImporter(NoteImporter):
|
||||
|
||||
return unicode(btflsoup(s, selfClosingTags=['br','hr','img','wbr'], convertEntities=btflsoup.HTML_ENTITIES))
|
||||
|
||||
def _afactor2efactor(self, af):
|
||||
# Adapted from <http://www.supermemo.com/beta/xml/xml-core.htm>
|
||||
|
||||
# Ranges for A-factors and E-factors
|
||||
af_min = 1.2
|
||||
af_max = 6.9
|
||||
ef_min = 1.3
|
||||
ef_max = 3.3
|
||||
|
||||
# Sanity checks for the A-factor
|
||||
if af < af_min:
|
||||
af = af_min
|
||||
elif af > af_max:
|
||||
af = af_max
|
||||
|
||||
# Scale af to the range 0..1
|
||||
af_scaled = (af - af_min) / (af_max - af_min)
|
||||
# Rescale to the interval ef_min..ef_max
|
||||
ef = ef_min + af_scaled * (ef_max - ef_min)
|
||||
|
||||
return ef
|
||||
|
||||
## DEFAULT IMPORTER METHODS
|
||||
|
||||
def foreignNotes(self):
|
||||
@ -191,7 +213,7 @@ class SupermemoXmlImporter(NoteImporter):
|
||||
nextDue = tLastrep + (float(item.Interval) * 86400.0)
|
||||
remDays = int((nextDue - time.time())/86400)
|
||||
card.due = self.col.sched.today+remDays
|
||||
card.factor = int(float(item.AFactor.replace(',','.'))*1000)
|
||||
card.factor = int(self._afactor2efactor(float(item.AFactor.replace(',','.')))*1000)
|
||||
note.cards[0] = card
|
||||
|
||||
# categories & tags
|
||||
|
Loading…
Reference in New Issue
Block a user