230 lines
8.6 KiB
Python
230 lines
8.6 KiB
Python
"""
|
|
阳具崇拜文化分析 - 核心数据模型
|
|
基于设计文档中定义的数据结构
|
|
"""
|
|
|
|
from dataclasses import dataclass
|
|
from typing import List, Optional, Dict
|
|
from datetime import datetime
|
|
from enum import Enum
|
|
|
|
class ReliabilityLevel(Enum):
|
|
"""史料可靠性等级"""
|
|
HIGH = "high" # 多重史料验证
|
|
MEDIUM = "medium" # 单一可靠史料
|
|
LOW = "low" # 传说或推测
|
|
UNCERTAIN = "uncertain" # 存疑
|
|
|
|
class CulturalType(Enum):
|
|
"""文化类型"""
|
|
PHALLIC_WORSHIP = "phallic_worship" # 阳具崇拜
|
|
DRAGON_WORSHIP = "dragon_worship" # 龙崇拜
|
|
FIRE_WORSHIP = "fire_worship" # 火崇拜
|
|
ANCESTOR_WORSHIP = "ancestor_worship" # 祖先崇拜
|
|
FERTILITY_RITUAL = "fertility_ritual" # 生育仪式
|
|
|
|
@dataclass
|
|
class Emperor:
|
|
"""北魏皇帝数据模型"""
|
|
name: str # 皇帝姓名
|
|
reign_period: str # 在位时期
|
|
birth_year: Optional[int] # 出生年份
|
|
death_year: Optional[int] # 死亡年份
|
|
lifespan: Optional[int] # 寿命
|
|
reign_duration: Optional[int] # 在位时长
|
|
death_cause: Optional[str] # 死因
|
|
offspring_count: Optional[int] # 子嗣数量
|
|
fertility_anxiety_score: Optional[float] # 生育焦虑评分
|
|
religious_activities: List[str] # 宗教活动记录
|
|
sources: List[str] # 史料来源
|
|
reliability: ReliabilityLevel # 可靠性等级
|
|
|
|
def calculate_lifespan(self) -> Optional[int]:
|
|
"""计算寿命"""
|
|
if self.birth_year and self.death_year:
|
|
return self.death_year - self.birth_year
|
|
return None
|
|
|
|
def is_short_lived(self, threshold: int = 30) -> bool:
|
|
"""判断是否短寿"""
|
|
lifespan = self.calculate_lifespan()
|
|
return lifespan is not None and lifespan < threshold
|
|
|
|
@dataclass
|
|
class ReligiousBuilding:
|
|
"""宗教建筑数据模型"""
|
|
name: str # 建筑名称
|
|
location: Dict[str, float] # 地理位置 {"lat": 纬度, "lng": 经度}
|
|
construction_period: str # 建造时期
|
|
architect: Optional[str] # 建造者
|
|
purpose: List[str] # 建造目的
|
|
architectural_features: List[str] # 建筑特征
|
|
religious_function: List[str] # 宗教功能
|
|
political_significance: str # 政治意义
|
|
modern_status: str # 现状
|
|
fertility_elements: List[str] # 生育祈福元素
|
|
dragon_symbolism: List[str] # 龙崇拜象征
|
|
sources: List[str] # 史料来源
|
|
reliability: ReliabilityLevel # 可靠性等级
|
|
|
|
def has_fertility_function(self) -> bool:
|
|
"""是否具有生育祈福功能"""
|
|
fertility_keywords = ["生育", "祈福", "多子", "繁衍", "阳具", "龙"]
|
|
return any(keyword in " ".join(self.religious_function + self.fertility_elements)
|
|
for keyword in fertility_keywords)
|
|
|
|
@dataclass
|
|
class FolkCustom:
|
|
"""民俗习俗数据模型"""
|
|
name: str # 习俗名称
|
|
region: str # 地区
|
|
historical_period: str # 历史时期
|
|
practice_description: str # 实践描述
|
|
cultural_meaning: List[str] # 文化含义
|
|
religious_aspects: List[str] # 宗教层面
|
|
social_function: List[str] # 社会功能
|
|
modern_practice: bool # 现代是否仍在实践
|
|
variations: List[str] # 地区变体
|
|
fertility_connection: bool # 是否与生育相关
|
|
dragon_elements: List[str] # 龙文化元素
|
|
phallic_symbolism: List[str] # 阳具象征
|
|
sources: List[str] # 史料来源
|
|
reliability: ReliabilityLevel # 可靠性等级
|
|
|
|
def get_cultural_continuity_score(self) -> float:
|
|
"""计算文化连续性评分"""
|
|
score = 0.0
|
|
if self.modern_practice:
|
|
score += 0.3
|
|
if len(self.variations) > 2:
|
|
score += 0.2
|
|
if self.fertility_connection:
|
|
score += 0.3
|
|
if len(self.dragon_elements) > 0:
|
|
score += 0.2
|
|
return min(score, 1.0)
|
|
|
|
@dataclass
|
|
class CulturalTransmission:
|
|
"""文化传播数据模型"""
|
|
source_region: str # 源地区
|
|
target_region: str # 目标地区
|
|
transmission_period: str # 传播时期
|
|
transmission_mechanism: str # 传播机制
|
|
cultural_carriers: List[str] # 文化载体
|
|
adaptations: List[str] # 适应性变化
|
|
evidence: List[str] # 证据来源
|
|
reliability: ReliabilityLevel # 可靠性评分
|
|
cultural_type: CulturalType # 文化类型
|
|
transmission_route: List[str] # 传播路径
|
|
time_span: Optional[int] # 传播时间跨度
|
|
success_indicators: List[str] # 成功传播指标
|
|
|
|
def calculate_transmission_success(self) -> float:
|
|
"""计算传播成功度"""
|
|
success_score = 0.0
|
|
if len(self.evidence) >= 3:
|
|
success_score += 0.4
|
|
if len(self.success_indicators) >= 2:
|
|
success_score += 0.3
|
|
if self.reliability in [ReliabilityLevel.HIGH, ReliabilityLevel.MEDIUM]:
|
|
success_score += 0.3
|
|
return min(success_score, 1.0)
|
|
|
|
@dataclass
|
|
class DragonWorshipDocument:
|
|
"""龙崇拜文献数据模型"""
|
|
title: str # 文献标题
|
|
author: str # 作者
|
|
period: str # 时期
|
|
content: str # 文献内容
|
|
dragon_characteristics: List[str] # 龙的特征描述
|
|
sexual_symbolism: List[str] # 性象征内容
|
|
cultural_context: str # 文化背景
|
|
cross_references: List[str] # 交叉引用
|
|
reliability: ReliabilityLevel # 史料可靠性
|
|
phallic_connections: List[str] # 与阳具崇拜的关联
|
|
|
|
def extract_dragon_sexuality_themes(self) -> List[str]:
|
|
"""提取龙性特征主题"""
|
|
sexuality_keywords = ["淫", "交", "生", "育", "繁", "殖"]
|
|
themes = []
|
|
for char in self.dragon_characteristics:
|
|
if any(keyword in char for keyword in sexuality_keywords):
|
|
themes.append(char)
|
|
return themes
|
|
|
|
@dataclass
|
|
class LinguisticEvidence:
|
|
"""语言学考证数据模型"""
|
|
word: str # 词汇
|
|
pronunciation: str # 发音
|
|
meaning: str # 含义
|
|
etymology: str # 词源
|
|
region: str # 地区
|
|
period: str # 时期
|
|
related_words: List[str] # 相关词汇
|
|
symbolism: List[str] # 象征意义
|
|
evidence: List[str] # 语言学证据
|
|
phonetic_evolution: Dict[str, str] # 音韵演变
|
|
dragon_connection: bool # 是否与龙相关
|
|
phallic_connection: bool # 是否与阳具相关
|
|
|
|
def is_dragon_phallic_word(self) -> bool:
|
|
"""判断是否为龙-阳具相关词汇"""
|
|
return self.dragon_connection and self.phallic_connection
|
|
|
|
@dataclass
|
|
class NihonShokiAnalysis:
|
|
"""日本书纪分析数据模型"""
|
|
section: str # 章节
|
|
content: str # 内容
|
|
northern_wei_elements: List[str] # 北魏文化元素
|
|
packaging_strategies: List[str] # 包装策略
|
|
myth_construction: List[str] # 神话建构
|
|
political_purpose: str # 政治目的
|
|
cultural_inferiority_indicators: List[str] # 文化自卑指标
|
|
imagination_community_elements: List[str] # 想象共同体元素
|
|
sources: List[str] # 史料来源
|
|
analysis_confidence: float # 分析置信度
|
|
|
|
def calculate_packaging_intensity(self) -> float:
|
|
"""计算包装强度"""
|
|
intensity = 0.0
|
|
intensity += len(self.packaging_strategies) * 0.2
|
|
intensity += len(self.myth_construction) * 0.3
|
|
intensity += len(self.cultural_inferiority_indicators) * 0.1
|
|
return min(intensity, 1.0)
|
|
|
|
# 数据库连接配置
|
|
DATABASE_CONFIG = {
|
|
"neo4j": {
|
|
"uri": "bolt://localhost:7687",
|
|
"user": "neo4j",
|
|
"password": "password",
|
|
"database": "phallic_worship_analysis"
|
|
},
|
|
"postgresql": {
|
|
"host": "localhost",
|
|
"port": 5432,
|
|
"database": "phallic_worship_db",
|
|
"user": "postgres",
|
|
"password": "password"
|
|
}
|
|
}
|
|
|
|
# 数据质量控制标准
|
|
QUALITY_STANDARDS = {
|
|
"minimum_sources": 2, # 最少史料来源数
|
|
"reliability_threshold": ReliabilityLevel.MEDIUM, # 最低可靠性要求
|
|
"evidence_completeness": 0.7, # 证据完整性阈值
|
|
"cross_validation_required": True # 是否需要交叉验证
|
|
}
|
|
|
|
# 统计分析参数
|
|
ANALYSIS_PARAMETERS = {
|
|
"emperor_lifespan_threshold": 30, # 短寿阈值
|
|
"cultural_continuity_threshold": 0.6, # 文化连续性阈值
|
|
"transmission_success_threshold": 0.5, # 传播成功阈值
|
|
"confidence_interval": 0.95 # 置信区间
|
|
} |