时间:2017.8.17
需求
分诊分析后台的需求如下:
- 增加AB Test模型结果的显示
- 增加性别判断的显示
- 增加细分关键词的显示
笔记
工程:tag_trace;项目:tagging
服务器用户:classify@docker01
项目位置:/home/classify/workspace/tag_trace
网页显示(admin.py):ProblemClassificationBadCaseAdmin类
模型样式(admin.py):ProblemClassificationBadCaseForm类
数据模型(models.py):ProblemClassificationBadCase类
数据与显示关联:
admin.site.register(ProblemClassificationBadCase, ProblemClassificationBadCaseAdmin)
数据获取(classification_bad_case_manager.py):build_problem_classification_info()
网站样式:tagging/templates
常量定义:
strong_keywords_clinics_dict:粗分关键词强相关科室
weak_keywords_clinics_dict:粗分关键词弱相关科室
fine_keywords_clinics_dict:细分关键词相关科室
数据模型:ProblemClassificationBadCase,继承于models.Model
,定义字段,部分数据存储于Json格式的detail变量中。
提取分诊数据的逻辑(classification_bad_case_manager.py):
- get_bad_case_safe() 和 get_or_create_bad_case_db():从数据库中,获得信息
- check_single_problem_classification():检查单个问题的分诊,写入单条检查(数据库),通过ProblemClassificationBadCase,调用RPC接口triage_second_for_debug()
- get_next_not_corrected_problem_classification_bad_case():导出多个“规则导入”的问题,随机选择一个
- get_problem_classification_info_by_id():根据problem_id获取
- build_problem_classification_info():创建问题分诊信息
- _filter_emoji_chars():过滤Emoji表情
分词的位置:ProblemClassificationBadCaseForm.schema:src_segment、des_segment
视图规则:views.py
视图URL:urls.py:将视图规则(views)替换为URL
网站的启停命令:
- 暂停服务: sh scripts/uwsgi/stop.sh
- 启动服务: sh scripts/uwsgi/start.sh
修改部分:
class ProblemClassificationBadCaseAdmin(VersionAdmin):
list_display = ("problem_id", "source", "corrected", "origin_clinic", "final_clinic", "manual_correction",
"created_time")
list_filter = ("source", "corrected")
fields = ("check_single", "new_clinic", "sex_age", "new_fine", "problem_id_link", "created_time", "first_question",
"has_image", "origin_clinic", "final_clinic", "manual_correction", "detail",
"corrected", "next_case")
readonly_fields = ("check_single", "new_clinic", "sex_age", "new_fine", "created_time", "first_question",
"has_image", "origin_clinic", "final_clinic", "manual_correction", "problem_id_link",
"next_case")
form = ProblemClassificationBadCaseForm
def new_clinic(self, obj):
"""
需要返回网页形式的文本
:return:
"""
text = json.loads(obj.detail).get('ab_clinic')
return u'<p target=_blank>{0}</p>'.format(text)
new_clinic.allow_tags = True
new_clinic.short_description = '分诊科室对比'
def sex_age(self, obj):
"""
需要返回网页形式的文本
:return:
"""
text = json.loads(obj.detail).get('sex_age')
return u'<p target=_blank>{0}</p>'.format(text)
sex_age.allow_tags = True
sex_age.short_description = '性别年龄'
def new_fine(self, obj):
"""
需要返回网页形式的文本
:return:
"""
text = json.loads(obj.detail).get('new_fine')
return u'<p target=_blank>{0}</p>'.format(text)
new_fine.allow_tags = True
new_fine.short_description = '新的细分'
分诊服务RPC修改:
修改problem_triage服务的adult_triage_predict_by_brnn_and_keywords_for_debug()接口;
在字典中添加:
字段:"ab_clinic": "新: 皮肤科 | 旧: 皮肤科";
字段:"sex_age": "用户性别: 女, 内容性别: , 年龄: 青年";
字段:"new_fine": "狗抓: 感染科(d)";
RPC命令:
sh control_lb.sh stop
sh scripts/sup_stop.sh
sh scripts/sup_start.sh
sh control_lb.sh start
网友评论