Spaces:
Sleeping
Sleeping
Create trust.py
Browse files- nlp/trust.py +23 -0
nlp/trust.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .detectors import (
|
| 2 |
+
disclaimer_present, disclaimer_position, risk_confidence_ratio,
|
| 3 |
+
overconfidence_hits, conflict_terms_present
|
| 4 |
+
)
|
| 5 |
+
|
| 6 |
+
def score(text: str):
|
| 7 |
+
dp = disclaimer_present(text)
|
| 8 |
+
pos = disclaimer_position(text)
|
| 9 |
+
early = 1 if pos == 'start' else 0
|
| 10 |
+
rcr = risk_confidence_ratio(text)
|
| 11 |
+
over = overconfidence_hits(text)
|
| 12 |
+
conflict = conflict_terms_present(text)
|
| 13 |
+
|
| 14 |
+
sub = 0.4*dp + 0.2*early + 0.2*min(1.0, rcr) - 0.2*(1 if over>0 else 0) - 0.1*conflict
|
| 15 |
+
sub = max(0.0, min(1.0, sub))
|
| 16 |
+
return {
|
| 17 |
+
'subscore': sub,
|
| 18 |
+
'disclaimer_present': dp,
|
| 19 |
+
'disclaimer_early': early,
|
| 20 |
+
'risk_confidence_ratio': rcr,
|
| 21 |
+
'overconfidence_hits': over,
|
| 22 |
+
'conflict_terms_present': conflict,
|
| 23 |
+
}
|