{"id":19718943,"url":"https://github.com/nodef/pg-english","last_synced_at":"2025-02-27T17:35:16.434Z","repository":{"id":52079043,"uuid":"135931378","full_name":"nodef/pg-english","owner":"nodef","description":"English interface to PostgreSQL.","archived":false,"fork":false,"pushed_at":"2021-05-07T18:16:22.000Z","size":33,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-15T23:03:27.749Z","etag":null,"topics":["database","english","interface","language","natural","nlidb","nlp","pg","postgresql","processing"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/pg-english","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nodef.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-03T18:50:27.000Z","updated_at":"2023-02-24T02:47:43.000Z","dependencies_parsed_at":"2022-08-26T01:10:30.265Z","dependency_job_id":null,"html_url":"https://github.com/nodef/pg-english","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fpg-english","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fpg-english/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fpg-english/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fpg-english/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nodef","download_url":"https://codeload.github.com/nodef/pg-english/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240893833,"owners_count":19874689,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","english","interface","language","natural","nlidb","nlp","pg","postgresql","processing"],"created_at":"2024-11-11T23:02:17.768Z","updated_at":"2025-02-27T17:35:16.392Z","avatar_url":"https://github.com/nodef.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pg-english\n\n[![pg-english](https://i.imgur.com/UN74CCi.jpg)](https://npmjs.com/package/pg-english)\n\nConvert [english query] to [informal] [SQL SELECT].\n\u003e NOTE: [pg-slang] can convert informal SQL to formal SQL.\n\n```javascript\nvar english = require('pg-english');\n// english.token([type], [value]): token\n// english.number(\u003ctext\u003e): processed text\n// english.unit(\u003ctext\u003e): processed text\n// english.reserved(\u003ctext\u003e): processed text\n// english.entity(\u003ctext\u003e, \u003cmatch fn\u003e, [this]): Promise (processed text)\n// english(\u003ctext\u003e, \u003cmatch fn\u003e, [this], [options])\n// -\u003e Promise (processed text)\n\n// \u003cmatch fn\u003e(\u003ctexts\u003e)\n// - texts: array of text\n// -\u003e Promise {type, value, length}\n// - type: token type (table/column/row)\n// - value: token value\n// - hint: token hint (identifies table)\n// - length: token length (from start of texts)\n\n// options: {\n//   table: undefined,       // default table: none\n//   columns: {\u003ctable\u003e: []}, // default columns per table: none\n// }\n\n\nfunction match(txts) {\n  var z = null, txt = txts.join(' ');\n  if(txt.startsWith('ascorbic acid')) z = {type: 'column', value: 'ASCORBIC ACID', length: 2};\n  else if(txt.startsWith('food')) z = {type: 'table', value: 'FOOD', length: 1};\n  return Promise.resolve(z);\n};\nawait english('show food with ascorbic acid less than twenty nine mg', match);\n// SELECT \"ASCORBIC ACID\" FROM \"FOOD\" WHERE (\"ASCORBIC ACID\" \u003c 0.029)\n```\n\nMethods:\n- [token](https://www.npmjs.com/package/@pg-english/token)\n- [number](https://www.npmjs.com/package/@pg-english/number)\n- [unit](https://www.npmjs.com/package/@pg-english/unit)\n- [reserved](https://www.npmjs.com/package/@pg-english/reserved)\n- [entity](https://www.npmjs.com/package/@pg-english/entity)\n\n\n[english query]: https://www.nexthink.com/blog/natural-language-interfaces-to-databases-nlidb/\n[informal]: https://www.npmjs.com/package/pg-slang\n[SQL SELECT]: https://www.postgresql.org/docs/10/static/sql-select.html\n[pg-slang]: https://www.npmjs.com/package/pg-slang\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodef%2Fpg-english","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnodef%2Fpg-english","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodef%2Fpg-english/lists"}