-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculate.py
97 lines (88 loc) · 4.51 KB
/
calculate.py
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
from filemanager import *
from dictionary import *
from persona import *
from dog import *
from synonyms import *
import operator
#Read data from json
razas = readJson()
pesoGrande = 25
alturaGrande = 40
pesoPequeño = 15
alturaPequeño = 30
def recomendedDog(persona: Persona) -> Dog:
for raza in razas:
raza.compatibility = 0
if persona.get_hogar().get_tipo == "house":
if not persona.get_hogar().get_jardin:
if (raza.weight > pesoPequeño and raza.weight < pesoGrande) and (raza.height > alturaPequeño and raza.height < alturaGrande):
raza.compatibility += 1
elif raza.weight > pesoGrande or raza.height > alturaGrande:
raza.compatibility += 0.75
elif raza.weight < pesoPequeño or raza.height < alturaPequeño:
raza.compatibility += 0.75
else:
if (raza.weight > pesoPequeño and raza.weight < pesoGrande) and (raza.height > alturaPequeño and raza.height < alturaGrande):
raza.compatibility += 0.75
elif raza.weight > pesoGrande or raza.height > alturaGrande:
raza.compatibility += 1
elif raza.weight < pesoPequeño or raza.height < alturaPequeño:
raza.compatibility += 0.5
elif persona.get_hogar().get_tipo() == "apartment":
if not persona.get_hogar().get_terraza:
if (raza.weight > pesoPequeño and raza.weight < pesoGrande) and (raza.height > alturaPequeño and raza.height < alturaGrande):
raza.compatibility += 0.75
elif raza.weight < pesoPequeño or raza.height < alturaPequeño:
raza.compatibility += 1
else:
if (raza.weight > pesoPequeño and raza.weight < pesoGrande) and (raza.height > alturaPequeño and raza.height < alturaGrande):
raza.compatibility += 1
elif raza.weight > pesoGrande or raza.height > alturaGrande:
raza.compatibility += 0.5
elif raza.weight < pesoPequeño or raza.height < alturaPequeño:
raza.compatibility += 0.75
if persona.get_tamaño() == "L" and (raza.weight > pesoGrande or raza.height > alturaGrande):
raza.compatibility += 0.7
elif persona.get_tamaño() == "M" and (raza.weight > pesoPequeño and raza.weight < pesoGrande) and (raza.height > alturaPequeño and raza.height < alturaGrande):
raza.compatibility += 0.7
elif persona.get_tamaño() == "S" and (raza.weight < pesoPequeño or raza.height < alturaPequeño):
raza.compatibility += 0.7
for adj in raza.temperament:
valor = 1 / len(raza.temperament)
if adj in filtro["hours"] and persona.get_horas() > 5:
raza.compatibility += float(valor*1.5)
if adj in filtro["childrens"] and persona.get_niños():
raza.compatibility += float(valor*1.3)
if adj in filtro["disability"] and persona.get_discapacidad():
raza.compatibility += float(valor*1.5)
if persona.get_finalidad() == "disability":
raza.compatibility += float(valor*1.5)
if adj in filtro["pets"] and persona.get_mascotas():
raza.compatibility += float(valor*1.3)
if adj in filtro["sports"] and persona.get_deporte():
raza.compatibility += float(valor*1.2)
if adj in persona.get_caracter():
raza.compatibility += float(valor)
if persona.get_finalidad() != "disability":
for finalidad in dog_for[persona.get_finalidad()]:
if finalidad in raza.bredFor:
raza.compatibility += 1
else:
if raza.name in dog_for[persona.get_finalidad()]:
raza.compatibility += 1
frase = persona.get_finalidad().lower().split()
for palabra in frase:
especialidad = raza.bredFor.lower()
if especialidad.find(palabra.lower()) > -1:
raza.compatibility += 0.5
raza.compatibility = round(raza.compatibility,2)
razas.sort(key=operator.attrgetter("compatibility"),reverse=True)
print(razas[0])
print(razas[1])
print(razas[2])
print(razas[3])
print(razas[4])
print(razas[5])
print(razas[6])
print(razas[7])
return razas[0]