{"id":22266300,"url":"https://github.com/vsm/vsm-dictionary-local","last_synced_at":"2025-10-06T10:20:55.921Z","repository":{"id":39577420,"uuid":"123609556","full_name":"vsm/vsm-dictionary-local","owner":"vsm","description":"Local (in-memory), full implementation of a VSM-dictionary","archived":false,"fork":false,"pushed_at":"2023-01-03T15:17:15.000Z","size":1812,"stargazers_count":0,"open_issues_count":21,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-14T14:25:19.678Z","etag":null,"topics":["dictionary","identifiers","in-memory","ontology-search","terms","vsm"],"latest_commit_sha":null,"homepage":"https://github.com/vsm/vsm-dictionary","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vsm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-02T17:29:45.000Z","updated_at":"2020-08-27T20:40:53.000Z","dependencies_parsed_at":"2023-02-01T07:01:15.245Z","dependency_job_id":null,"html_url":"https://github.com/vsm/vsm-dictionary-local","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vsm/vsm-dictionary-local","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsm%2Fvsm-dictionary-local","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsm%2Fvsm-dictionary-local/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsm%2Fvsm-dictionary-local/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsm%2Fvsm-dictionary-local/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vsm","download_url":"https://codeload.github.com/vsm/vsm-dictionary-local/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vsm%2Fvsm-dictionary-local/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278592784,"owners_count":26012377,"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","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["dictionary","identifiers","in-memory","ontology-search","terms","vsm"],"created_at":"2024-12-03T10:18:16.010Z","updated_at":"2025-10-06T10:20:55.879Z","avatar_url":"https://github.com/vsm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vsm-dictionary-local\n\n\u003cbr\u003e\n\n## Summary\n\n`vsm-dictionary-local` is a full, local (=in-memory) implementation\nof the 'VsmDictionary' parent-class/interface (from the package\n[`vsm-dictionary`](https://github.com/vsm/vsm-dictionary)).\n\n\u003cbr\u003e\n\n## Background\n\n- [VSM-sentences](http://scicura.org/vsm/vsm.html)\n  are built from terms that are linked to identifiers.\n- The '[`vsm-dictionary`](https://github.com/vsm/vsm-dictionary)'\n  package defines a standardized interface,\n  for VSM-related tools to communicate with services\n  that provide terms+IDs (e.g. a webserver API).\n- That packages also includes the 'VsmDictionary' parent class that provides\n  some shared functionality for concrete subclasses (like this package).\n\n\u003cbr\u003e\n\n## A local implementation of a VsmDictionary\n\nThis is VsmDictionaryLocal:\n\n- It extends the VsmDictionary parent class, and provides\n  a concrete implementation that fully implements the vsm-dictionary\n  [specification](https://github.com/vsm/vsm-dictionary/blob/master/Dictionary.spec.md).\n  - i.e. it has the complete Create, Read, Update, Delete, search,\n    sort, filter, etc. functionality for terms, subdictionary-info objects, etc.\n- It does not use an online server for data storage or lookup.\n  Instead, it stores all data in-memory, as long as the application is running.\n\n\u003cbr\u003e\n\n## When to use VsmDictionaryLocal\n\nBecause of the above:\n\n- During the development of new tools that depend on a VsmDictionary,\n  this module can be used as a fully functional placeholder\n  that does not need an online server.\n- Or, it could provide mock terms+ids while running\n  standalone demos of VSM-sentence building tools.\n- The many automated tests in VsmDictionaryLocal can give inspiration\n  for testing future, webserver-connecting implementations.\n\n\u003cbr\u003e\n\n## Specification\n\nApart from following the parent class\n[specification](https://github.com/vsm/vsm-dictionary/blob/master/Dictionary.spec.md),\nVsmDictionaryLocal follows the additional the spec described in\n[DictionaryLocal.spec.md](DictionaryLocal.spec.md).  \n\u0026bull; \u003cspan style=\"font-size: smaller;\"\u003e\n(Note: we simply use the name 'DictionaryLocal' for VsmDictionaryLocal,\nin the spec \u0026amp; source code).\u003c/span\u003e  \n\n\u003cbr\u003e\n\n## Installation\n\n### Node.js\n\n```\nnpm install vsm-dictionary-local\n```\n\n```\nconst VsmDictionaryLocal = require('vsm-dictionary-local');\n```\n\n### Browsers\n\n```\n\u003cscript src=\"https://unpkg.com/vsm-dictionary-local@^2.0.0/dist/vsm-dictionary-local.min.js\"\u003e\u003c/script\u003e\n```\nafter which it is accessible as the global variable `VsmDictionaryLocal`.\n\n\u003cbr\u003e\n\n## Example use in Node.js\n\nExample that (only):  \n\u0026nbsp;\u0026bull; adds one subdictionary (by adding a dictionary-info object),  \n\u0026nbsp;\u0026bull; adds entries to it (=concepts/IDs + terms),  \n\u0026nbsp;\u0026bull; string-searches for matching terms:\n\n```javascript\nconst VsmDictionaryLocal = require('vsm-dictionary-local');\n\nvar dict = new VsmDictionaryLocal();\nvar dictInfos = [ { id: 'DictID_12', name: 'Example subdictionary' } ];\nvar entries = [\n  { id: 'URI:001', dictID: 'DictID_12', terms: [{str: 'aaa'}, {str: 'synonym'}] },\n  { id: 'URI:002', dictID: 'DictID_12', terms: [{str: 'aab'}] },\n  { id: 'URI:003', dictID: 'DictID_12', terms: [{str: 'abc'}], descr: 'description' }\n];\n\ndict.addDictInfos(dictInfos, (err) =\u003e {  // Add 1 subdictionary-info object.\n  dict.addEntries(entries, (err) =\u003e {    // Add 3 entries.\n    dict.getMatchesForString('ab', {}, (err, res) =\u003e {  // Query for string 'ab'.\n      console.dir(res.items, { depth: 3 });\n    });\n  });\n});\n```\n\nThis gives the output:\n\n```javascript\n[ { id: 'URI:003',         // Concept-ID.\n    dictID: 'DictID_12',   // Dictionary-ID.\n    descr: 'description',  // Description of the meaning of concept `URI:003`.\n    terms: [ { str: 'abc' } ],  // Term-objects: one term as an unstyled string.\n    str: 'abc',            // The term-string that this match pertains to.\n    type: 'S' },           // Match type. Prefix(S)-matches come before infix(T).\n  { id: 'URI:002',\n    dictID: 'DictID_12',\n    terms: [ { str: 'aab' } ],\n    str: 'aab',\n    type: 'T' } ]\n```\n\n\u003cbr\u003e\nOr we can load all data in one synchronous call, by giving it to\nVsmDictionaryLocal's constructor:\n\n```javascript\nconst VsmDictionaryLocal = require('vsm-dictionary-local');\n\n// Create.\nvar dict = new VsmDictionaryLocal({\n  dictData: [\n    { id: 'DictID_12',\n      name: 'Example subdictionary',\n      entries: [\n        { id: 'URI:001', terms: [{str: 'aaa'}, {str: 'synonym'}] },\n        { id: 'URI:002', terms: [{str: 'aab'}] },\n        { id: 'URI:003', terms: [{str: 'abc'}], descr: 'description' }\n      ]\n    },\n  ],\n});\n\n// Query.\ndict.getMatchesForString('ab', {}, (err, res) =\u003e {\n  console.dir(res.items, {depth: 3});\n});\n```\n\nwhich gives the same output.\n\n\u003cbr\u003e\n\n## Tests\n\nRun `npm test`, which runs tests with Mocha.  \nRun `npm run testw`, which automatically reruns tests when any file changes.\n\n\u003cbr\u003e\n\n## Demo in Node.js\n\nMore examples are included in [demoInNode.js](demo/demoInNode.js)\n(based on [demoData.js](demo/demoData.js)).  \nRun it with: `node demo/demoInNode.js`.\n\n\u003cbr\u003e\n\n## Interactive demo in the browser\n\nRun `npm run demo` to start an interactive demo of (only)\nthe string-search functionality, based on example data.  \nThis opens a browser page with an input-field to search\non [demoData.js](demo/demoData.js).\n\nThe demo works by making a Webpack dev-server bundle all source code \n(VsmDictionaryLocal and its dependencies) and serve it to the browser.  \nThis is useful during development, to see immediate effects of changes\nto the source code (excl. the demo code).\n\n(For normal use in browsers, just include the browser-build via a\n\u0026lt;script\u0026gt;-tag, see above).\n\n\u003cbr\u003e\n\n## License\n\nThis project is licensed under the AGPL license - see [LICENSE.md](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvsm%2Fvsm-dictionary-local","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvsm%2Fvsm-dictionary-local","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvsm%2Fvsm-dictionary-local/lists"}