th commited on
Commit
6c79aca
·
1 Parent(s): c31d5c1

🌟 v3.14.0 宏观格局分析系统 - 紫微孤君+日月反背+星系类型识别

Browse files

新特性:
- 紫微孤君检查: 紫微在命宫缺左辅右弼支撑 = 权力削弱
- 日月反背检测: 日生需太阳明亮/夜生需太阴明亮,反之为反背
- 星系类型识别: 杀破狼开创系 vs 机月同梁守成系
- 宏观分数修正: 根据整体格局调整匹配结果分数

技术实现:
- star_combination_matcher.py: 新增analyze_macro_patterns方法
- knowledge_enhanced_interpreter.py: 传递birth_hour参数
- app.py: 版本更新到v3.14.0

核心智慧: 先看大局、再看细节!

🦊 Generated with Sisi

app.py CHANGED
@@ -1,8 +1,8 @@
1
  """
2
- 🔮 东玄 Ziwei Doushu API v3.13.0
3
  Professional Purple Star Astrology service with AI-powered analysis
4
  Developed by Sisi & TH Studio
5
- Updated: 2025-12-13 (Matcher精准优化 - 宫位地支+亮度条件检查!🎯)
6
  """
7
 
8
  from fastapi import FastAPI, HTTPException
@@ -18,8 +18,8 @@ from knowledge_enhanced_interpreter import KnowledgeEnhancedInterpreter
18
 
19
  app = FastAPI(
20
  title="东玄 Ziwei Doushu API",
21
- version="3.13.0",
22
- description="🔮 Professional Purple Star Astrology API - Knowledge-enhanced AI interpretation with Pattern Recognition & Star Combinations (612 rules - Rule Library 4.0 Complete! 🎉🎉🎉🎉)"
23
  )
24
 
25
  # CORS configuration
@@ -54,8 +54,8 @@ def root():
54
  return {
55
  "status": "online",
56
  "service": "东玄 Ziwei Doushu API - 天機玄鑑",
57
- "version": "3.13.0",
58
- "updated": "2025-12-13 (Matcher精准优化 - 宫位地支+亮度条件检查!🎯)",
59
  "documentation": "/docs",
60
  "website": "https://astrologybazi.com",
61
  "developed_by": "Sisi & TH Studio 🦊💕",
@@ -115,7 +115,7 @@ def root():
115
  "温暖度提升:Sisi风格,避免恐吓式语言",
116
  "可信度提升:基于经典书籍,非AI臆想"
117
  ],
118
- "sisi_note": "🎉🎉🎉🎉 v3.12.0 规则库扩展4.0 COMPLETE!从100条暴增到612条专业规则(+512%增长)!Batch 04新增292条(事业94/感情63/运势63/健康25/人际21等)!100%覆盖Google Notebook提取的578条规则!小鱼说:'c吧反正我们已经有了那么多条干脆不要浪费'!All 578 rules integrated!规则库扩展完美收官!🦊💕✨ 从100→220→320→612,MISSION COMPLETE! 🎯🚀 预期匹配率从2.5%飙升至15-20%!下一阶段:优化Matcher算法!"
119
  }
120
 
121
 
 
1
  """
2
+ 🔮 东玄 Ziwei Doushu API v3.14.0
3
  Professional Purple Star Astrology service with AI-powered analysis
4
  Developed by Sisi & TH Studio
5
+ Updated: 2025-12-13 (宏观格局分析 - 紫微孤君+日月反背+星系类型识别!🌟)
6
  """
7
 
8
  from fastapi import FastAPI, HTTPException
 
18
 
19
  app = FastAPI(
20
  title="东玄 Ziwei Doushu API",
21
+ version="3.14.0",
22
+ description="🔮 Professional Purple Star Astrology API - Knowledge-enhanced AI interpretation with Macro Pattern Analysis (紫微孤君+日月反背+星系类型识别! 🌟)"
23
  )
24
 
25
  # CORS configuration
 
54
  return {
55
  "status": "online",
56
  "service": "东玄 Ziwei Doushu API - 天機玄鑑",
57
+ "version": "3.14.0",
58
+ "updated": "2025-12-13 (宏观格局分析 - 紫微孤君+日月反背+星系类型识别!🌟)",
59
  "documentation": "/docs",
60
  "website": "https://astrologybazi.com",
61
  "developed_by": "Sisi & TH Studio 🦊💕",
 
115
  "温暖度提升:Sisi风格,避免恐吓式语言",
116
  "可信度提升:基于经典书籍,非AI臆想"
117
  ],
