> This page is for version 0.7.0.
> For other versions, use one of these documentation indexes:
> - Main (default): https://docs.nvidia.com/nemo/gym/main/llms.txt
> - 0.7.0: https://docs.nvidia.com/nemo/gym/v0.7.0/llms.txt
> - 0.6.0: https://docs.nvidia.com/nemo/gym/v0.6.0/llms.txt
> - 0.5.1: https://docs.nvidia.com/nemo/gym/v0.5.1/llms.txt
> - 0.5.0: https://docs.nvidia.com/nemo/gym/v0.5.0/llms.txt
> - 0.4.0: https://docs.nvidia.com/nemo/gym/v0.4.0/llms.txt
> - 0.3.0: https://docs.nvidia.com/nemo/gym/v0.3.0/llms.txt
> - 0.2.1: https://docs.nvidia.com/nemo/gym/v0.2.1/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/gym/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/gym/_mcp/server.

# nemo_gym.utils.text

Text helpers for user-facing messages.

## Module Contents

### Functions

| Name                                                        | Description                                                                                             |
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| [`_hydra_parses_to`](#nemo_gym-utils-text-_hydra_parses_to) | Whether Hydra's override grammar reads `text` back as exactly `expected`, type included.                |
| [`did_you_mean`](#nemo_gym-utils-text-did_you_mean)         | A ` Did you mean \`X\`?`fragment for the closest candidate to`value`, or `""\` if none is close enough. |
| [`hydra_literal`](#nemo_gym-utils-text-hydra_literal)       | `value` as an override value that Hydra parses back to the same value and type.                         |
| [`hydra_quote`](#nemo_gym-utils-text-hydra_quote)           | Single-quote `value` as a literal for Hydra's override grammar, so it parses back to the same string.   |

### API

```python
nemo_gym.utils.text._hydra_parses_to(
    text: str,
    expected: typing.Any
) -> bool
```

Whether Hydra's override grammar reads `text` back as exactly `expected`, type included.

```python
nemo_gym.utils.text.did_you_mean(
    value: str,
    candidates: typing.Iterable[str]
) -> str
```

A ` Did you mean \`X\`?`fragment for the closest candidate to`value`, or `""\` if none is close enough.

```python
nemo_gym.utils.text.hydra_literal(
    value: typing.Any
) -> str
```

`value` as an override value that Hydra parses back to the same value and type.

A string is written as it is when Hydra reads it back unchanged, and as a quoted literal otherwise, so
`"1"` stays a string and `nightly(run)` survives the grammar. The check is Hydra's own parser, not a guess
at its rules. Numbers, booleans, null and lists of those are written in their own syntax; anything else
raises `ValueError`.

```python
nemo_gym.utils.text.hydra_quote(
    value: str
) -> str
```

Single-quote `value` as a literal for Hydra's override grammar, so it parses back to the same string.

`json.dumps` is not that encoder: Hydra keeps `\uXXXX`, `\t` and a doubled backslash literally, so a Unicode
or backslash-containing filename would reach the command under another name. Hydra un-escapes a backslash
only when its run ends at a quote character, so only those runs (and the quote itself) are escaped here.
Everything else, Unicode included, is passed through unchanged.