espnet3.utils.config_utils.load_line
Less than 1 minute
espnet3.utils.config_utils.load_line
espnet3.utils.config_utils.load_line(path)
Load lines from a text file and return as a list of strings.
This function is used as a custom resolver in OmegaConf, allowing YAML files to reference external text line files dynamically via ${load_line:some/file.txt}.
This resolver is intended to load vocab file in configuration.
- Parameters:path (str or Path) – Path to the file.
- Returns: A list of stripped lines from the file.
- Return type: List[str]
- Raises:
- FileNotFoundError – If
pathdoes not exist. - PermissionError – If the file cannot be read.
- FileNotFoundError – If
Example
>>> from omegaconf import OmegaConf
>>> cfg = OmegaConf.create({"vocab": "${load_line:tokens.txt}"})