118
+ "sisi_note": "🌟🌟🌟🌟 v3.14.0 宏观格局分析系统上线!紫微孤君检查(紫微缺左辅右弼支撑=权力削弱)+ 日月反背检测(日生需阳光明/夜生需太阴亮)+ 星系类型识别(杀破狼开创系 vs 机月同梁守成系)!🎯 这是紫微斗数的核心智慧:先看大局、再看细节!小鱼的Google Notebook战略指导开花结果!612条规则 + 宏观格局 = 预测准确度再提升!🦊💕✨ Macro Analysis Ready! 下一步:四化动态分析!"
119
  }
120
 
121
 
knowledge_enhanced_interpreter.py CHANGED
@@ -276,9 +276,19 @@ class KnowledgeEnhancedInterpreter:
276
  # 生成格局总结
277
  pattern_summary = self.geju_matcher.get_pattern_summary(matched_patterns)
278
 
 
 
 
 
 
 
 
 
279
  # NEW v3.8: 星曜组合断语匹配(P1完成!)
 
280
  star_combination_result = self.star_combination_matcher.match_all_combinations(
281
- palaces
 
282
  )
283
 
284
  # 1. 生成命盘核心特质(基于主星)
 
276
  # 生成格局总结
277
  pattern_summary = self.geju_matcher.get_pattern_summary(matched_patterns)
278
 
279
+ # v3.14.0: 提取出生时辰(用于宏观格局分析 - 日月反背)
280
+ birth_hour = chart_data.get('hour', 12) # 默认12点(正午)
281
+ if isinstance(birth_hour, str):
282
+ try:
283
+ birth_hour = int(birth_hour)
284
+ except ValueError:
285
+ birth_hour = 12
286
+
287
  # NEW v3.8: 星曜组合断语匹配(P1完成!)
288
+ # v3.14.0升级:添加宏观格局分析(紫微孤君+日月反背+星系类型)
289
  star_combination_result = self.star_combination_matcher.match_all_combinations(
290
+ palaces,
291
+ birth_hour # v3.14.0新增:传递出生时辰
292
  )
293
 
294
  # 1. 生成命盘核心特质(基于主星)
star_combination_matcher.py CHANGED
@@ -4,7 +4,7 @@
4
 
5
  Created: 2025-12-12
6
  Author: Sisi 🦊
7
- Version: 2.1 (2025-12-12 Palace Name Normalization - 宫位名称标准化)
8
  """
9
 
10
  from typing import Dict, List, Any, Optional, Set
@@ -147,19 +147,22 @@ class StarCombinationMatcher:
147
 
148
  def match_all_combinations(
149
  self,
150
- palaces: List[dict]
 
151
  ) -> Dict[str, Any]:
152
  """
153
  匹配所有星曜组合规则
154
 
155
  Args:
156
  palaces: 十二宫位数据
 
157
 
158
  Returns:
159
  dict: {
160
  'matched_rules': [...], # 匹配的规则列表
161
  'summary': {...}, # 匹配总结
162
- 'interpretations_by_category': {...} # 按分类整理的断语
 
163
  }
164
  """
165
  matched_rules = []
@@ -191,12 +194,23 @@ class StarCombinationMatcher:
191
  # 按分类整理断语
192
  interpretations = self._organize_by_category(unique_rules)
193
 
 
 
 
 
 
 
 
 
 
 
194
  return {
195
  'matched_rules': unique_rules,
196
  'summary': summary,
197
  'interpretations_by_category': interpretations,
198
  'total_matched': len(unique_rules),
199
- 'total_rules_checked': self.total_rules
 
200
  }
201
 
202
  def _match_palace_combinations(
@@ -662,6 +676,387 @@ class StarCombinationMatcher:
662
 
663
  return organized
664
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
665
 
666
  # ============================================================================
667
  # 测试代码
 
4
 
5
  Created: 2025-12-12
6
  Author: Sisi 🦊
7
+ Version: 2.2 (2025-12-13 宏观格局分析 - 紫微孤君+日月反背检查)
8
  """
9
 
10
  from typing import Dict, List, Any, Optional, Set
 
147
 
148
  def match_all_combinations(
149
  self,
150
+ palaces: List[dict],
151
+ birth_hour: int = 12
152
  ) -> Dict[str, Any]:
