
    (j                    X    d Z ddlmZ ddlmZ  G d de          Z G d d          ZdS )	u   记忆重要度打分:决定一条记忆在检索中的基础权重。

v0 用确定性启发式(关键词 + 长度);LLM 版打分在 L2 接入 DeepSeek 后替换
(同一个 Protocol,注入即可换,见 PRD §12 TODO)。
    )annotations)Protocolc                      e Zd ZddZdS )ImportanceScorercontentstrreturnfloatc                    d S N )selfr   s     4/root/genesis-world/src/genesis/memory/importance.pyscorezImportanceScorer.score   s        Nr   r   r	   r
   )__name__
__module____qualname__r   r   r   r   r   r      s(             r   r   c                      e Zd ZdZdZd	dZdS )
HeuristicImportanceScoreru^   无 LLM 的确定性打分:含人生里程碑/强情绪关键词或较长的事件更重要。)u   死u   出生u   结婚u   离婚u   吵架u   爱u   恨u   升职u   失业u   搬家u   背叛diedeaddeathbornbirthlovehatefightmarridivorcpromotfiredbetrayr   r   r	   r
   c                ,   |                                 }|sdS d}|                                t          fd| j        D                       r|dz  }|t	          dt          |          dz            z  }t          dt	          d|                    S )Ng        g?c              3      K   | ]}|v V  	d S r   r   ).0klowereds     r   	<genexpr>z2HeuristicImportanceScorer.score.<locals>.<genexpr>!   s'      33qG|333333r   g      ?g333333?g      i@g      ?)striplowerany_SALIENTminlenmax)r   r   textbaser)   s       @r   r   zHeuristicImportanceScorer.score   s    }} 	3**,,3333T]33333 	CKDCTU*+++3C'''r   Nr   )r   r   r   __doc__r.   r   r   r   r   r   r      s5        hhH	( 	( 	( 	( 	( 	(r   r   N)r4   
__future__r   typingr   r   r   r   r   r   <module>r7      s     # " " " " "          x   
( ( ( ( ( ( ( ( ( (r   