0.1.35 • Published 7 years ago
pg-english v0.1.35
pg-english
Convert english query to informal.
NOTE: pg-slang can convert informal SQL to formal SQL.
var english = require('pg-english');
// english.token([type], [value]): token
// english.number(<text>): processed text
// english.unit(<text>): processed text
// english.reserved(<text>): processed text
// english.entity(<text>, <match fn>, [this]): Promise (processed text)
// english(<text>, <match fn>, [this], [options])
// -> Promise (processed text)
// <match fn>(<texts>)
// - texts: array of text
// -> Promise {type, value, length}
// - type: token type (table/column/row)
// - value: token value
// - hint: token hint (identifies table)
// - length: token length (from start of texts)
// options: {
// table: undefined, // default table: none
// columns: {<table>: []}, // default columns per table: none
// }
function match(txts) {
var z = null, txt = txts.join(' ');
if(txt.startsWith('ascorbic acid')) z = {type: 'column', value: 'ASCORBIC ACID', length: 2};
else if(txt.startsWith('food')) z = {type: 'table', value: 'FOOD', length: 1};
return Promise.resolve(z);
};
await english('show food with ascorbic acid less than twenty nine mg', match);
// SELECT "ASCORBIC ACID" FROM "FOOD" WHERE ("ASCORBIC ACID" < 0.029)
Methods:
0.1.35
7 years ago
0.1.34
7 years ago
0.1.33
7 years ago
0.1.32
7 years ago
0.1.31
7 years ago
0.1.30
7 years ago
0.1.29
7 years ago
0.1.28
7 years ago
0.1.27
7 years ago
0.1.26
7 years ago
0.1.25
7 years ago
0.1.24
7 years ago
0.1.23
7 years ago
0.1.22
7 years ago
0.1.21
7 years ago
0.1.20
7 years ago
0.1.19
7 years ago
0.1.18
7 years ago
0.1.17
7 years ago
0.1.16
7 years ago
0.1.15
7 years ago
0.1.14
7 years ago
0.1.13
7 years ago
0.1.12
7 years ago
0.1.11
7 years ago
0.1.10
7 years ago
0.1.9
7 years ago
0.1.8
7 years ago
0.1.7
7 years ago
0.1.6
7 years ago
0.1.5
7 years ago
0.1.4
7 years ago
0.1.3
7 years ago
0.1.2
7 years ago
0.1.1
7 years ago
0.1.0
7 years ago
0.0.14
7 years ago
0.0.13
7 years ago
0.0.12
7 years ago
0.0.11
7 years ago
0.0.10
7 years ago
0.0.9
7 years ago
0.0.8
7 years ago
0.0.7
7 years ago
0.0.6
7 years ago
0.0.5
7 years ago
0.0.4
7 years ago
0.0.2
7 years ago
0.0.1
7 years ago