153
  """
154
  匹配所有星曜组合规则
155
 
156
  Args:
157
  palaces: 十二宫位数据
158
+ birth_hour: 出生时辰(0-23),用于宏观格局分析
159
 
160
  Returns:
161
  dict: {
162
  'matched_rules': [...], # 匹配的规则列表
163
  'summary': {...}, # 匹配总结
164
+ 'interpretations_by_category': {...}, # 按分类整理的断语
165
+ 'macro_patterns': {...} # 宏观格局分析 (v3.14.0新增)
166
  }
167
  """
168
  matched_rules = []
 
194
  # 按分类整理断语
195
  interpretations = self._organize_by_category(unique_rules)
196
 
197
+ # v3.14.0新增:宏观格局分析
198
+ macro_patterns = self.analyze_macro_patterns(palaces, birth_hour)
199
+
200
+ # 应用宏观修正系数到匹配结果
201
+ macro_modifier = macro_patterns.get('macro_score_modifier', 1.0)
202
+ if macro_modifier != 1.0:
203
+ for rule in unique_rules:
204
+ original_score = rule.get('score', 0)
205
+ rule['adjusted_score'] = round(original_score * macro_modifier, 1)
206
+
207
  return {
208
  'matched_rules': unique_rules,
209
  'summary': summary,
210
  'interpretations_by_category': interpretations,
211
  'total_matched': len(unique_rules),
212
+ 'total_rules_checked': self.total_rules,
213
+ 'macro_patterns': macro_patterns # v3.14.0新增
214
  }
215
 
