外卖评价智能生成器 - 让好评不再词穷一、实际应用场景描述场景背景小张是一名数字文化艺术创新创业课程的在读研究生同时也是某互联网公司的全栈开发工程师。作为一个资深宅男他每周要点8-10次外卖但每次到了评价环节就犯难- 好吃的外卖想夸但只会说好吃、不错、很香- 遇到包装精美的外卖想夸设计但词不达意- 送餐小哥服务很好但除了谢谢不知道怎么表达感谢- 偶尔遇到不满意的情况想提意见又怕显得刻薄- 看着别人写的几百字走心好评自己只能憋出几个字更尴尬的是小张发现自己的评价记录简直是评价灾难- 好吃配一张模糊的包装袋照片- 不错不错配一张几乎看不清菜品的图- 味道还行没有任何细节描述痛点分析1. 词汇贫瘠面对丰富多样的用餐体验大脑一片空白2. 表达焦虑担心评价太简单显得没诚意太复杂又怕词不达意3. 场景多样不同的外卖类型快餐、正餐、甜品、饮品需要不同的评价角度4. 情绪复杂满意时要夸得有格调不满意时要提得有建设性5. 时间成本每次评价都要绞尽脑汁想半天破坏用餐后的放松时光解决方案开发一个基于Python的外卖评价智能生成器结合数字文化艺术理念通过多维体验分析文体风格适配情感智能匹配颠覆传统的绞尽脑汁写评价模式实现从词穷尴尬到妙笔生花的转变。二、核心逻辑讲解┌─────────────────────────────────────────────────────────────────────┐│ 外卖评价智能生成器 │├─────────────────────────────────────────────────────────────────────┤│ ││ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ││ │ 体验感知层 │───▶│ 情感分析层 │───▶│ 文案生成层 │ ││ │ │ │ │ │ │ ││ │ • 菜品维度 │ │ • 满意度 │ │ • 风格选择 │ ││ │ • 包装维度 │ │ • 惊喜度 │ │ • 模板匹配 │ ││ │ • 配送维度 │ │ • 期待差 │ │ • 修辞润色 │ ││ │ • 服务维度 │ │ • 情感倾向 │ │ • 个性化 │ ││ └─────────────┘ └─────────────┘ └─────────────┘ ││ │ │ │ ││ ▼ ▼ ▼ ││ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ││ │ 数字文化层 │ │ 文体风格层 │ │ 智能优化层 │ ││ │ │ │ │ │ │ ││ │ • 美食美学 │ │ • 文艺风 │ │ • 字数平衡 │ ││ │ • 包装艺术 │ │ • 幽默风 │ │ • 标签优化 │ ││ │ • 服务哲学 │ │ • 专业风 │ │ • 图片建议 │ ││ │ • 生活诗学 │ │ • 极简风 │ │ • 情感共鸣 │ ││ └─────────────┘ └─────────────┘ └─────────────┘ ││ │└─────────────────────────────────────────────────────────────────────┘核心工作流程1. 用户输入用餐体验的多维信息口味、包装、配送、服务等2. 系统分析各维度的表现计算综合满意度和情感倾向3. 根据用户偏好的文体风格从模板库中选择合适的表达框架4. 结合数字文化艺术元素生成具有美感和诚意的评价文案5. 智能优化文案长度、标签搭配和配图建议6. 输出多版本评价供用户选择支持二次编辑核心评价公式评价质量 (维度覆盖度 × 0.3) (情感真挚度 × 0.25) (文采表现力 × 0.2) (个性化程度 × 0.15) (实用价值 × 0.1)维度覆盖度 有效描述的维度数量 / 总维度数量情感真挚度 基于用户真实感受的自然表达程度文采表现力 修辞运用、词汇丰富度、节奏感个性化程度 避免套话体现个人特色实用价值 对其他用户的参考价值三、完整代码实现项目结构food_review_generator/├── main.py # 主程序入口├── experience_analyzer.py # 体验分析模块├── sentiment_analyzer.py # 情感分析模块├── style_selector.py # 风格选择器├── content_generator.py # 内容生成器├── digital_art_integration.py # 数字艺术整合模块├── smart_optimizer.py # 智能优化器├── config.py # 配置文件├── templates/ # 评价模板库│ ├── literary_style.json│ ├── humorous_style.json│ ├── professional_style.json│ └── minimal_style.json├── vocabulary/ # 词汇库│ ├── taste_descriptors.json│ ├── packaging_terms.json│ ├── delivery_phrases.json│ └── service_expressions.json├── data/ # 数据存储│ ├── user_preferences.json│ └── review_history.json├── requirements.txt # 依赖清单└── README.md # 项目说明1. requirements.txtpandas2.0.3numpy1.24.3jieba0.42.1snownlp0.12.3transformers4.30.2torch2.0.1scikit-learn1.3.0pillow10.0.0matplotlib3.7.2wordcloud1.9.22. config.py配置文件外卖评价智能生成器 - 配置文件作者AI助手用途统一管理系统的配置参数和模板路径数字文化艺术创新创业课程项目import osfrom dataclasses import dataclass, fieldfrom typing import Dict, List, Optionalfrom enum import Enumclass ReviewStyle(Enum):评价风格枚举LITERARY literary # 文艺风HUMOROUS humorous # 幽默风PROFESSIONAL professional # 专业风MINIMAL minimal # 极简风CREATIVE creative # 创意风class DishType(Enum):菜品类型枚举MAIN_COURSE main_course # 主食SNACK snack # 小吃DESSERT dessert # 甜品BEVERAGE beverage # 饮品COMBO combo # 套餐UNKNOWN unknown # 未知dataclassclass DimensionWeights:评价维度权重配置taste: float 0.35 # 口味权重packaging: float 0.20 # 包装权重delivery: float 0.25 # 配送权重service: float 0.20 # 服务权重dataclassclass StyleConfig:风格配置name: strdescription: strcharacteristics: List[str]suitable_scenes: List[str]vocabulary_tone: strsentence_patterns: List[str]emoji_usage: str # abundant, moderate, minimal, nonedataclassclass TemplateConfig:模板配置template_id: strstyle: strdish_type: strsatisfaction_level: str # very_satisfied, satisfied, neutral, dissatisfiedstructure: List[str] # 模板结构: [opening, taste, packaging, delivery, closing]min_length: intmax_length: intclass SystemConfig:系统总配置def __init__(self):self.dimension_weights DimensionWeights()self.review_styles self._init_review_styles()self.templates self._init_templates()self.vocabulary_paths self._init_vocabulary_paths()# 数据路径self.base_dir os.path.dirname(__file__)self.templates_dir os.path.join(self.base_dir, templates)self.vocabulary_dir os.path.join(self.base_dir, vocabulary)self.data_dir os.path.join(self.base_dir, data)# 创建必要目录self._create_directories()def _init_review_styles(self) - Dict[str, StyleConfig]:初始化评价风格配置return {literary: StyleConfig(name文艺风,description用诗意的语言描述用餐体验适合精致料理和甜品,characteristics[优美辞藻, 意境营造, 情感细腻, 文学引用],suitable_scenes[精致正餐, 甜品饮品, 特色小店, 文艺餐厅],vocabulary_tone雅致,sentence_patterns[初尝{菜品名}{味觉描述}如{文学意象}般在舌尖绽放,包装{包装描述}{视觉感受}透着{美学评价}的巧思,这一餐{情感表达}是{生活感悟}的注脚],emoji_usageminimal),humorous: StyleConfig(name幽默风,description用轻松诙谐的方式评价适合日常快餐和重口味食物,characteristics[俏皮话, 夸张修辞, 自嘲元素, 网络用语],suitable_scenes[快餐汉堡, 麻辣烫, 烧烤炸串, 平价小食],vocabulary_tone活泼,sentence_patterns[这{菜品名}啊{味觉夸张}差点让我{搞笑后果},包装{包装吐槽}但{转折惊喜}也算{幽默结论},外卖小哥{配送趣事}今天的快乐是{菜品名}给的],emoji_usageabundant),professional: StyleConfig(name专业风,description客观详细地评价各方面表现适合商务用餐和质量测评,characteristics[客观描述, 细节关注, 专业术语, 结构化表达],suitable_scenes[商务套餐, 健康轻食, 品质餐厅, 新品测评],vocabulary_tone严谨,sentence_patterns[{菜品名}采用{食材工艺}{口感层次}分明调味{专业评价},包装采用{材质工艺}{防护性能}良好保温{效果描述},配送准时率{时效数据}服务态度{标准化评价}整体体验{专业总结}],emoji_usagenone),minimal: StyleConfig(name极简风,description简洁有力的短评适合快速评价和日常记录,characteristics[言简意赅, 重点突出, 不废话, 易读性高],suitable_scenes[日常便当, 简单快餐, 快速复购, 时间紧迫],vocabulary_tone直接,sentence_patterns[{菜品名}{核心评价},包装{简洁描述}配送{速度评价},整体{满意度}{推荐指数}],emoji_usagemoderate),creative: StyleConfig(name创意风,description用独特视角和创新表达适合网红店和创意料理,characteristics[新颖比喻, 跨界联想, 个性化表达, 艺术感],suitable_scenes[网红打卡, 创意料理, 艺术餐厅, 新奇体验],vocabulary_tone独特,sentence_patterns[{菜品名}像是{跨界类比}{味觉惊喜}颠覆了我对{品类认知},包装设计{创意描述}{视觉冲击}像{艺术形式}般呈现,这顿饭{体验总结}是{创意评价}的味蕾实验],emoji_usagemoderate)}def _init_templates(self) - List[TemplateConfig]:初始化评价模板配置return [# 文艺风模板TemplateConfig(template_idlit_001,styleliterary,dish_typemain_course,satisfaction_levelvery_satisfied,structure[opening, taste, packaging, delivery, closing],min_length80,max_length150),TemplateConfig(template_idlit_002,styleliterary,dish_typedessert,satisfaction_levelsatisfied,structure[opening, appearance, taste, packaging, closing],min_length60,max_length120),# 幽默风模板TemplateConfig(template_idhum_001,stylehumorous,dish_typesnack,satisfaction_levelvery_satisfied,structure[opening, taste_exaggeration, packaging_funny, delivery_story, closing],min_length50,max_length100),TemplateConfig(template_idhum_002,stylehumorous,dish_typemain_course,satisfaction_levelsatisfied,structure[opening, taste_funny, packaging_complaint, delivery_relief, closing],min_length60,max_length110),# 专业风模板TemplateConfig(template_idpro_001,styleprofessional,dish_typemain_course,satisfaction_levelvery_satisfied,structure[opening, ingredient_analysis, texture_taste, packaging_quality, delivery_service, summary],min_length100,max_length180),TemplateConfig(template_idpro_002,styleprofessional,dish_typebeverage,satisfaction_levelsatisfied,structure[opening, recipe_analysis, flavor_balance, temperature_control, packaging_function, service_evaluation],min_length80,max_length140),# 极简风模板TemplateConfig(template_idmin_001,styleminimal,dish_typecombo,satisfaction_levelsatisfied,structure[quick_summary, highlight, minor_issue, overall],min_length30,max_length60),TemplateConfig(template_idmin_002,styleminimal,dish_typeany,satisfaction_levelvery_satisfied,structure[direct_praise, reason, emoji],min_length20,max_length45),# 创意风模板TemplateConfig(template_idcre_001,stylecreative,dish_typemain_course,satisfaction_levelvery_satisfied,structure[creative_opening, cross_analogy, taste_discovery, design_appreciation, experience_summary],min_length90,max_length160),TemplateConfig(template_idcre_002,stylecreative,dish_typedessert,satisfaction_levelsatisfied,structure[artistic_opening, visual_taste_link, packaging_art, surprise_element, creative_closing],min_length70,max_length130)]def _init_vocabulary_paths(self) - Dict[str, str]:初始化词汇库路径return {taste_descriptors: os.path.join(self.vocabulary_dir, taste_descriptors.json),packaging_terms: os.path.join(self.vocabulary_dir, packaging_terms.json),delivery_phrases: os.path.join(self.vocabulary_dir, delivery_phrases.json),service_expressions: os.path.join(self.vocabulary_dir, service_expressions.json),literary_images: os.path.join(self.vocabulary_dir, literary_images.json),humorous_expressions: os.path.join(self.vocabulary_dir, humorous_expressions.json)}def _create_directories(self):创建必要的目录directories [self.templates_dir, self.vocabulary_dir, self.data_dir]for directory in directories:if not os.path.exists(directory):os.makedirs(directory)def get_style_config(self, style: str) - Optional[StyleConfig]:获取风格配置return self.review_styles.get(style)def get_templates_by_style_and_dish(self, style: str, dish_type: str) - List[TemplateConfig]:根据风格和菜品类型获取模板return [t for t in self.templatesif t.style style and (t.dish_type dish_type or t.dish_type any)]def calculate_weighted_score(self, scores: Dict[str, float]) - float:计算加权综合评分weights self.dimension_weightsweighted_sum (scores.get(taste, 0) * weights.taste scores.get(packaging, 0) * weights.packaging scores.get(delivery, 0) * weights.delivery scores.get(service, 0) * weights.service)return min(100, max(0, weighted_sum))# 全局配置实例config SystemConfig()# 使用示例if __name__ __main__:print( 外卖评价智能生成器配置)print( * 50)# 显示所有评价风格print(\n 支持的评价风格:)for style_id, style_config in config.review_styles.items():print(f • {style_config.name} ({style_id}))print(f 特点: {, .join(style_config.characteristics)})print(f 适用: {, .join(style_config.suitable_scenes)})# 显示权重配置print(f\n⚖️ 评价维度权重:)weights config.dimension_weightsprint(f 口味: {weights.taste:.0%})print(f 包装: {weights.packaging:.0%})print(f 配送: {weights.delivery:.0%})print(f 服务: {weights.service:.0%})# 测试评分计算sample_scores {taste: 85, packaging: 70, delivery: 90, service: 80}weighted_score config.calculate_weighted_score(sample_scores)print(f\n 示例评分计算:)print(f 各维度得分: {sample_scores})print(f 加权总分: {weighted_score:.1f})3. experience_analyzer.py体验分析模块体验分析模块 - 分析和量化用户的用餐体验作者AI助手用途从多个维度分析外卖体验为文案生成提供数据支撑数字文化艺术创新创业课程项目import numpy as npfrom datetime import datetimefrom typing import Dict, List, Optional, Tuplefrom dataclasses import dataclass, fieldfrom collections import defaultdictfrom config import config, DishType, DimensionWeightsdataclassclass ExperienceDimensions:体验维度数据taste: Dict[str, any] field(default_factorydict) # 口味维度packaging: Dict[str, any] field(default_factorydict) # 包装维度delivery: Dict[str, any] field(default_factorydict) # 配送维度service: Dict[str, any] field(default_factorydict) # 服务维度# 综合评分overall_satisfaction: float 0.0dimension_scores: Dict[str, float] field(default_factorydict)# 亮点与不足highlights: List[str] field(default_factorylist)drawbacks: List[str] field(default_factorylist)class TasteAnalyzer:口味分析器def __init__(self):self.taste_dimensions [flavor_balance, # 味道平衡度aroma_intensity, # 香气浓度texture_feel, # 口感质地temperature_control, # 温度控制seasoning_accuracy, # 调味准确度aftertaste_duration # 回味持久度]# 味觉形容词映射self.flavor_adjectives {excellent: [惊艳, 绝妙, 层次丰富, 回味无穷, 恰到好处],good: [不错, 可口, 香醇, 清爽, 入味],average: [一般, 中规中矩, 尚可, 普通, 无功无过],poor: [欠佳, 寡淡, 过重, 偏咸, 不够新鲜]}self.texture_descriptions {excellent: [酥脆, 嫩滑, Q弹, 绵密, 爽口],good: [松软, 紧实, 温热, 湿润, 有嚼劲],average: [偏硬, 稍软, 不够热, 略干, 韧性一般],poor: [过硬, 过软, 凉了, 干涩, 难咀嚼]}def analyze(self, taste_input: Dict) - Dict:分析口味维度Args:taste_input: 用户输入的口味相关信息- overall_rating: 总体口味评分 1-10- flavor_notes: 味道描述- texture_notes: 口感描述- temperature_ok: 温度是否合适- freshness_ok: 新鲜度评价Returns:dict: 口味分析结果scores {}descriptions {}# 总体评分标准化overall_rating taste_input.get(overall_rating, 5)normalized_overall (overall_rating - 1) / 9 * 100 # 转换为0-100# 分析各子维度# 味道平衡度flavor_notes taste_input.get(flavor_notes, )if any(word in flavor_notes for word in [平衡, 协调, 层次, 丰富]):scores[flavor_balance] min(100, normalized_overall 10)descriptions[flavor_balance] self._get_flavor_description(excellent)elif any(word in flavor_notes for word in [偏, 重, 淡, 单调]):scores[flavor_balance] max(0, normalized_overall - 10)descriptions[flavor_balance] self._get_flavor_description(poor)else:scores[flavor_balance] normalized_overalldescriptions[flavor_balance] self._get_flavor_description(good)# 口感质地texture_notes taste_input.get(texture_notes, )if any(word in texture_notes for word in [酥脆, 嫩滑, Q弹, 绵密]):scores[texture_feel] min(100, normalized_overall 5)descriptions[texture_feel] self._get_texture_description(excellent)elif any(word in texture_notes for word in [硬, 软, 干, 凉]):scores[texture_feel] max(0, normalized_overall - 15)descriptions[texture_feel] self._get_texture_description(poor)else:scores[texture_feel] normalized_overalldescriptions[texture_feel] self._get_texture_description(good)# 温度控制if taste_input.get(temperature_ok, True):scores[temperature_control] 85 np.random.randint(-5, 10)descriptions[temperature_control] 温度适宜保持得很好else:scores[temperature_control] 40 np.random.randint(0, 20)descriptions[temperature_control] 温度有所流失影响口感# 新鲜度if taste_input.get(freshness_ok, True):scores[freshness] 90 np.random.randint(-5, 10)descriptions[freshness] 食材新鲜口感有保证else:scores[freshness] 35 np.random.randint(0, 25)descriptions[freshness] 新鲜度一般能感觉到些许差距# 计算口味综合得分valid_scores [s for s in利用AI解决实际问题如果你觉得这个工具好用欢迎关注长安牧笛