wordnet-binary-search

Access to Wordnet 3.* files through binary-search

Usage no npm install needed!

<script type="module">
  import wordnetBinarySearch from 'https://cdn.skypack.dev/wordnet-binary-search';
</script>

README

wordnet-binary-search

SYNOPSIS

import { Wordnet } from 'wordnet-binary-search';

Wordnet.dataDir = '../downloads/WordNet-3.0/dict');

const verb = Wordnet.findVerb('import');
const noun = Wordnet.findNoun('name');
const adj = Wordnet.findAdjective('good');
const adv = Wordnet.findAdverb('loudly');

const indexEntriesForAllForms = Wordnet.findAll('excuse');

indexEntriesForAllForms.forEach(indexEntry => {
    indexEntry.senses.forEach(sense => {
        console.log(
            'hypernym for sense "[%s]": [%s]',
            sense,
            sense['hypernym'][0]
        );
    });
});

const allUniqueOppositesOfImport = Array.from(new Set(
    Wordnet.findAll('import').map(
        (indexEntry: IndexEntry) => indexEntry.senses.map(
            sense => sense['antonym'] ? sense['antonym'].toString() : null
        ).filter(s => s !== null)
    ).reduce(
        (call, item) => { call.push(...item); return call }
    )
))

DESCRIPTION

  • binary searches upon your downloaded copies of Wordnet 3.1 "database files"
  • basic object modelling of Wordnet in Typescript
  • automatic, lazy-loaded dereferencing of word senses and semantic pointers

TODO

Lots, probably - it currently does what I want.

The typescript modelling is very limited atm.

The specs do not say if there can be more than one pointer of each type, so currently multiple are supported. This may change.

POINTER REFERENCE

Pointers follow the Wordnet format, and are stored in WithPointers.pointerMapEngToSymbol, keyed by Wordnet word form identifier: n for noun, v for verb, a for adverb, r for adjective. Pointers can be dereferenced manually by calling the derefPointer(symbol) method upon the Sense object (where symbol is the Wordnet pointer_symbol, eg, @i), or by calling the dynamically-generated lazy-loaded memoised property of the Sense named after the pointer_symbol name (eg instanceHypernym for @i).

    console.log(WithPointers.pointerMapEngToSymbol);

    {
        n: { // The pointer_symbols for nouns:
            antonym: '!',
            hypernym: '@',
            instanceHypernym: '@i',
            hypnym: '~',
            instanceHyponym: '~i',
            memberHolonym: '#m',
            substanceHolonym: '#s',
            partHolonym: '#p',
            memberMeronym: '%m',
            substanceMeronym: '%s',
            partMeronym: '%p',
            attribute: '=',
            derivationallyRelatedForm: '+',
            domainofSynsetTopic: ';c',
            memberofThisDomainTopic: '-c',
            domainofSynsetRegion: ';r',
            memberofThisDomainRegion: '-r',
            domainofSynsetUsage: ';u',
            memberofThisDomainUsage: '-u'
        },
        v: { // The pointer_symbols for verbs:
            antonym: '!',
            hypernym: '@',
            hypnym: '~',
            entailment: '*',
            cause: '>',
            alsoSee: '^',
            verbGroup: '

,
            derivationallyRelatedForm: '+',
            domainofSynsetTopic: ';c',
            domainofSynsetRegion: ';r',
            domainofSynsetUsage: ';u'
        },
        r: { // The pointer_symbols for adjectives:
            antonym: '!',
            similarTo: '&',
            participleOfVerb: '<',
            pertainym: '\\',
            attribute: '=',
            alsoSee: '^',
            domainofSynsetTopic: ';c',
            domainofSynsetRegion: ';r',
            domainofSynsetUsage: ';u'
        },
        a: {// The pointer_symbols for adverbs are:
            antonym: '!',
            derivedFromAdjective: '\\',
            domainofSynsetTopic: ';c',
            domainofSynsetRegion: ';r',
            domainofSynsetUsage: ';u'
        }
    };