Skip to content

Commit ffd9eb5

Browse files
committed
add mddoclink to data tutorial
1 parent 31205c4 commit ffd9eb5

File tree

3 files changed

+23
-85
lines changed

3 files changed

+23
-85
lines changed

docs/source/docs_utils/apiref.py

Lines changed: 0 additions & 66 deletions
This file was deleted.

docs/source/docs_utils/notebook.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ class DocumentationLink(ReplacePattern):
9898
@staticmethod
9999
def link_to_doc_page(
100100
page_type: Literal["api", "tutorial", "guide"],
101-
page: str,
102-
anchor: str | None = None,
101+
dotpath: str,
102+
obj: str | None = None,
103103
) -> str:
104104
"""
105105
Create a link to a documentation page.
@@ -111,18 +111,18 @@ def link_to_doc_page(
111111
- "tutorial" -- Tutorials
112112
- "guide" -- User guides
113113
114-
:param page:
115-
Name of the page without the common prefix.
114+
:param dotpath:
115+
Path to the index page in unix style.
116116
117-
So, to link to keywords, pass "script.core.keywords" as page (omitting the "chatsky" prefix).
117+
So, to link Dataset, pass "context" as page (omitting the "autointent" prefix).
118118
119119
To link to the basic script tutorial, pass "script.core.1_basics" (without the "tutorials" prefix).
120120
121121
To link to the basic concepts guide, pass "basic_conceptions".
122122
123123
API index pages are also supported.
124124
Passing "index_pipeline" will link to the "apiref/index_pipeline.html" page.
125-
:param anchor:
125+
:param obj:
126126
An anchor on the page. (optional)
127127
128128
For the "api" type, use only the last part of the linked object.
@@ -134,12 +134,14 @@ def link_to_doc_page(
134134
A link to the corresponding documentation part.
135135
"""
136136
if page_type == "api":
137-
prefix = "" if page.startswith("index") else "chatsky."
138-
return f"../apiref/{prefix}{page}.rst" + (f"#{prefix}{page}.{anchor}" if anchor is not None else "")
139-
if page_type == "tutorial":
140-
return f"../tutorials/tutorials.{page}.py" + (f"#{anchor}" if anchor is not None else "")
141-
if page_type == "guide":
142-
return f"../user_guides/{page}.rst" + (f"#{anchor}" if anchor is not None else "")
137+
path = "/".join(dotpath.split("."))
138+
return f"../autoapi/autointent/{path}/index.rst" + (
139+
f"#autointent.{dotpath}.{obj}" if obj is not None else ""
140+
)
141+
# if page_type == "tutorial":
142+
# return f"../tutorials/tutorials.{page}.py" + (f"#{anchor}" if anchor is not None else "")
143+
# if page_type == "guide":
144+
# return f"../guides/{page}.rst" + (f"#{anchor}" if anchor is not None else "")
143145
msg = "Unexpected page type"
144146
raise ValueError(msg)
145147

tutorials/data.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from autointent.context.data_handler import Dataset
1212

1313
# %%
14-
datasets.logging.disable_progress_bar() # disable tqdm outputs
14+
datasets.logging.disable_progress_bar() # disable tqdm outputs
1515

1616
# %% [markdown]
1717
"""
@@ -101,9 +101,9 @@
101101
```
102102
103103
- `name`: A human-readable representation of the intent.
104-
- `tags`: Used in multilabel scenarios to predict the most probable class listed in a specific tag.
105-
- `regexp_partial_match` and `regexp_full_match`: Used by the `RegExp` module to predict intents based on provided patterns.
106-
- `description`: Used by the `DescriptionScorer` to calculate scores based on the similarity between an utterance and intent descriptions.
104+
- `tags`: Used in multilabel scenarios to predict the most probable class listed in a specific %mddoclink(api,context.data_handler,Tag).
105+
- `regexp_partial_match` and `regexp_full_match`: Used by the %mddoclink(api,modules,RegExp) module to predict intents based on provided patterns.
106+
- `description`: Used by the %mddoclink(api,modules.scoring,DescriptionScorer) to calculate scores based on the similarity between an utterance and intent descriptions.
107107
108108
All fields in the `intents` list are optional except for `id`.
109109
"""
@@ -122,6 +122,8 @@
122122
# %% [markdown]
123123
"""
124124
### Creating a dataset from a Python dictionary
125+
126+
One can load data into Python using our %mddoclink(api,context.data_handler,Dataset) object.
125127
"""
126128

127129
# %%
@@ -203,7 +205,7 @@
203205

204206
# %% [markdown]
205207
"""
206-
The `Dataset` class organizes your data as a dictionary of splits (`str: datasets.Dataset`).
208+
The %mddoclink(api,context.data_handler,Dataset) class organizes your data as a dictionary of [datasets.Dataset](https://huggingface.co/docs/datasets/v2.1.0/en/package_reference/main_classes#datasets.Dataset).
207209
For example, after initialization, an `oos` key may be added if OOS samples are provided.
208210
In the case of the `banking77` dataset, only the `train` split is available, which you can access as shown below:
209211
"""
@@ -215,7 +217,7 @@
215217
"""
216218
### Working with dataset splits
217219
218-
Each split in the `Dataset` class is an instance of [datasets.Dataset](https://huggingface.co/docs/datasets/en/package_reference/main_classes#datasets.Dataset),
220+
Each split in the %mddoclink(api,context.data_handler,Dataset) class is an instance of [datasets.Dataset](https://huggingface.co/docs/datasets/en/package_reference/main_classes#datasets.Dataset),
219221
so you can work with them accordingly.
220222
"""
221223

@@ -230,7 +232,7 @@
230232
"""
231233

232234
# %%
233-
dataset.intents[0] # get intent (id=0)
235+
dataset.intents[0] # get intent (id=0)
234236

235237
# %% [markdown]
236238
"""

0 commit comments

Comments
 (0)