-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtransformers.py
More file actions
151 lines (125 loc) · 3.5 KB
/
transformers.py
File metadata and controls
151 lines (125 loc) · 3.5 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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env python3
import random
import numpy as np
def anonimize(s):
letras = list(s)
random.shuffle(letras)
result = ''.join(letras)
if ' ' in result:
return ' '.join([
_.capitalize()
for _ in result.split()
])
return result
def get_codigo_menu(menu):
# OMNI = '1'
# VEG = '2'
# CELIACO = '3'
OMNI = '✱'
VEG = '▼'
CELIACO = '©'
return {
'Celiaco': CELIACO,
'Sin restricciones. | Celiaco': CELIACO,
'Sin restricciones. | Vegetariano': VEG,
'Sin restricciones.': OMNI,
'Vegano | Vegetariano': VEG,
'Vegano': VEG,
'Vegano. | Especial Celiaco | Vegetariano': CELIACO,
'Vegano. | Vegetariano': VEG,
'Vegano | Vegetariano': VEG,
'Vegetariano | Celiaco': CELIACO,
'Vegetariano': VEG,
}.get(menu)
def get_pronombre(pronombre):
return {
'él': 'él',
'ella': 'ella',
'elle': 'elle',
'otro': 'otro',
}.get(pronombre, '')
def get_talla_camisa(camisa):
CODIGO_SIN_CAMISA = '0'
CODIGO_XS = '1'
CODIGO_S = '2'
CODIGO_M = '3'
CODIGO_L = '4'
CODIGO_XL = '5'
CODIGO_XXL = '6'
CODIGO_3XL = '7'
return {
'No quiero camiseta, prefiero el regalo alternativo.': CODIGO_SIN_CAMISA,
'XS': CODIGO_XS,
'S': CODIGO_S,
'M': CODIGO_M,
'L': CODIGO_L,
'XL': CODIGO_XL,
'XXL': CODIGO_XXL,
'3XL': CODIGO_3XL,
}.get(camisa)
def get_empresa(empresa):
if empresa is np.nan:
return ''
if empresa:
return str(empresa).strip()
return ''
FIXES = {
'Aaron': 'Aarón',
'Abadia': 'Abadía',
'Alvaro': 'Álvaro',
'Calderon': 'Calderón',
'Dominguez': 'Domínguez',
'Fernandez': 'Fernández',
'Hernandez': 'Hernández',
'Garcia': 'García',
'Gomez': 'Gómez',
'Gonzalez': 'González',
'Jimenez': 'Jiménez',
'Jose': 'José',
'Lopez': 'López',
'Maria': 'María',
'Martin': 'Martín',
'Martinez': 'Martínez',
'Jesus': 'Jesús',
'Perez': 'Pérez',
'Ramon': 'Ramón',
'Rodriguez': 'Rodríguez',
'Roman': 'Román',
'Ruben': 'Rubén',
'Sanchez': 'Sánchez',
'Simon': 'Simón',
'Suarez': 'Suárez',
'Vazquez': 'Vázquez',
'Verdu': 'Verdú',
}
def fix(texto):
texto = texto.replace('a\u0301', 'á')
texto = texto.replace('A\u0301', 'Á')
texto = texto.replace('e\u0301', 'é')
texto = texto.replace('E\u0301', 'É')
texto = texto.replace('i\u0301', 'í')
texto = texto.replace('I\u0301', 'Í')
texto = texto.replace('o\u0301', 'ó')
texto = texto.replace('O\u0301', 'Ó')
texto = texto.replace('u\u0301', 'ú')
texto = texto.replace('U\u0301', 'Ú')
texto = texto.strip().capitalize()
return FIXES.get(texto, texto)
def get_fixed(nombre):
nombre = nombre.strip()
words = [fix(_) for _ in nombre.split()]
return ' '.join(words)
# def split_apellidos(apellidos):
# apellidos = apellidos.strip()
# if ' ' not in apellidos:
# return (fix(apellidos), '')
# space_in = apellidos.index(' ')
# if space_in < 4:
# primer_apellido, segundo_apellido = apellidos.rsplit(maxsplit=1)
# else:
# primer_apellido, segundo_apellido = apellidos.split(maxsplit=1)
# return fix(primer_apellido), fix(segundo_apellido)
# def get_primer_apellido(s):
# return split_apellidos(s)[0]
# def get_segundo_apellido(s):
# return split_apellidos(s)[1]