wordnet.rb

Path: | lib/wordnet.rb
Modified: | Wed Sep 03 06:27:51 GMT 2003

WordNet - A Ruby interface to the WordNet lexical database

## Synopsis

      require "WordNet"

      # Create a new lexicon object
      lex = WordNet::Lexicon::new

      # Look up the synsets for "language" and "computer program"
      languageSynset = lex.lookupSynsets( "language", WordNet::Noun, 3 )
      programSynset = lex.lookupSynsets( "program", WordNet::Noun, 3 )

      # Create a new synset for programming languages, set its gloss, link it to its
      # hypernym and holonym, and save everything to the database.
      progLangSynset = lex.createSynset( "programming language", WordNet::Noun )
      progLangSynset.gloss = "a system of human-readable symbols and words " #               "for encoding instructions for a computer"
      progLangSynset.hypernyms += languageSynset
      languageSynset.hyponyms += progLangSynset
      progLangSynset.holonyms += programSynset
          programSynset.stuffMeronyms += progLangSynset
      [ progLangSynset, programSynset, languageSynset ].each do |synset|
            synset.store
      end

      # Create a new synset for Ruby, link it, and save it
      rubySynset = lex.createSynset( "Ruby", Wordnet::Noun )
      rubySynset.gloss = "an interpreted scripting language for quick and easy object-oriented programming"
      rubySynset.hypernyms += languageSyn ; languageSynset.hyponyms += rubySyn
      rubySynset.write ; languageSynset.write

## Description

This is a Ruby interface to the WordNet lexical database. It’s mostly a port of Dan Brian’s Lingua::Wordnet Perl module, modified a bit to be more Ruby-ish.

## Author

The Lingua::Wordnet module by Dan Brian, on which this code is based, falls under the following license:

      Copyright 1999,2000,2001 by Dan Brian.

      This program is free software; you can redistribute it and/or modify
      it under the same terms as Perl itself.

Written by Michael Granger <ged@FaerieMUD.org>

Copyright © 2002,2003 The FaerieMUD Consortium. All rights reserved.

This module is free software. You may use, modify, and/or redistribute this software under the terms of the Perl Artistic License. (See language.perl.com/misc/Artistic.html)

## Version

     $Id: wordnet.rb,v 1.4 2003/09/03 06:27:51 deveiant Exp $

Required files

crosscase wordnet/constants wordnet/lexicon wordnet/synset

Classes and Modules

Module WordNet
::Module WordNet::Constants
::Class WordNet::Lexicon
::Class WordNet::LexiconError
::Class WordNet::LookupError
::Class WordNet::Synset
:: ::Class WordNet::Synset::Pointer
::Class WordNet::SynsetError
::Class WordNet::TestCase