{"id":17946994,"url":"https://github.com/defstream/nl3","last_synced_at":"2025-03-24T20:32:56.396Z","repository":{"id":54809005,"uuid":"48395100","full_name":"defstream/nl3","owner":"defstream","description":"nl3  - Natural Language Triples","archived":false,"fork":false,"pushed_at":"2023-03-22T00:45:29.000Z","size":131,"stargazers_count":12,"open_issues_count":23,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T01:52:11.715Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://defstream.github.io/nl3","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/defstream.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":"2015-12-21T21:29:27.000Z","updated_at":"2024-03-11T09:32:19.000Z","dependencies_parsed_at":"2022-08-14T03:31:01.802Z","dependency_job_id":null,"html_url":"https://github.com/defstream/nl3","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defstream%2Fnl3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defstream%2Fnl3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defstream%2Fnl3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/defstream%2Fnl3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/defstream","download_url":"https://codeload.github.com/defstream/nl3/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245348379,"owners_count":20600633,"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":[],"created_at":"2024-10-29T07:08:17.595Z","updated_at":"2025-03-24T20:32:56.023Z","avatar_url":"https://github.com/defstream.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## nl3 - Natural Language Triples\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"http://npmjs.com/package/nl3\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/nl3.svg\"\n     alt=\"npm version\"\u003e\u003c/a\u003e\n\n  \u003ca href=\"https://gemnasium.com/defstream/nl3\"\u003e\u003cimg src=\"https://img.shields.io/gemnasium/defstream/nl3.svg\"\n       alt=\"Gemnasium\"\u003e\u003c/a\u003e\n\n  \u003ca href=\"https://travis-ci.org/defstream/nl3\"\u003e\u003cimg src=\"https://img.shields.io/travis/defstream/nl3.svg\"\n       alt=\"build status\"\u003e\u003c/a\u003e\n\n  \u003ca href=\"https://codecov.io/github/defstream/nl3\"\u003e\u003cimg src=\"https://img.shields.io/codecov/c/github/defstream/nl3.svg\"\n        alt=\"coverage\"\u003e\u003c/a\u003e\n\n  \u003ca href=\"https://circleci.com/gh/defstream/nl3\"\u003e\u003cimg src=\"https://img.shields.io/circleci/project/defstream/nl3.svg\"\n       alt=\"coverage\"\u003e\u003c/a\u003e\n\n  \u003ca href=\"https://snyk.io/test/npm/nl3\"\u003e\u003cimg src=\"https://snyk.io/test/npm/nl3/badge.svg\" alt=\"Known Vulnerabilities\"\u003e\u003c/a\u003e\n\n  \u003ca href=\"http://npm-stat.com/charts.html?package=nl3\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/nl3.svg\" alt=\"downloads\"\u003e\u003c/a\u003e\n\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://gitter.im/defstream/nl3\"\u003e\u003cimg src=\"https://img.shields.io/gitter/room/defstream/nl3.svg\"\n     alt=\"Chat\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n**nl3** is a natural language triple library, used for parsing triples from plain english.\nCurrently nl3 is best at generating triples from  simple short phrases that contain the Subject, Predicate and Object in order.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.github.com/defstream/nl3/master/logo.png\"\u003e\n\u003c/p\u003e\n\n#### What is a triple?\nA triple is a data structure that represents a Subject, Predicate and Object or S P O.\n\n**More Information**\n- https://en.wikipedia.org/wiki/Triplestore\n- https://en.wikipedia.org/wiki/Resource_Description_Framework\n\n#### TLDR;\n\n```javascript\nvar nl3 = require('nl3')({\n/**\n* Specifies valid triples in plain english ex: 'Subject Predicate Object'.\n* All values will be singularized.\n* @type {Array}\n*/\n  grammar: [\n    'users message users'\n  ],\n/**\n* Extend your vocabulary by mapping word stems to existing predicates.\n* @type {Object}\n*/\n  vocabulary: {\n    msg: 'message',     // user bob msgs user tom\n    messag: 'message',  // user bob messaged user jill\n    contact: 'message'  // user bob contacted user bill\n  }\n});\n```\n\nThe client returned is able to parse these queries.\n\n```javascript\nnl3.parse('user jack msg user jill');\nnl3.parse('user jack msgs user jill');\nnl3.parse('user jack messaged user jill');\nnl3.parse('user jack contacted user jill');\nnl3.parse('user jack contacts user jill');\n```\n\nAll of which will have the same output.\n\n```javascript\n{\n  subject: {\n    type: 'user',\n    value: 'jack'\n  },\n  predicate: {\n    value: 'message'\n  },\n  object: {\n    type: 'user',\n    value: 'jill'\n  }\n}\n```\n\n# Installation\n\n```shell\n$ npm install nl3 --save\n```\n\n# Development Scripts\nBefore running any development scripts, be sure to first install the dev modules.\n\n```shell\n$ npm install nl3 --save --dev\n```\n\n#### Build Documentation\nOutputs code documentation files to the `./doc/api` folder.\n\n```shell\n$ npm run doc\n```\n\n#### Static Analysis\nOutputs static analysis files to the `./doc/analysis` folder.\n\n```shell\n$ npm run analyze\n```\n\n#### Test + Coverage\nOutputs code coverage files to the `./doc/coverage` folder.\n\n```shell\n$ npm run test\n```\n\n**CURRENT COVERAGE REPORT**\n\n![codecov.io](https://codecov.io/github/defstream/nl3/branch.svg?branch=master)\n\n# API\n\n### `nl3(options)`\n\nCreate an nl3 instance.\n\n**parameters:**\n- **options**            {Object}    The options for the nl3 client.\n- **options.grammar**    {Array}     An array of valid grammar in the format of 'S P O'.\n- **options.vocabulary** {Array}     An object mapping the phonetic root of an object to a predicate.\n\n\n**returns**: a new instance of the nl3 client.\n\nExample\n\n```javascript\nvar nl3 = require('nl3')({\n/**\n* Specify valid triples in plain english ex: 'Subject Predicate Object'.\n* The Subject, Predicate and Object will be will be singularized, if presented in any tense.\n* @type {Array}\n*/\n  grammar: [\n    'users message users'\n  ],\n/**\n* Extend the vocabulary of your predicates by mapping word stems to existing predicates within your grammar.\n* @type {Object}\n*/\n  vocabulary: {\n    msg: 'message',     // user bob msgs user tom\n    messag: 'message',  // user bob messaged user jill\n    contact: 'message'  // user bob contacted user bill\n  }\n});\n```\n\n### `nl3.parse( text )`\n\n**parameters:**\n- **text**:  {String}  A string containing a S P O phrase in plain english.\n**returns**: A triple containing the results of of the parsed Subject Predicate and Object.\n\nExample\n\n```javascript\n\nvar nl3 = require('nl3')({\n  grammar: [\n    'users message users'\n  ],\n  vocabulary: {\n    contact: 'message', // user bob contacted user bill\n  }\n});\n\nfunction print (description, triple) {\n  console.log(\n    description + ' =', JSON.stringify(triple, null, '  ');\n  );\n};\n\nprint( 'user jack contacts user jill', nl3.parse('user jack contacts user jill') );\n\nprint( 'users who message user jill', nl3.parse('users who message user jill') );\n\n```\n\n**returns:**\n\n```javascript\n\nuser jack contacts user jill = {\n  \"subject\": {\n    \"type\": \"user\",\n    \"value\": \"jack\"\n\n  },\n  \"predicate\": {\n    \"value\": \"message\"\n  },\n  \"object\": {\n    \"type\": \"user\",\n    \"value\": \"jill\"\n  }\n}\nusers who message user jill = {\n  \"subject\": {\n    \"type\": \"user\"\n  },\n  \"predicate\": {\n    \"value\": \"message\"\n  },\n  \"object\": {\n    \"type\": \"user\",\n    \"value\": \"jill\"\n  }\n}\n\n```\n\n### vNext\nSupport for natural random order queries, these are not in (SPO) order, such as messages that user bob created (OSP), created messages by user jill (POS), created by user jill messages (PSO), (SO) user jills messages, (OS) messages for user jill.\n\n```javascript\n\n  nl3.parse('messages from user 42');\n  nl3.parse('messages by user 32');\n\n```\n\n### The Backlog\n- Support for misspelled subjects \u0026 objects ( nearest neighbor )\n\n### Discuss\nChat channel:    \u003ca href=\"https://gitter.im/defstream/nl3\"\u003e\u003cimg src=\"https://img.shields.io/gitter/room/defstream/nl3.svg\" alt=\"Chat\"\u003e\u003c/a\u003e\n\nQuestions or comments can also be posted on the nl3 Github issues page.\n\n### Maintainers\nHector Gray (Twitter: \u003ca href=\"https://twitter.com/defstream\"\u003e@defstream\u003c/a\u003e)\n\n### Contribute\nPull Requests welcome. Please make sure all tests pass:\n\n```shell\n$ npm test\n```\n\nPlease submit \u003ca href=\"https://github.com/defstream/nl3/issues\"\u003eGithub issues\u003c/a\u003e for any feature enhancements, bugs or documentation problems.\n\n### License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefstream%2Fnl3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefstream%2Fnl3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefstream%2Fnl3/lists"}