MCPcopy Create free account
hub / github.com/BIT-DataLab/Edit-Banana / process

Method process

modules/text/processors/font_size.py:17–47  ·  view source on GitHub ↗

处理字号(主入口) Args: text_blocks: 文字块列表 unify: 是否执行聚类统一 vertical_threshold_ratio: 垂直距离阈值比例 font_diff_threshold: 字号差异阈值 Returns: 处理后的文字块列表

(
        self, 
        text_blocks: List[Dict[str, Any]],
        unify: bool = True,
        vertical_threshold_ratio: float = 0.5,
        font_diff_threshold: float = 5.0
    )

Source from the content-addressed store, hash-verified

15 self.text_offset = text_offset
16
17 def process(
18 self,
19 text_blocks: List[Dict[str, Any]],
20 unify: bool = True,
21 vertical_threshold_ratio: float = 0.5,
22 font_diff_threshold: float = 5.0
23 ) -> List[Dict[str, Any]]:
24 """
25 处理字号(主入口)
26
27 Args:
28 text_blocks: 文字块列表
29 unify: 是否执行聚类统一
30 vertical_threshold_ratio: 垂直距离阈值比例
31 font_diff_threshold: 字号差异阈值
32
33 Returns:
34 处理后的文字块列表
35 """
36 # 步骤 1: 计算初始字号
37 blocks = self.calculate_font_sizes(text_blocks)
38
39 # 步骤 2: 聚类统一
40 if unify and len(blocks) > 1:
41 blocks = self.unify_by_clustering(
42 blocks,
43 vertical_threshold_ratio,
44 font_diff_threshold
45 )
46
47 return blocks
48
49 def calculate_font_sizes(self, text_blocks: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
50 """Set font_size from block height (text: height - offset; formula: height * ratio)."""

Callers 1

font_size.pyFile · 0.45

Calls 2

calculate_font_sizesMethod · 0.95
unify_by_clusteringMethod · 0.95

Tested by

no test coverage detected