MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / parseRecords

Function parseRecords

intent-classifier/training/raw_to_csv.js:30–47  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

28const {loadJSON} = require('./util');
29
30function parseRecords(data) {
31 const result = [];
32 const intentStr = Object.keys(data)[0];
33 const entries = data[intentStr];
34 entries.forEach(entry => {
35 const data = entry.data;
36 const queryText = data.reduce((memo, curr) => {
37 return memo.concat(curr.text);
38 }, '');
39
40 result.push({
41 query: queryText,
42 intent: intentStr,
43 });
44 });
45
46 return result;
47}
48
49function writeCSV(data, path) {
50 const csvStr = dsv.csvFormat(data, ['query', 'intent']);

Callers 1

runFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected