Skip to content

Commit

Permalink
📝 Add tutorials in the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoPerrier committed Dec 12, 2023
1 parent de2f039 commit 9434875
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions docs/tutorials/00_GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ A typical code for a melusine-based application looks like this :

```Python
--8<--
docs_src/GettingStarted/tutorial001.py:simple_pipeline
docs/docs_src/GettingStarted/tutorial001.py:simple_pipeline
--8<--
```

Expand Down Expand Up @@ -90,7 +90,7 @@ End users typically want to know what lead melusine to a specific detection resu

```Python
--8<--
docs_src/GettingStarted/tutorial002.py:debug_pipeline
docs/docs_src/GettingStarted/tutorial002.py:debug_pipeline
--8<--
```

Expand Down
12 changes: 6 additions & 6 deletions docs/tutorials/05a_MelusineDetectors.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ The next sections break down the different parts of the code.

```Python
--8<--
docs_src/MelusineDetectors/tutorial001.py:detector
docs/docs_src/MelusineDetectors/tutorial001.py:detector
--8<--
```

The detector is run on a simple dataframe:
```Python
--8<--
docs_src/MelusineDetectors/tutorial001.py:run
docs/docs_src/MelusineDetectors/tutorial001.py:run
--8<--
```

Expand All @@ -66,7 +66,7 @@ In the init method, you should call the superclass init and provide:

```Python
--8<--
docs_src/MelusineDetectors/tutorial001.py:detector_init
docs/docs_src/MelusineDetectors/tutorial001.py:detector_init
--8<--
```

Expand All @@ -80,7 +80,7 @@ The `pre_detect` method simply combines the header text and the body text
(separated by a line break).
```Python
--8<--
docs_src/MelusineDetectors/tutorial001.py:pre_detect
docs/docs_src/MelusineDetectors/tutorial002.py:pre_detect
--8<--
```

Expand All @@ -90,15 +90,15 @@ The `detect` applies two regexes on the selected text:
- A negative regex to avoid false positive detections
```Python
--8<--
docs_src/MelusineDetectors/tutorial001.py:detect
docs/docs_src/MelusineDetectors/tutorial002.py:detect
--8<--
```

## Detector post_detect
The `post_detect` combines the regex detection result to determine the final result.
```Python
--8<--
docs_src/MelusineDetectors/tutorial001.py:post_detect
docs/docs_src/MelusineDetectors/tutorial002.py:post_detect
--8<--
```

Expand Down
8 changes: 4 additions & 4 deletions docs/tutorials/05b_MelusineDetectorsAdvanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Populating this debug dict with debug info is then left to the user's responsibi
Exemple of a detector with debug data
```Python hl_lines="21 22 37-53"
--8<--
docs_src/MelusineDetectors/tutorial003.py:detector
docs/docs_src/MelusineDetectors/tutorial003.py:detector
--8<--
```

Expand Down Expand Up @@ -60,7 +60,7 @@ Otherwise, dataframe wise transformations are used.
Exemple of a Detector with dataframe wise method (works with a PandasBackend only).
```Python hl_lines="22 28 39"
--8<--
docs_src/MelusineDetectors/tutorial002.py:detector
docs/docs_src/MelusineDetectors/tutorial002.py:detector
--8<--
```

Expand All @@ -75,7 +75,7 @@ instead of the default `pre_detect`/`detect`/`post_detect`.

```Python
--8<--
docs_src/MelusineDetectors/tutorial004.py:detector
docs/docs_src/MelusineDetectors/tutorial004.py:detector
--8<--
```

Expand All @@ -88,7 +88,7 @@ The `transform` method will now call `prepare` and `run`.

```Python
--8<--
docs_src/MelusineDetectors/tutorial004.py:run
docs/docs_src/MelusineDetectors/tutorial004.py:run
--8<--
```

Expand Down
14 changes: 7 additions & 7 deletions docs/tutorials/06_Configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ Melusine components can be instantiated using parameters defined in configuratio
The `from_config` method accepts a `config_dict` argument
```Python
--8<--
docs_src/Configurations/tutorial001.py:from_config_dict
docs/docs_src/Configurations/tutorial001.py:from_config_dict
--8<--
```

