How to use the thingtalk.SentenceGenerator function in thingtalk

To help you get started, we’ve selected a few thingtalk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stanford-oval / almond-cloud / scripts / gen_sentences.js View on Github external
dest: 'debug',
        help: 'Enable debugging.',
    });

    const args = parser.parseArgs();
    const options = {
        rng: seedrandom.alea('almond is awesome'),
        language: 'en',
        targetLanguage: 'thingtalk',
        thingpediaClient: new AdminThingpediaClient(args.language),
        turkingMode: args.turking,
        maxDepth: args.maxdepth,
        debug: args.debug
    };

    const generator = new ThingTalk.SentenceGenerator(options);
    const transform = new stream.Transform({
        writableObjectMode: true,
        
        transform(ex, encoding, callback) {
            callback(null, 'S' + ex.id + '\t' + ex.utterance + '\t' + ex.target_code + '\n');
        },
        
        flush(callback) {
            process.nextTick(callback);
        }
    });

    generator.pipe(transform).pipe(args.output);
    args.output.on('finish', () => process.exit());
}
return main();