MCPcopy
hub / github.com/chinesehuazhou/python-weekly / build_english_description

Function build_english_description

resources/weekly_workflow.py:96–122  ·  view source on GitHub ↗

将中文统计描述转换为英文描述

(description)

Source from the content-addressed store, hash-verified

94 return f"{prefix}: {english_issue_title}"
95
96def build_english_description(description):
97 """将中文统计描述转换为英文描述"""
98 if not description:
99 return description
100 article_count = int(re.search(r'(\d+)\s*篇文章', description).group(1)) if re.search(r'(\d+)\s*篇文章', description) else 0
101 project_count = int(re.search(r'(\d+)\s*个开源项目', description).group(1)) if re.search(r'(\d+)\s*个开源项目', description) else 0
102 audio_video_match = re.search(r'(\d+)\s*则音视频', description)
103 hot_topic_match = re.search(r'(\d+)\s*[则个]\s*热门(?:讨论|话题)', description)
104 book_match = re.search(r'赠书\s*(\d+)\s*本', description)
105
106 parts = []
107 if article_count:
108 parts.append(f"{article_count} article{'s' if article_count != 1 else ''}")
109 if project_count:
110 parts.append(f"{project_count} open-source project{'s' if project_count != 1 else ''}")
111 if audio_video_match:
112 count = int(audio_video_match.group(1))
113 parts.append(f"{count} audio/video{'s' if count != 1 else ''}")
114 if hot_topic_match:
115 count = int(hot_topic_match.group(1))
116 parts.append(f"{count} hot discussion{'s' if count != 1 else ''}")
117 if book_match:
118 count = int(book_match.group(1))
119 parts.append(f"{count} book giveaway{'s' if count != 1 else ''}")
120 if parts:
121 return "Shared " + ", ".join(parts)
122 return description
123
124def replace_front_matter_field(content, field_name, new_value):
125 """替换 front matter 中的单行字段,并尽量保留原始引号风格"""

Callers 2

split_and_generate_filesFunction · 0.85
write_to_md_file_enFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected