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

Method format_for_display

agent/amount_normalizer.py:181–201  ·  view source on GitHub ↗

格式化用于显示的用量字符串 Args: amount: 用量 unit: 单位 Returns: 格式化后的字符串

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

Source from the content-addressed store, hash-verified

179 return estimated
180
181 def format_for_display(self, amount: str, unit: str = "") -> str:
182 """
183 格式化用于显示的用量字符串
184
185 Args:
186 amount: 用量
187 unit: 单位
188
189 Returns:
190 格式化后的字符串
191 """
192 normalized, _ = self.normalize_amount(amount, unit)
193
194 if unit and normalized:
195 # 如果有单位且不是特殊表达(如"适量"已经很完整)
196 if normalized not in ["适量", "少许", "中量", "大量"]:
197 return f"{normalized} {unit}"
198 else:
199 return normalized
200 else:
201 return normalized or amount
202
203# 使用示例
204def demo_normalization():

Callers

nothing calls this directly

Calls 1

normalize_amountMethod · 0.95

Tested by

no test coverage detected