Python 根据一些验证计算分数,包括权重和所需的成功验证
我正在尝试实施一些我认为不太难但到目前为止还没有解决方案的东西 假设我有以下几点:Python 根据一些验证计算分数,包括权重和所需的成功验证,python,python-3.x,Python,Python 3.x,我正在尝试实施一些我认为不太难但到目前为止还没有解决方案的东西 假设我有以下几点: validations = dict( integrity_id_number = dict( fields = ['id_number'], weight = 25 ), integrity_doc_number = dict( fields = ['doc_number'], weight = 25 ), integrity_birth_date = dict( fie
validations = dict(
integrity_id_number = dict(
fields = ['id_number'],
weight = 25
),
integrity_doc_number = dict(
fields = ['doc_number'],
weight = 25
),
integrity_birth_date = dict(
fields = ['birth_date'],
weight = 5
),
integrity_expiry_date = dict(
fields = ['expiry_date'],
weight = 15
),
match_doc_number = dict(
fields = ['doc_number','number'],
weight = 10
),
match_name = dict(
fields = ['names','names'],
weight = 1
),
match_surname = dict(
fields = ['surnames','surname'],
weight = 1
),
match_gender = dict(
fields = ['gender','sex'],
weight = 3
),
expiration_date = dict(
fields = ['expiry_date'],
weight = 15
)
)
在这里,我只需运行此验证记录,并根据其结果将值“权重”添加到最终分数:
score = score + (validation_score / 100) * validation['weight']
但我需要更先进的东西:
- 有些验证必须成功,我需要知道,当其中一个验证失败时,它会反映在分数上,从分数中我必须知道整体验证是否通过
- 我向用户显示的最终分数必须在0-100之间,在这之前没有关系
- 有人告诉我应该在不同的字段上使用乘法器,我了解如何将概念转换为代码
验证中的数据。这将使我们更好地了解如何扩展它以获得附加功能。