Package net.didion.jwnl.utilities
Class DictionaryToDatabase
- java.lang.Object
-
- net.didion.jwnl.utilities.DictionaryToDatabase
-
public class DictionaryToDatabase extends java.lang.ObjectDictionaryToDatabase is used to transfer a WordNet file database into an actual database structure.
-
-
Field Summary
Fields Modifier and Type Field Description private java.sql.ConnectionconnectionThe database connection.private java.util.MapidToSynsetOffsetMapping of database id's to synset offset id's.private static intINTERNAL_IDprivate static MessageLogLOGOur message log.private java.util.MapsynsetOffsetToIdMapping of synset offset id's to database id's.private static longTIME
-
Constructor Summary
Constructors Constructor Description DictionaryToDatabase(java.sql.Connection conn)Create a new DictionaryToDatabase with a database connection.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateTables(java.lang.String scriptFilePath)Create the database tables.voidinsertData()Inserts the data into the database.static voidmain(java.lang.String[] args)Run the program, requires 4 arguments.private static intnextId()private voidstoreExceptions(java.util.Iterator itr)Store the exceptions file.private voidstoreIndexWords(java.util.Iterator itr)Store all the index words.private voidstoreIndexWordSynsets()Store the index word synsets.private voidstoreSynsets(java.util.Iterator itr)Store all of the synsets in the database.
-
-
-
Field Detail
-
LOG
private static final MessageLog LOG
Our message log.
-
INTERNAL_ID
private static int INTERNAL_ID
-
TIME
private static long TIME
-
connection
private java.sql.Connection connection
The database connection.
-
idToSynsetOffset
private java.util.Map idToSynsetOffset
Mapping of database id's to synset offset id's. 1 to 1.
-
synsetOffsetToId
private java.util.Map synsetOffsetToId
Mapping of synset offset id's to database id's. 1:1.
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
Run the program, requires 4 arguments. See DictionaryToDatabase.txt for more documentation.- Parameters:
args-
-
nextId
private static int nextId()
-
createTables
public void createTables(java.lang.String scriptFilePath) throws java.io.IOException, java.sql.SQLExceptionCreate the database tables.- Parameters:
scriptFilePath- - the sql script filename- Throws:
java.io.IOExceptionjava.sql.SQLException
-
insertData
public void insertData() throws java.lang.ExceptionInserts the data into the database. Iterates through the various POS, then stores all the index words, synsets, exceptions of that POS.- Throws:
java.lang.Exception
-
storeIndexWords
private void storeIndexWords(java.util.Iterator itr) throws java.sql.SQLExceptionStore all the index words.- Parameters:
itr- - the part of speech iterator- Throws:
java.sql.SQLException
-
storeSynsets
private void storeSynsets(java.util.Iterator itr) throws java.sql.SQLExceptionStore all of the synsets in the database.- Parameters:
itr-- Throws:
java.sql.SQLException
-
storeIndexWordSynsets
private void storeIndexWordSynsets() throws java.sql.SQLExceptionStore the index word synsets.- Throws:
java.sql.SQLException
-
storeExceptions
private void storeExceptions(java.util.Iterator itr) throws java.sql.SQLExceptionStore the exceptions file.- Parameters:
itr-- Throws:
java.sql.SQLException
-
-