更新 providers
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import heurams.services.timer as timer
|
||||
from heurams.context import config_var
|
||||
from heurams.kernel.algorithms import get_algorithm
|
||||
from heurams.kernel.algorithms import algorithms
|
||||
|
||||
class Electron:
|
||||
"""电子: 记忆分析元数据及算法"""
|
||||
|
||||
def __init__(self, ident: str, algodata: dict = {}, algo: str = "supermemo2"):
|
||||
def __init__(self, ident: str, algodata: dict = {}, algo_name: str = "supermemo2"):
|
||||
"""初始化电子对象 (记忆数据)
|
||||
|
||||
Args:
|
||||
@@ -15,14 +15,12 @@ class Electron:
|
||||
"""
|
||||
self.algodata = algodata
|
||||
self.ident = ident
|
||||
self.algo = algo
|
||||
|
||||
algorithm_config = get_algorithm(self.algo)
|
||||
self.algo = algorithms[algo_name]
|
||||
|
||||
if self.algo not in self.algodata.keys():
|
||||
self.algodata[self.algo] = {}
|
||||
if not self.algodata[self.algo]:
|
||||
self._default_init(algorithm_config['defaults'])
|
||||
self._default_init(self.algo.defaults)
|
||||
|
||||
def _default_init(self, defaults: dict):
|
||||
"""默认初始化包装"""
|
||||
@@ -41,6 +39,11 @@ class Electron:
|
||||
else:
|
||||
print(f"警告: '{var}' 非已知元数据字段")
|
||||
|
||||
def is_due(self):
|
||||
"""是否应该复习
|
||||
"""
|
||||
return self.algo.is_due(self.algodata)
|
||||
|
||||
def revisor(self, quality: int = 5, is_new_activation: bool = False):
|
||||
"""算法迭代决策机制实现
|
||||
|
||||
@@ -48,8 +51,7 @@ class Electron:
|
||||
quality (int): 记忆保留率量化参数 (0-5)
|
||||
is_new_activation (bool): 是否为初次激活
|
||||
"""
|
||||
algorithm_config = get_algorithm(self.algo)
|
||||
algorithm_config['revisor'](self.algodata, quality, is_new_activation)
|
||||
self.algo.revisor(self.algodata, quality, is_new_activation)
|
||||
|
||||
def __str__(self):
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user