Class DictionaryToDatabaseWithUsageCount


  • public class DictionaryToDatabaseWithUsageCount
    extends java.lang.Object
    DictionaryToDatabase is used to transfer a WordNet file database into an actual database structure.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.sql.Connection connection
      The database connection.
      private java.util.Map idToSynsetOffset
      Mapping of database id's to synset offset id's.
      private static int INTERNAL_ID  
      private static MessageLog LOG
      Our message log.
      private java.util.Map synsetOffsetToId
      Mapping of synset offset id's to database id's.
      private static long TIME  
      private java.util.Map usageMap
      Maps the usage.
    • Constructor Summary

      Constructors 
      Constructor Description
      DictionaryToDatabaseWithUsageCount​(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
      void createTables​(java.lang.String scriptFilePath)
      Create the database tables.
      void insertData()
      Inserts the data into the database.
      private void loadSenseKeyAndUsage​(java.lang.String filename)
      loads the sense key usage from a file.
      static void main​(java.lang.String[] args)
      Run the program, requires 4 arguments.
      private static int nextId()  
      private void storeExceptions​(java.util.Iterator itr)
      Store the exceptions file.
      private void storeIndexWords​(java.util.Iterator itr)
      Store all the index words.
      private void storeIndexWordSynsets()
      Store the index word synsets.
      private void storeSynsets​(java.util.Iterator 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

      • 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.
      • usageMap

        private java.util.Map usageMap
        Maps the usage. The key is 'offset:lemma', the object[] contains the sense key (string) and the usage count (integer).
    • Constructor Detail

      • DictionaryToDatabaseWithUsageCount

        public DictionaryToDatabaseWithUsageCount​(java.sql.Connection conn)
        Create a new DictionaryToDatabase with a database connection. JWNL already initialized.
        Parameters:
        conn - - the database connection
    • 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.SQLException
        Create the database tables.
        Parameters:
        scriptFilePath - - the sql script filename
        Throws:
        java.io.IOException
        java.sql.SQLException
      • insertData

        public void insertData()
                        throws java.lang.Exception
        Inserts 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.SQLException
        Store 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.SQLException
        Store all of the synsets in the database.
        Parameters:
        itr -
        Throws:
        java.sql.SQLException
      • storeIndexWordSynsets

        private void storeIndexWordSynsets()
                                    throws java.sql.SQLException
        Store the index word synsets.
        Throws:
        java.sql.SQLException
      • loadSenseKeyAndUsage

        private void loadSenseKeyAndUsage​(java.lang.String filename)
                                   throws java.sql.SQLException
        loads the sense key usage from a file.
        Throws:
        java.sql.SQLException
      • storeExceptions

        private void storeExceptions​(java.util.Iterator itr)
                              throws java.sql.SQLException
        Store the exceptions file.
        Parameters:
        itr -
        Throws:
        java.sql.SQLException