-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_json.py
More file actions
42 lines (38 loc) · 1.84 KB
/
generate_json.py
File metadata and controls
42 lines (38 loc) · 1.84 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
from faker import Faker
import json
import random
faker = Faker(locale = ['es_AR', 'es_CL', 'es_CO', 'es_ES', 'pt_BR'])
DATASET_LEN = 100
COMIDAS = ['Sopa', 'Ensalada', 'Salsa', 'Sandwich', 'Postre']
CATEGORIAS = ['Desayuno', 'Almuerzo', 'Merienda', 'Cena']
DIFICULTADES = ['Fácil', 'Medio', 'Difícil']
ETIQUETAS = ['Horno', 'Sartén', 'Microondas', 'Licuadora', 'Panificado', 'Pasta']
CARACTERISTICAS = ['Dulce', 'Salado', 'Frio', 'Caliente', 'Dulce', 'APPC', 'vegan', 'veggie']
recetas = [{
"nombre": random.choice(COMIDAS) + ' ' + faker.city(),
"descripción": faker.text(100),
"categoria": random.choice(CATEGORIAS),
"tiempo_preparación": random.randint(5, 180),
"dificultad": random.choice(DIFICULTADES),
"instrucciones": faker.text(200),
"imagen": faker.image_url(),
"ingredientes": [
{ "nombre": "Huevos", "cantidad": random.randint(1, 3), "unidad": "Unidad/es" },
{ "nombre": "Harina", "cantidad": random.randint(100, 500), "unidad": "g" },
{ "nombre": "Agua", "cantidad": random.randint(100, 500), "unidad": "ml" },
],
"rendimiento": [
{ "cantidad": random.randint(1, 3), "unidad": "Porción/es" },
{ "cantidad": random.randint(100, 500), "unidad": "g", "texto": str(random.randint(100, 500)) + 'g' }
],
"etiquetas": [
{ "tipo": random.choice(ETIQUETAS), "valor": faker.null_boolean() },
{ "tipo": random.choice(ETIQUETAS), "valor": faker.null_boolean(), "texto": faker.text(20) }
],
"caracteristicas": [
{ "tipo": random.choice(CARACTERISTICAS), "valor": faker.null_boolean(), "texto": faker.text(20) },
{ "tipo": random.choice(CARACTERISTICAS), "valor": faker.null_boolean(), "texto": faker.text(20) }
]
} for _ in range(DATASET_LEN)]
with open('recetasDeCocina.json', "w", encoding="utf-8") as file:
file.write(json.dumps(recetas))