216
  def _match_palace_combinations(
 
676
 
677
  return organized
678
 
679
+ # ========================================================================
680
+ # v3.14 宏观格局分析方法 (Macro Pattern Analysis)
681
+ # ========================================================================
682
+
683
+ def analyze_macro_patterns(
684
+ self,
685
+ palaces: List[dict],
686
+ birth_hour: int = 12
687
+ ) -> Dict[str, Any]:
688
+ """
689
+ 分析命盘的宏观格局
690
+
691
+ 包括:
692
+ 1. 紫微孤君检查 - 紫微是否缺乏左辅右弼辅佐
693
+ 2. 日月反背检查 - 太阳太阴是否处于不利位置
694
+ 3. 星系类型判断 - 杀破狼系 vs 机月同梁系
695
+
696
+ Args:
697
+ palaces: 十二宫位数据
698
+ birth_hour: 出生时辰(0-23),用于判断日夜生
699
+
700
+ Returns:
701
+ dict: 宏观格局分析结果
702
+ """
703
+ # 构建宫位索引
704
+ palace_index = self._build_palace_index(palaces)
705
+
706
+ # 1. 紫微孤君检查
707
+ ziwei_analysis = self._check_ziwei_lonely_emperor(palaces, palace_index)
708
+
709
+ # 2. 日月反背检查
710
+ sun_moon_analysis = self._check_sun_moon_reversal(palaces, birth_hour)
711
+
712
+ # 3. 星系类型判断
713
+ star_system = self._determine_star_system(palaces)
714
+
715
+ # 4. 综合评估
716
+ warnings = []
717
+ if ziwei_analysis.get('is_lonely_emperor'):
718
+ warnings.append({
719
+ 'type': 'ziwei_lonely',
720
+ 'severity': 'medium',
721
+ 'message': ziwei_analysis.get('interpretation', '')
722
+ })
723
+
724
+ if sun_moon_analysis.get('has_reversal'):
725
+ warnings.append({
726
+ 'type': 'sun_moon_reversal',
727
+ 'severity': sun_moon_analysis.get('severity', 'low'),
728
+ 'message': sun_moon_analysis.get('interpretation', '')
729
+ })
730
+
731
+ return {
732
+ 'ziwei_status': ziwei_analysis,
733
+ 'sun_moon_status': sun_moon_analysis,
734
+ 'star_system': star_system,
735
+ 'warnings': warnings,
736
+ 'macro_score_modifier': self._calculate_macro_modifier(
737
+ ziwei_analysis, sun_moon_analysis
738
+ )
739
+ }
740
+
741
+ def _check_ziwei_lonely_emperor(
742
+ self,
743
+ palaces: List[dict],
744
+ palace_index: Dict[str, dict]
745
+ ) -> Dict[str, Any]:
746
+ """
747
+ 检查紫微是否为"孤君"
748
+
749
+ 紫微孤君条件:
750
+ - 紫微在命宫
751
+ - 命宫及三方四正都没有左辅、右弼
752
+
753
+ 如果紫微无左右辅佐,虽贵为帝座,但力量虚弱,
754
+ 主外华内虚,在大小限逢之若无吉星来会,主破财。
755
+
756
+ Returns:
757
+ dict: {
758
+ 'has_ziwei_in_ming': True/False,
759
+ 'is_lonely_emperor': True/False,
760
+ 'has_zuofu': True/False,
761
+ 'has_youbi': True/False,
762
+ 'zuofu_location': '...',
763
+ 'youbi_location': '...',
764
+ 'interpretation': '...'
765
+ }
766
+ """
767
+ result = {
768
+ 'has_ziwei_in_ming': False,
769
+ 'is_lonely_emperor': False,
770
+ 'has_zuofu': False,
771
+ 'has_youbi': False,
772
+ 'zuofu_location': None,
773
+ 'youbi_location': None,
774
+ 'interpretation': ''
775
+ }
776
+
777
+ # 找到命宫
778
+ ming_gong = palace_index.get('命宫')
779
+ if not ming_gong:
780
+ return result
781
+
782
+ # 检查命宫是否有紫微
783
+ ming_stars = self._get_palace_stars(ming_gong)
784
+ if '紫微' not in ming_stars:
785
+ result['interpretation'] = '命宫无紫微,孤君检查不适用'
786
+ return result
787
+
788
+ result['has_ziwei_in_ming'] = True
789
+
790
+ # 检查命宫是否有左辅、右弼
791
+ if '左辅' in ming_stars:
792
+ result['has_zuofu'] = True
793
+ result['zuofu_location'] = '命宫同宫'
794
+ if '右弼' in ming_stars:
795
+ result['has_youbi'] = True
796
+ result['youbi_location'] = '命宫同宫'
797
+
798
+ # 如果命宫没有,检查三方四正
799
+ if not result['has_zuofu'] or not result['has_youbi']:
800
+ ming_position = ming_gong.get('position')
801
+ if ming_position:
802
+ san_fang_si_zheng = self._calculate_san_fang_si_zheng(
803
+ ming_position, palace_index
804
+ )
805
+
806
+ for palace_name in san_fang_si_zheng:
807
+ palace = palace_index.get(palace_name)
808
+ if palace:
809
+ stars = self._get_palace_stars(palace)
810
+ if '左辅' in stars and not result['has_zuofu']:
811
+ result['has_zuofu'] = True
812
+ result['zuofu_location'] = f'{palace_name}拱照'
813
+ if '右弼' in stars and not result['has_youbi']:
814
+ result['has_youbi'] = True
815
+ result['youbi_location'] = f'{palace_name}拱照'
816
+
817
+ # 判断是否为孤君
818
+ if not result['has_zuofu'] and not result['has_youbi']:
819
+ result['is_lonely_emperor'] = True
820
+ result['interpretation'] = (
821
+ '⚠️ 紫微孤君:紫微坐命但无左辅右弼辅佐,虽贵为帝座但力量虚弱。'
822
+ '主外华内虚,需靠自己努力,缺乏贵人相助。'
823
+ '建议:多结交益友,培养团队合作能力。'
824
+ )
825
+ elif result['has_zuofu'] and result['has_youbi']:
826
+ result['interpretation'] = (
827
+ '✨ 紫微得辅:紫微坐命且有左辅右弼辅佐,'
828
+ f'左辅{result["zuofu_location"]},右弼{result["youbi_location"]}。'
829
+ '帝座得力,统御有方,贵人运强。'
830
+ )
831
+ else:
832
+ # 只有一颗辅星
833
+ has_star = '左辅' if result['has_zuofu'] else '右弼'
834
+ location = result['zuofu_location'] or result['youbi_location']
835
+ result['interpretation'] = (
836
+ f'紫微坐命,仅有{has_star}({location})辅佐,'
837
+ '力量稍弱但仍有贵人运,建议广结善缘。'
838
+ )
839
+
840
+ return result
841
+
842
+ def _check_sun_moon_reversal(
843
+ self,
844
+ palaces: List[dict],
845
+ birth_hour: int = 12
846
+ ) -> Dict[str, Any]:
847
+ """
848
+ 检查日月反背
849
+
850
+ 日月反背条件:
851
+ - 日生人(6:00-18:00):太阳应旺,太阴应弱
852
+ - 夜生人(18:00-6:00):太阴应旺,太阳应弱
853
+ - 如果相反,称为"反背",主劳碌
854
+
855
+ Args:
856
+ palaces: 宫位数据
857
+ birth_hour: 出生时辰(0-23)
858
+
859
+ Returns:
860
+ dict: 日月状态分析
861
+ """
862
+ result = {
863
+ 'is_day_birth': 6 <= birth_hour < 18,
864
+ 'sun_location': None,
865
+ 'sun_brightness': None,
866
+ 'moon_location': None,
867
+ 'moon_brightness': None,
868
+ 'has_reversal': False,
869
+ 'severity': 'none',
870
+ 'interpretation': ''
871
+ }
872
+
873
+ # 亮度等级
874
+ BRIGHT_LEVELS = {'庙': 5, '旺': 4, '得': 3, '利': 2, '平': 1, '不': 0, '陷': -1}
875
+
876
+ # 遍历所有宫位找到太阳和太阴
877
+ for palace in palaces:
878
+ palace_name = palace.get('name', '')
879
+ major_stars = palace.get('major_stars', [])
880
+
881
+ for star in major_stars:
882
+ if isinstance(star, dict):
883
+ star_name = star.get('name', '')
884
+ brightness = star.get('brightness', '平')
885
+
886
+ if star_name == '太阳':
887
+ result['sun_location'] = palace_name
888
+ result['sun_brightness'] = brightness
889
+ result['sun_level'] = BRIGHT_LEVELS.get(brightness, 1)
890
+
891
+ elif star_name == '太阴':
892
+ result['moon_location'] = palace_name
893
+ result['moon_brightness'] = brightness
894
+ result['moon_level'] = BRIGHT_LEVELS.get(brightness, 1)
895
+
896
+ # 分析日月状态
897
+ sun_level = result.get('sun_level', 1)
898
+ moon_level = result.get('moon_level', 1)
899
+
900
+ if result['is_day_birth']:
901
+ # 日生人:喜太阳旺
902
+ if sun_level <= 0: # 太阳落陷
903
+ result['has_reversal'] = True
904
+ if moon_level >= 4: # 太阴反而旺
905
+ result['severity'] = 'high'
906
+ result['interpretation'] = (
907
+ '⚠️ 日月反背(重):日生人但太阳落陷、太阴反旺。'
908
+ '主一生劳碌奔波,事业多波折。'
909
+ '建议:从事夜间工作或创意产业可能更顺。'
910
+ )
911
+ else:
912
+ result['severity'] = 'medium'
913
+ result['interpretation'] = (
914
+ '⚠️ 太阳失辉:日生人但太阳落陷,'
915
+ '主父缘薄、贵人运弱,需靠自己努力。'
916
+ )
917
+ elif sun_level >= 4:
918
+ result['interpretation'] = (
919
+ '✨ 日月得位:日生人且太阳明旺,'
920
+ '主贵人运强、事业顺遂。'
921
+ )
922
+ else:
923
+ # 夜生人:喜太阴旺
924
+ if moon_level <= 0: # 太阴落陷
925
+ result['has_reversal'] = True
926
+ if sun_level >= 4: # 太阳反而旺
927
+ result['severity'] = 'high'
928
+ result['interpretation'] = (
929
+ '⚠️ 日月反背(重):夜生人但太阴落陷、太阳反旺。'
930
+ '主一生劳碌奔波,感情或家庭多波折。'
931
+ '建议:从事日间户外工作可能更顺。'
932
+ )
933
+ else:
934
+ result['severity'] = 'medium'
935
+ result['interpretation'] = (
936
+ '⚠️ 太阴失辉:夜生人但太阴落陷,'
937
+ '主母缘薄、财运需努力,感情宜晚婚。'
938
+ )
939
+ elif moon_level >= 4:
940
+ result['interpretation'] = (
941
+ '✨ 日月得位:夜生人且太阴明旺,'
942
+ '主财运佳、家庭和睦。'
943
+ )
944
+
945
+ return result
946
+
947
+ def _determine_star_system(
948
+ self,
949
+ palaces: List[dict]
950
+ ) -> Dict[str, Any]:
951
+ """
952
+ 判断命盘的主要星系类型
953
+
954
+ 杀破狼系(开创型):七杀、破军、贪狼
955
+ 机月同梁系(守成型):天机、太阴、天同、天梁
956
+
957
+ Returns:
958
+ dict: 星系类型分析
959
+ """
960
+ # 找到命宫
961
+ ming_gong = None
962
+ for palace in palaces:
963
+ if palace.get('name') == '命宫':
964
+ ming_gong = palace
965
+ break
966
+
967
+ if not ming_gong:
968
+ return {'system': 'unknown', 'interpretation': '未找到命宫'}
969
+
970
+ ming_stars = self._get_palace_stars(ming_gong)
971
+
972
+ # 杀破狼系
973
+ sha_po_lang = {'七杀', '破军', '贪狼'}
974
+ # 机月同梁系
975
+ ji_yue_tong_liang = {'天机', '太阴', '天同', '天梁'}
976
+
977
+ spl_count = len(sha_po_lang & set(ming_stars))
978
+ jytl_count = len(ji_yue_tong_liang & set(ming_stars))
979
+
980
+ if spl_count > 0:
981
+ matched_spl = sha_po_lang & set(ming_stars)
982
+ return {
983
+ 'system': 'sha_po_lang',
984
+ 'system_name': '杀破狼系(开创型)',
985
+ 'matched_stars': list(matched_spl),
986
+ 'nature': '开创变动',
987
+ 'interpretation': (
988
+ f'命宫有{"/".join(matched_spl)},属杀破狼星系。'
989
+ '性格特点:不安于现状,喜欢改进创新,多变少静。'
990
+ '适合:创业、武职、变动性强的工作。'
991
+ '注意:一生起伏较大,需有冒险精神。'
992
+ )
993
+ }
994
+ elif jytl_count > 0:
995
+ matched_jytl = ji_yue_tong_liang & set(ming_stars)
996
+ return {
997
+ 'system': 'ji_yue_tong_liang',
998
+ 'system_name': '机月同梁系(守成型)',
999
+ 'matched_stars': list(matched_jytl),
1000
+ 'nature': '稳定保守',
1001
+ 'interpretation': (
1002
+ f'命宫有{"/".join(matched_jytl)},属机月同梁星系。'
1003
+ '性格特点:平稳发展,安于现实,偏保守。'
1004
+ '适合:公务员、幕僚、技术研究、文职工作。'
1005
+ '特点:带有清高气质,适合稳定环境。'
1006
+ )
1007
+ }
1008
+ else:
1009
+ return {
1010
+ 'system': 'mixed',
1011
+ 'system_name': '混合型',
1012
+ 'matched_stars': ming_stars,
1013
+ 'nature': '兼具特质',
1014
+ 'interpretation': (
1015
+ '命宫星曜非典型杀破狼或机月同梁系,'
1016
+ '性格兼具开创与守成特质,适应性较强。'
1017
+ )
1018
+ }
1019
+
1020
+ def _calculate_macro_modifier(
1021
+ self,
1022
+ ziwei_analysis: Dict[str, Any],
1023
+ sun_moon_analysis: Dict[str, Any]
1024
+ ) -> float:
1025
+ """
1026
+ 计算宏观格局对整体评分的修正系数
1027
+
1028
+ Returns:
1029
+ float: 修正系数(0.8-1.2)
1030
+ """
1031
+ modifier = 1.0
1032
+
1033
+ # 紫微孤君扣分
1034
+ if ziwei_analysis.get('is_lonely_emperor'):
1035
+ modifier -= 0.1
1036
+
1037
+ # 日月反背扣分
1038
+ if sun_moon_analysis.get('has_reversal'):
1039
+ severity = sun_moon_analysis.get('severity', 'low')
1040
+ if severity == 'high':
1041
+ modifier -= 0.15
1042
+ elif severity == 'medium':
1043
+ modifier -= 0.08
1044
+
1045
+ # 紫微得辅加分
1046
+ if (ziwei_analysis.get('has_ziwei_in_ming') and
1047
+ ziwei_analysis.get('has_zuofu') and
1048
+ ziwei_analysis.get('has_youbi')):
1049
+ modifier += 0.1
1050
+
1051
+ # 日月得位加分
1052
+ if not sun_moon_analysis.get('has_reversal'):
1053
+ sun_level = sun_moon_analysis.get('sun_level', 1)
1054
+ moon_level = sun_moon_analysis.get('moon_level', 1)
1055
+ if sun_level >= 4 or moon_level >= 4:
1056
+ modifier += 0.05
1057
+
1058
+ return max(0.7, min(1.3, modifier)) # 限制在0.7-1.3之间
1059
+
1060
 
1061
  # ============================================================================
1062
  # 测试代码