javatools.database
Class DBWordNet

java.lang.Object
  extended by javatools.database.DBWordNet

public class DBWordNet
extends java.lang.Object

This class is part of the Java Tools (see http://mpii.de/yago-naga/javatools). It is licensed under the Creative Commons Attribution License (see http://creativecommons.org/licenses/by/3.0) by the YAGO-NAGA team (see http://mpii.de/yago-naga). This class provides a wrapping for WordNet by a database. The database can be e.g. an OracleDatabase or a MySQLDatabase. Before creating instances of this class, you have to build the database by the construct-method. This method requires the Prolog-version of WordNet, which can be downloaded from the WordNet-website.
Example:

  // Execute this only once to create the database!
  Database database=new OracleDatabase("scott","tiger");
  DBWordNet.construct(database, new File("wordnet/prologversion"));

  // Use this code to access the data
  Database database=new OracleDatabase("scott","tiger");
  DBWordNet wordnet = new DBWordNet(database);
  System.out.println(wordnet.synsetsFor("house"));
  --->     103413667, 103413668, 103413669 (or similar)
  System.out.println(wordnet.glossFor(103413667));  
  --->     a dwelling that serves as living quarters for one or more families


Nested Class Summary
static class DBWordNet.Table
          One enum per SQL table
 
Constructor Summary
DBWordNet(Database db)
          Constructs a new DBWordNet, basing on a filled database
 
Method Summary
static void construct(Database db, java.io.File wordNetFolder)
          Fills the database with WordNet data
 Database getDatabase()
          Returns the database
 java.lang.String glossFor(int synset)
          Returns the gloss for a synset
static void main(java.lang.String[] args)
           
 java.util.List<java.lang.Integer> synsetsFor(java.lang.String word)
          Returns synsets for a word
 java.util.List<java.lang.Integer> targetSynsets(DBWordNet.Table relation, int source)
          Returns target synsets for a relation and a source synset
 java.util.List<java.lang.String> wordsFor(int synset)
          Returns words of a synset
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBWordNet

public DBWordNet(Database db)
Constructs a new DBWordNet, basing on a filled database

Method Detail

construct

public static void construct(Database db,
                             java.io.File wordNetFolder)
                      throws java.sql.SQLException,
                             java.io.IOException
Fills the database with WordNet data

Throws:
java.sql.SQLException
java.io.IOException

targetSynsets

public java.util.List<java.lang.Integer> targetSynsets(DBWordNet.Table relation,
                                                       int source)
                                                throws java.sql.SQLException
Returns target synsets for a relation and a source synset

Throws:
java.sql.SQLException

synsetsFor

public java.util.List<java.lang.Integer> synsetsFor(java.lang.String word)
                                             throws java.sql.SQLException
Returns synsets for a word

Throws:
java.sql.SQLException

wordsFor

public java.util.List<java.lang.String> wordsFor(int synset)
                                          throws java.sql.SQLException
Returns words of a synset

Throws:
java.sql.SQLException

glossFor

public java.lang.String glossFor(int synset)
                          throws java.sql.SQLException
Returns the gloss for a synset

Throws:
java.sql.SQLException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Parameters:
args -
Throws:
java.lang.Exception

getDatabase

public Database getDatabase()
Returns the database