Skip to content

Commit

Permalink
Merge pull request #60 from mminchev/file-names
Browse files Browse the repository at this point in the history
Adding support for custom dataset file names
  • Loading branch information
rodrigopivi authored Feb 10, 2019
2 parents eb10ea9 + 9546704 commit 5f73f8f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
10 changes: 6 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Use the default format if you plan to train a custom model or if you are writtin
Custom entities like 'context', 'required' and 'type' will be available at the output so you can handle this custom arguments as you want.

#### [Rasa NLU](https://rasa.com/docs/nlu/)
[Rasa NLU](https://rasa.com/docs/nlu/) is a great open source framework for training NLU models.
[Rasa NLU](https://rasa.com/docs/nlu/) is a great open source framework for training NLU models.
One particular behavior of the Rasa adapter is that when a slot definition sentence only contains one alias, the generated rasa dataset will map the alias as a synonym. e.g.:

```
Expand Down Expand Up @@ -106,13 +106,15 @@ The generated dataset should be available next to your definition file.
Here is the full npm generator options:
```
npx chatito <pathToFileOrDirectory> --format=<format> --formatOptions=<formatOptions> --outputPath=<outputPath>
npx chatito <pathToFileOrDirectory> --format=<format> --formatOptions=<formatOptions> --outputPath=<outputPath> --trainingFileName=<trainingFileName> --testingFileName=<testingFileName>
```
- `<pathToFileOrDirectory>` path to a `.chatito` file or a directory that contains chatito files. If it is a directory, will search recursively for all `*.chatito` files inside and use them to generate the dataset. e.g.: `lightsChange.chatito` or `./chatitoFilesFolder`
- `<format>` Optional. `default`, `rasa` or `snips`
- `<formatOptions>` Optional. Path to a .json file that each adapter optionally can use
- `<outputPath>` Optional. The directory where to save the generated dataset. Uses the current directory as default.
- `<outputPath>` Optional. The directory where to save the generated datasets. Uses the current directory as default.
- `<trainingFileName>` Optional. The name of the generated training dataset file. Do not forget to add a .json extension at the end. Uses `<format>`_dataset_training.json as default file name.
- `<testingFileName>` Optional. The name of the generated testing dataset file. Do not forget to add a .json extension at the end. Uses `<format>`_dataset_testing.json as default file name.
### Author and maintainer
Rodrigo Pimentel
Rodrigo Pimentel
12 changes: 8 additions & 4 deletions src/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ const adapterAccumulator = (format: 'default' | 'rasa' | 'snips', formatOptions?
if (!fs.existsSync(outputPath)) {
fs.mkdirSync(outputPath);
}
const trainingJsonFilePath = path.resolve(outputPath, `${format}_dataset_training.json`);

const trainingJsonFileName = argv.trainingFileName || `${format}_dataset_training.json`;
const trainingJsonFilePath = path.resolve(outputPath, trainingJsonFileName);
fs.writeFileSync(trainingJsonFilePath, JSON.stringify(trainingDataset));
// tslint:disable-next-line:no-console
console.log(`Saved training dataset: ./${format}_dataset_training.json`);
console.log(`Saved training dataset: ${trainingJsonFilePath}`);

if (Object.keys(testingDataset).length) {
const testingJsonFilePath = path.resolve(outputPath, `${format}_dataset_testing.json`);
const testingFileName = argv.testingFileName || `${format}_dataset_testing.json`;
const testingJsonFilePath = path.resolve(outputPath, testingFileName);
fs.writeFileSync(testingJsonFilePath, JSON.stringify(testingDataset));
// tslint:disable-next-line:no-console
console.log(`Saved testing dataset: ./${format}_dataset_testing.json`);
console.log(`Saved testing dataset: ${testingJsonFilePath}`);
}
}
};
Expand Down

0 comments on commit 5f73f8f

Please sign in to comment.