Package net.didion.jwnl.utilities
Class DictionaryToDatabaseWithUsageCount
java.lang.Object
net.didion.jwnl.utilities.DictionaryToDatabaseWithUsageCount
DictionaryToDatabase is used to transfer a WordNet file database into an actual
database structure.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Connection
The database connection.private Map
Mapping of database id's to synset offset id's.private static int
private static final MessageLog
Our message log.private Map
Mapping of synset offset id's to database id's.private static long
private Map
Maps the usage. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new DictionaryToDatabase with a database connection. -
Method Summary
Modifier and TypeMethodDescriptionvoid
createTables
(String scriptFilePath) Create the database tables.void
Inserts the data into the database.private void
loadSenseKeyAndUsage
(String filename) loads the sense key usage from a file.static void
Run the program, requires 4 arguments.private static int
nextId()
private void
storeExceptions
(Iterator itr) Store the exceptions file.private void
storeIndexWords
(Iterator itr) Store all the index words.private void
Store the index word synsets.private void
storeSynsets
(Iterator itr) Store all of the synsets in the database.
-
Field Details
-
LOG
Our message log. -
INTERNAL_ID
private static int INTERNAL_ID -
TIME
private static long TIME -
connection
The database connection. -
idToSynsetOffset
Mapping of database id's to synset offset id's. 1 to 1. -
synsetOffsetToId
Mapping of synset offset id's to database id's. 1:1. -
usageMap
Maps the usage. The key is 'offset:lemma', the object[] contains the sense key (string) and the usage count (integer).
-
-
Constructor Details
-
DictionaryToDatabaseWithUsageCount
Create a new DictionaryToDatabase with a database connection. JWNL already initialized.- Parameters:
conn
- - the database connection
-
-
Method Details
-
main
Run the program, requires 4 arguments. See DictionaryToDatabase.txt for more documentation.- Parameters:
args
-
-
nextId
private static int nextId() -
createTables
Create the database tables.- Parameters:
scriptFilePath
- - the sql script filename- Throws:
IOException
SQLException
-
insertData
Inserts the data into the database. Iterates through the various POS, then stores all the index words, synsets, exceptions of that POS.- Throws:
Exception
-
storeIndexWords
Store all the index words.- Parameters:
itr
- - the part of speech iterator- Throws:
SQLException
-
storeSynsets
Store all of the synsets in the database.- Parameters:
itr
-- Throws:
SQLException
-
storeIndexWordSynsets
Store the index word synsets.- Throws:
SQLException
-
loadSenseKeyAndUsage
loads the sense key usage from a file.- Throws:
SQLException
-
storeExceptions
Store the exceptions file.- Parameters:
itr
-- Throws:
SQLException
-