npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vsm-dictionary

v2.6.6

Published

VSM-dictionary interface specification, and parent class, having shared code for subclass implementations

Downloads

28

Readme

vsm-dictionary

Intro

VSM-sentences are built from terms (=words or phrases) that are linked to semantic identifiers (=unique IDs that represent a concept with a definition).

These terms+IDs are typically stored on various 'dictionary' servers that make them accessible through their own API.

vsm-dictionary provides a standardized interface for communicating with dictionary webservers, in order to support VSM-sentence-building tools. (Tools such as vsm-autocomplete, or more advanced components for searching, storing, and managing terms).

vsm-dictionary is also designed to handle multiple 'sub-dictionaries', as well as multiple synonyms per term.
And it supports the representation of stylized terms, e.g. with italic or superscript parts, like Ca2+, and more.

Overview

vsm-dictionary contains only:

  • a full specification for the above interface (for search, creating terms, etc);
  • a 'VsmDictionary' parent-class implementation, which provides VSM-specific and shared functionality that subclasses should use.

The real interface with a dictionary service is thus implemented by subclasses of VsmDictionary.

Currently there are at least two such implementations available:

  • vsm-dictionary-local:
    a full implementation of a local (in-memory, serverless) VsmDictionary.
    • This module can be used as a fully functional placeholder that does not depend on a third-party term-server, while developing new tools that depend on a VsmDictionary.
    • Or it could provide mock terms+ids while running standalone demos of VSM-sentence building tools.
    • The many automated tests in VsmDictionaryLocal can give inspiration for testing future, webserver-linked subclasses.
  • vsm-dictionary-remote-demo:
    a bare-minimum demo-implementation of a VsmDictionary that connects to a hypothetical server API.
    • This module only serves as inspiration for developing real interfaces to an online dictionary service.
    • Still, it includes a live demo that connects to a real server API.

How to implement a VsmDictionary subclass

Specification

• Any implementation of a VsmDictionary (which communicates with a particular dictionary-webservice) must follow the interface specified in  ----> Dictionary.spec.md <----- .
VsmDictionary is the parent class that all implementations must 'extends' from.
(Note: we simply use the name 'Dictionary' for VsmDictionary, in the spec & source code).

Installation with NPM for Node.js:

mkdir vsm-dictionary-newwwww
cd    vsm-dictionary-newwwww
npm init -y
npm install vsm-dictionary

Template for a subclass, as a Node.js module:

(See also VsmDictionaryLocal and VsmDictionaryRemoteDemo).

// Import the parent class.
const VsmDictionary = require('vsm-dictionary');

// Make subclass and export as Node.js module.
module.exports = class VsmDictionaryNewww extends VsmDictionary {

  constructor(options) {
    // Must call the parent constructor first.
    super(options);

    // ...

  }


  // Methods for Create, Read, Update, Delete of terms, subdictionary-info
  // objects, etc. (see spec).

  // ...
  // ...


  getEntryMatchesForString(str, options, cb) {
    var matches = [];

    // ...

    cb(null, { items: matches });
  }

}

(If the above code is placed in a file named 'VsmDictionaryNewww.js', it can already be used in another file 'test.js':

var Dict = require('./VsmDictionaryNewww.js');
var dict = new Dict();
console.dir(dict);
dict.getMatchesForString('42', {}, (err, res) => console.dir(res));

by running: node test.js).

Tests

Run npm test, which runs tests with Mocha.
Run npm run testw, which automatically reruns tests on any file change.

Demo

See vsm-dictionary-local and vsm-dictionary-remote-demo for interactive demos of at least the string-search functionality.

License

This project is licensed under the AGPL license - see LICENSE.md.