or a `config_key` argument.
```Python
--8<--
docs_src/Configurations/tutorial001.py:from_config
docs/docs_src/Configurations/tutorial001.py:from_config
--8<--
```
When `demo_pipeline` is given as argument, parameters are read from the `melusine.config` object at key `demo_pipeline`.
Expand All @@ -21,7 +21,7 @@ When `demo_pipeline` is given as argument, parameters are read from the `melusin
The melusine configurations can be accessed with the `config` object.
```Python
--8<--
docs_src/Configurations/tutorial001.py:print_config
docs/docs_src/Configurations/tutorial001.py:print_config
--8<--
```

Expand All @@ -45,7 +45,7 @@ The configuration of the `demo_pipeline` can then be easily inspected.
The simplest way to modify configurations is to create a new directory directly.
```Python
--8<--
docs_src/Configurations/tutorial001.py:modify_conf_with_dict
docs/docs_src/Configurations/tutorial001.py:modify_conf_with_dict
--8<--
```

Expand All @@ -54,15 +54,15 @@ modifying the configurations on the fly.
Melusine lets you specify the path to a folder containing *yaml* files and loads them (the `OmegaConf` package is used behind the scene).
```Python
--8<--
docs_src/Configurations/tutorial001.py:modify_conf_with_path
docs/docs_src/Configurations/tutorial001.py:modify_conf_with_path
--8<--
```

When the `MELUSINE_CONFIG_DIR` environment variable is set, Melusine loads directly the configurations files located at
the path specified by the environment variable.
```Python
--8<--
docs_src/Configurations/tutorial001.py:modify_conf_with_env
docs/docs_src/Configurations/tutorial001.py:modify_conf_with_env
--8<--
```

Expand All @@ -76,7 +76,7 @@ It is advised to export the default configurations and then modify just the file

```Python
--8<--
docs_src/Configurations/tutorial001.py:export_config
docs/docs_src/Configurations/tutorial001.py:export_config
--8<--
```

Expand Down
14 changes: 7 additions & 7 deletions docs/tutorials/07_BasicClassification.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ In this tutorial we want to detect insatisfaction in an email dataset.
Let's create a basic dataset:
```Python
--8<--
docs_src/BasicClassification/tutorial001.py:create_dataset
docs/docs_src/BasicClassification/tutorial001.py:create_dataset
--8<--
```

Expand All @@ -40,7 +40,7 @@ The `transformers` library makes it really simple to use pre-trained models for

```Python
--8<--
docs_src/BasicClassification/tutorial001.py:transformers
docs/docs_src/BasicClassification/tutorial001.py:transformers
--8<--
```

Expand Down Expand Up @@ -73,31 +73,31 @@ Melusine uses the MelusineDetector template class to standardise how models are

```Python
--8<--
docs_src/BasicClassification/tutorial001.py:detector_init
docs/docs_src/BasicClassification/tutorial001.py:detector_init
--8<--
```

The `pre_detect` method assembles the text that we want to use for classification.

```Python
--8<--
docs_src/BasicClassification/tutorial001.py:pre_detect
docs/docs_src/BasicClassification/tutorial001.py:pre_detect
--8<--
```

The `detect` method runs the classification model on the text.

```Python
--8<--
docs_src/BasicClassification/tutorial001.py:detect
docs/docs_src/BasicClassification/tutorial001.py:detect
--8<--
```

The `post_detect` method applies a threshold on the prediction score to determine the detection result.

```Python
--8<--
docs_src/BasicClassification/tutorial001.py:post_detect
docs/docs_src/BasicClassification/tutorial001.py:post_detect
--8<--
```

Expand All @@ -109,7 +109,7 @@ Putting it all together, we run the detector on the input dataset.

```Python
--8<--
docs_src/BasicClassification/tutorial001.py:run
docs/docs_src/BasicClassification/tutorial001.py:run
--8<--
```

Expand Down

0 comments on commit 9434875

Please sign in to comment.