-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfrontFormating.py
More file actions
70 lines (66 loc) · 2.39 KB
/
Copy pathfrontFormating.py
File metadata and controls
70 lines (66 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#
# frontFormating.py
#
# Collection of function to handle web formating and
# related needs of the front end.
#
def get_sketchyLevel(score):
"""Returns the sketchy labels"""
label = []
if score>=0.65:
label = ['btn btn-danger btn-mini', 'Sketchy']
elif score<=0.40:
label = ['btn btn-success btn-mini', 'Seems Legit']
else:
label = ['btn btn-warning btn-mini', 'Hard to tell']
return label[0], label[1]
def get_hint(feature_row):
"""
Returns the hint that is to be printed when hovering
over the risk assessment button
"""
hint_string = ''
## Hint row 1: Price/nbr ##
nprice_diff = feature_row[-1]
if nprice_diff>0:
hint_string = '<font color="green">%d%% greater </font> than the median ' \
% int(nprice_diff*100)
elif nprice_diff<0:
hint_string = '<font color="red">%d%% less </font> than the median' \
% int(nprice_diff*100)
else:
hint_string = '<i class="icon-remove"></i> \
<font color="red">Price</font>'
## Hint row 2: Address ##
if feature_row[0]:
hint_string += '<br><i class="icon-ok"></i> \
<font color="green">Address</font>'
else:
hint_string += '<br><i class="icon-remove"></i> \
<font color="red">Address</font>'
## Hint row 3: Phone number ##
if feature_row[1]:
hint_string += '<br><i class="icon-ok"></i> \
<font color="green">Phone</font>'
else:
hint_string += '<br><i class="icon-remove"></i> \
<font color="red">Phone</font>'
## Hint row 4: Frac of cap letters ##
if int(feature_row[4]*100)>7:
hint_string += '<br><font color="red">%d%% of capital letters</font>' \
% int(feature_row[4]*100)
else:
hint_string += '<br><font color="green">%d%% of capital letters</font>' \
% int(feature_row[4]*100)
## Hint row 5: Number of words ##
hint_string += '<br>%d words' \
% int(feature_row[5])
"""
if int(feature_row[5]*100)>80:
hint_string += '<br><font color="red">%d words</font>' \
% int(feature_row[5])
else:
hint_string += '<br><font color="green">%d words</font>' \
% int(feature_row[5])
"""
return hint_string