Skip to content

Commit 38eae51

Browse files
committed
Add a story for "Recipes generation".
1 parent d82eccd commit 38eae51

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

assets/recipes_generation.ru.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ _<small>➔ вывод:</small>_
319319
> instructions: Toss ingredients lightly and spoon into a buttered baking dish. Top with additional crushed cracker crumbs, and brush with melted butter. Bake in a preheated at 350 degrees oven for 25 to 30 minutes or until delicately browned.
320320
> ```
321321
322-
Let's count the total number of examples after we merged the files:
322+
Давайте посчитаем общее количество рецептов после слияния файлов с данными:
323323
324324
```python
325325
print('Total number of raw examples: ', len(dataset_raw))
@@ -331,13 +331,11 @@ _<small>➔ вывод:</small>_
331331
> Total number of raw examples: 125164
332332
> ```
333333
334-
## Preprocessing the dataset
334+
## Предварительная обработка набора данных
335335
336-
### Filtering out incomplete examples
336+
### Отфильтровываем неполные рецепты
337337
338-
It is possible that some recipes don't have some required fields (_name_, _ingredients_ or _instructions_). We need to clean our dataset from those incomplete examples.
339-
340-
The following function will help us filter out recipes which don't have either title or ingredients or instructions:
338+
Возможно, что некоторые рецепты не имеют обязательных полей (_name_, _ingredients_ или _instructions_). Нам необходимо очистить наш набор данных от этих неполных рецептов. Следующая функция поможет нам это сделать:
341339
342340
```python
343341
def recipe_validate_required_fields(recipe):
@@ -356,7 +354,7 @@ def recipe_validate_required_fields(recipe):
356354
return True
357355
```
358356
359-
Let's do the filtering now using `recipe_validate_required_fields()` function:
357+
Теперь воспользуемся функцией `recipe_validate_required_fields()` для фильтрации неполных рецептов:
360358

361359
```python
362360
dataset_validated = [recipe for recipe in dataset_raw if recipe_validate_required_fields(recipe)]
@@ -374,13 +372,13 @@ _<small>➔ вывод:</small>_
374372
> Number of incomplete recipes 2226
375373
> ```
376374
377-
As you may see among `125164` recipes we had `2226` somehow incomplete.
375+
Как вы можете увидеть, из `125164` рецептов `2226` были неполными.
378376
379-
### Converting recipes objects into strings
377+
### Конвертирование рецептов из объектов в строки
380378
381-
RNN doesn't understand objects. Therefore, we need to convert recipes objects to string and then to numbers (indices). Let's start with converting recipes objects to strings.
379+
RNN не умеет работать с объектами, она понимает только числа. Поэтому нам нужно сначала преобразовывать наши рецепты из объектов в строки, а затем в числа (индексы). Начнем с преобразования рецептов в строки.
382380
383-
To help our RNN learn the structure of the text faster let's add 3 "landmarks" to it. We will use these unique "title", "ingredients" and "instruction" landmarks to separate the logic sections of each recipe.
381+
Чтобы RNN было легче распознать секции (имя, ингредиенты и шаги приготовления) в тексте рецептов, мы можем расставить уникальные "маячки" или "ориентиры", которые будут разделять эти секции.
384382
385383
```python
386384
STOP_WORD_TITLE = '📗 '
@@ -390,9 +388,11 @@ STOP_WORD_INSTRUCTIONS = '\n📝\n\n'
390388
391389
The following function converts the recipe object to a string (sequence of characters) for later usage in RNN input.
392390

391+
Следующая функция преобразует объект в строку (последовательность символов) для последующего использования на входе RNN.
392+
393393
```python
394394
def recipe_to_string(recipe):
395-
# This string is presented as a part of recipes so we need to clean it up.
395+
# Эта рекламная строка присутсвует в рецептах, поэтому нам необходимо ее очистить.
396396
noize_string = 'ADVERTISEMENT'
397397

398398
title = recipe['title']
@@ -414,7 +414,7 @@ def recipe_to_string(recipe):
414414
return f'{STOP_WORD_TITLE}{title}\n{STOP_WORD_INGREDIENTS}{ingredients_string}{STOP_WORD_INSTRUCTIONS}{instructions_string}'
415415
```
416416

417-
Let's apply `recipe_to_string()` function to `dataset_validated`:
417+
Применяем функцию `recipe_to_string()` к `dataset_validated`:
418418

419419
```python
420420
dataset_stringified = [recipe_to_string(recipe) for recipe in dataset_validated]
@@ -428,7 +428,7 @@ _<small>➔ вывод:</small>_
428428
> Stringified dataset size: 122938
429429
> ```
430430
431-
Let's preview first several recipes:
431+
Давайте выведем первые несколько рецептов:
432432
433433
```python
434434
for recipe_index, recipe_string in enumerate(dataset_stringified[:3]):
@@ -502,7 +502,7 @@ _<small>➔ вывод:</small>_
502502
> ▪︎ Bake in preheated oven for 1 hour or until juices are clear.
503503
> ```
504504
505-
Just out of curiosity let's preview the recipe somewhere from the middle of the dataset to see that it has expected data structure:
505+
Исключительно из любопытства давайте просмотрим на рецепт где-то из середины набора данных, чтобы увидеть, что он имеет ожидаемую структуру:
506506
507507
```python
508508
print(dataset_stringified[50000])
@@ -542,7 +542,7 @@ _<small>➔ вывод:</small>_
542542
> ▪︎ Add white beans and stock and simmer, covered, stirring occasionally, 10 minutes. Add haricots verts and edamame and simmer, uncovered, until heated through, 2 to 3 minutes. Add butter, parsley, and chervil (if using) and stir gently until butter is melted. Discard bay leaf and rosemary sprigs.
543543
> ```
544544
545-
### Filtering out large recipes
545+
### Отфильтровываем большие рецепты
546546
547547
Recipes have different lengths. We need to have one _hard-coded sequence length_ limit before feeding recipe sequences to RNN. We need to find out what recipe length will cover most of the recipe use-cases and at the same time we want to keep it as small as possible to speed up the training process.
548548

0 commit comments

Comments
 (0)