MCPcopy Create free account
hub / github.com/Enfoirer/Text2GraphRAG / get_comparable_value

Method get_comparable_value

agent/amount_normalizer.py:160–179  ·  view source on GitHub ↗

获取可比较的数值(用于排序、筛选等) Args: amount: 用量 unit: 单位 Returns: 可比较的数值,None表示无法比较

(self, amount: str, unit: str = "")

Source from the content-addressed store, hash-verified

158 return normalized, "", estimated
159
160 def get_comparable_value(self, amount: str, unit: str = "") -> Optional[float]:
161 """
162 获取可比较的数值(用于排序、筛选等)
163
164 Args:
165 amount: 用量
166 unit: 单位
167
168 Returns:
169 可比较的数值,None表示无法比较
170 """
171 # 尝试解析为数字
172 try:
173 return float(amount)
174 except ValueError:
175 pass
176
177 # 使用估算值
178 normalized, estimated = self.normalize_amount(amount, unit)
179 return estimated
180
181 def format_for_display(self, amount: str, unit: str = "") -> str:
182 """

Callers

nothing calls this directly

Calls 1

normalize_amountMethod · 0.95

Tested by

no test coverage detected