net.sf.extjwnl.utilities
Class DictionaryToDatabase

java.lang.Object
  extended by net.sf.extjwnl.utilities.DictionaryToDatabase

public class DictionaryToDatabase
extends Object

DictionaryToDatabase is used to transfer a WordNet file database into an actual database structure.

Author:
Brett Walenz , Aliaksandr Autayeu

Field Summary
protected  Connection connection
          The database connection.
protected  Dictionary dictionary
           
protected  Map<Integer,long[]> idToSynsetOffset
          Mapping of database id's to synset offset id's.
protected static int INTERNAL_ID
           
protected  Map<Long,Integer> synsetOffsetToId
          Mapping of synset offset id's to database id's.
protected static String[] tables
           
protected static long TIME
           
 
Constructor Summary
DictionaryToDatabase(Dictionary dictionary, Connection conn)
          Create a new DictionaryToDatabase with a database connection.
 
Method Summary
 void createTables(String scriptFilePath)
          Create the database tables.
 void insertData()
          Inserts the data into the database.
static void main(String[] args)
          Run the program, requires 4 arguments.
protected static int nextId()
           
protected  void storeExceptions(Iterator<Exc> itr)
          Store the exceptions file.
protected  void storeIndexWords(Iterator<IndexWord> itr)
          Store all the index words.
protected  void storeIndexWordSynsets()
          Store the index word synsets.
protected  void storeSynsets(Iterator<Synset> itr)
          Store all of the synsets in the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INTERNAL_ID

protected static int INTERNAL_ID

TIME

protected static long TIME

tables

protected static final String[] tables

connection

protected Connection connection
The database connection.


idToSynsetOffset

protected Map<Integer,long[]> idToSynsetOffset
Mapping of database id's to synset offset id's. 1 to 1.


synsetOffsetToId

protected Map<Long,Integer> synsetOffsetToId
Mapping of synset offset id's to database id's. 1:1.


dictionary

protected Dictionary dictionary
Constructor Detail

DictionaryToDatabase

public DictionaryToDatabase(Dictionary dictionary,
                            Connection conn)
Create a new DictionaryToDatabase with a database connection. JWNL already initialized.

Parameters:
dictionary - the dictionary
conn - the database connection
Method Detail

main

public static void main(String[] args)
Run the program, requires 4 arguments. See DictionaryToDatabase.txt for more documentation.

Parameters:
args - args

nextId

protected static int nextId()

createTables

public void createTables(String scriptFilePath)
                  throws IOException,
                         SQLException
Create the database tables.

Parameters:
scriptFilePath - - the sql script filename
Throws:
IOException - IOException
SQLException - SQLException

insertData

public void insertData()
                throws JWNLException,
                       SQLException
Inserts the data into the database. Iterates through the various POS, then stores all the index words, synsets, exceptions of that POS.

Throws:
JWNLException - JWNLException
SQLException - SQLException

storeIndexWords

protected void storeIndexWords(Iterator<IndexWord> itr)
                        throws SQLException
Store all the index words.

Parameters:
itr - - the index word iterator
Throws:
SQLException - SQLException

storeSynsets

protected void storeSynsets(Iterator<Synset> itr)
                     throws SQLException
Store all of the synsets in the database.

Parameters:
itr - itr
Throws:
SQLException - SQLException

storeIndexWordSynsets

protected void storeIndexWordSynsets()
                              throws SQLException
Store the index word synsets.

Throws:
SQLException - SQLException

storeExceptions

protected void storeExceptions(Iterator<Exc> itr)
                        throws SQLException
Store the exceptions file.

Parameters:
itr - iterator
Throws:
SQLException - SQLException


Copyright © 2011. All Rights Reserved.