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

wordnet-sqlite

v1.0.3

Published

A node package exposing an SQLite database of the Princeton University WordNet database

Downloads

5

Readme

WordNet SQLite

A node package exposing an SQLite database of the Princeton University WordNet database

Installation

Just run

npm install wordnet-sqlite

Note that installing the module will install the SQLite3 module as a dependency, which requires compilation using node-gyp, so a working toolchain is required to install this module.

API

On requiring the module, an instance of an sqlite3 client is created and connected to the local WordNet database. This client is then returned, and can be used according to the sqlite3 API.The returned object is an instance of Database, so methods like #run and #foreach can be called directly from it.

Currently the database consists of only one table called words, which has the following columns:

  • word. A text field that contains the dictionary word in its most basic form (without a prefix or suffix) i.e. child will appear but not children. Note that spaces are replaced with underscores, e.g. out_of_the_way. For further information, have a look at the WordNet documentation

  • definition. A text field that contains a gloss, a string which which may contain a definition, one or more example sentences, or both. For example the definition field for implicit is the string being without doubt or reserve; "implicit trust", consisting of a definition and one example sentence.

  • type. Also a text field that contains a string indicating the type of word this row is. Either "adj", "adv", "noun", or "verb". Note that types such as conjunctions and interjections are not part of the WordNet project so are not present in the database.

  • rowid. An integer field created automatically by SQLite. Corresponds to the index of the word, so the first entry has a rowid of 1. However the words are in no particular order so this is not likely to be of any use.

Here's a simple example usage of the database. See the Example section for another example.

var db = require("wordnet-sqlite");
db.get("SELECT definition FROM words WHERE word = 'pulpy' LIMIT 1;", function (err, row) {
    console.log(row.definition);
});

Outputs:

like a pulp or overripe; not having stiffness

Example

Here's a bot I wrote to email people random compliments (well actually they're more like insults):

var nodemailer = require('nodemailer');
var db = require("wordnet-sqlite");

// create reusable transporter object using SMTP transport
var transporter = nodemailer.createTransport({
    service: 'Gmail',
    auth: {
        user: '<[email protected]>',
        pass: 'mypassword'
    }
});

db.get("SELECT * FROM words WHERE type = 'adj' ORDER BY RANDOM() LIMIT 1;", function (err, row) {
    var mailOptions = {
        from: 'Me <[email protected]>',
        to: 'My Victim <[email protected]>',
        subject: 'You are ' + row.word,
        text: row.word + ": " + row.definition
    };

    transporter.sendMail(mailOptions, function (error, info) {
        if (error)
            console.log(error);
        else
            console.log('Message sent: ' + info.response);

        db.close();
    });
});

Outputs: Mailer Results

Contributions

The GitHub repository contains the raw_dict directory, which contains the data.adj, data.adv, data.noun and data.verb files from the WordNet website (version 3.1). If WordNet is updated, download the new files and replace those in raw_dict, then run the setup.js script to rebuild the database.

Any other contributions are welcome, especially improvements to the database schema itself.