Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Verb Frame Issues

Help
2006-10-16
2013-04-29
  • jkurlandski
    jkurlandski
    2006-10-16

    I've been working on verb frames using JWNL and have run into a number of problems. Some of these have been addressed by other users, some have not. Some of the contributors who have addressed these issues offer solutions which did not work for me. I thought that putting these issues and the solutions I have found in one place might help others out. At the end I have also appended some examples on how to get the verb frames for a given verb or synset.

    ISSUES

    1) NUMBER_OF_VERB_FRAMES exception.

    Message:
    Exception java.lang.NumberFormatException: For input
    string: "NUMBER_OF_VERB_FRAMES"

    Cause:
    JWNL cannot find the JWNLResource_en.properties file.

    Solution:
    Find jwnl.jar in your downloaded files.

    Extract the files contained within it with:

    C:\<jarpath>\jar xf jwnl.jar

        - where jarpath is the path to your jar.exe file, usually with all your other Java executables.

    Put JWNLResource_en.properties into the root of your JWNL classpath.
        - For example, if your .class files are in c:\jwnl\classes\net\didion\..., you could put the file in c:\jwnl\classes.

    2) For a synset word having multiple verb frames, only one verb frame is given.

    - See also juanjof's bugs submitted in December of 2005.

    Solution:

    In VerbFrame.java, public static int[] getVerbFrameIndicies(BitSet bits):

    Replace

        int[] indicies = new int[bits.cardinality()];
        for (int i = 0; i < indicies.length; i++) {
            indicies[i] = bits.nextSetBit(i == 0 ? 0 : indicies[i - 1]);
        }

    With

            int lastIdx = 0;
            for (int a = 0; a < indicies.length; a++)  {
                lastIdx = bits.nextSetBit(lastIdx);
                indicies[a] = lastIdx;
                lastIdx++;  // If not incremented nextSetBit() will always find same index.
            }

    3) For a synset word, the wrong frame is given.

    - See also juanjof's bugs submitted in December of 2005.

    Solution:

    In VerbFrame.java, public static String[] getFrames(BitSet bits):

    Replace

                frames[i] = _verbFrames[i].getFrame();

    with

                frames[i] = _verbFrames[indicies[i] - 1].getFrame();

    4) Calling getVerbFrameFlags() or getVerbFrameIndicies() on a synset produces null values or runtime errors.

    Problem:

    The SynsetProxy class does not have forwarding methods for these Synset methods.

    Solution:

    In SynsetProxy.jave,

    - Add this to top of file:

        import java.util.BitSet;

    - Add these lines to method definitions:

        public BitSet getVerbFrameFlags() {
            return getSource().getVerbFrameFlags();
        }

        public int[] getVerbFrameIndicies() {
            return getSource().getVerbFrameIndicies();
        }

    EXAMPLES

        private void demonstrateFrameToSynset(IndexWord indexWord) throws JWNLException {
           
        Synset[] synsets = indexWord.getSenses();
            for(int g=0; g < synsets.length; g++)    {

                Synset synset = synsets[g];
               
                System.out.println("");
                System.out.println("Looking up \&quot;" + indexWord.getLemma() + "\&quot;:");
                System.out.println("synset: " + synset.toString());

                Word [] words = synset.getWords();
                for(int i=0; i < words.length; i++)    {

                    System.out.println("words" + i + ": " + words[i].getLemma());
                    Verb verb = (Verb)words[i];
               
                    // Get the frames for every verb of the synset.
                    String [] frames = verb.getVerbFrames();
                    for(int j=0; j < frames.length; j++)    {
                        System.out.println(words[i].getLemma() + " frame" + ": " + frames[j]);
                    }

                    // Instead of using getVerbFrames(), use the verb's verbFrameFlags bitset.
                    System.out.println("verbframe bitset: " + verb.getVerbFrameFlags());

                    BitSet bitset = verb.getVerbFrameFlags();
                    int[] frameNbrs = new int[bitset.cardinality()];
                    int lastIdx = 0;
                    for (int a = 0; a < frameNbrs.length; a++)  {

                        lastIdx = bitset.nextSetBit(lastIdx);
                        frameNbrs[a] = lastIdx;
                        System.out.println("bit" + a + ": " + frameNbrs[a]);
                        System.out.println("frame desc: " + net.didion.jwnl.data.VerbFrame.getFrame(lastIdx));
                        lastIdx++;  // If not incremented will always find same index.

                    }
                   
                    // Do the same with verb frame indicies.
                    int [] idxes = verb.getVerbFrameIndicies();
                    for(int k=0; k < idxes.length; k++)    {
                        System.out.println("idxes1" + k + ": " + idxes[k]);
                    }
                   
                }

                // Using the same three different methods, get frames for the synset as a whole, instead of for each verb within the synset.           
                System.out.println("synset verbframe bitset: " + synset.getVerbFrameFlags());

                int [] idxes = synset.getVerbFrameIndicies();
                for(int k=0; k < idxes.length; k++)    {
                    System.out.println("idxes" + k + ": " + idxes[k]);
                }
           
                String [] frames = synset.getVerbFrames();
                for(int j=0; j < frames.length; j++)    {
                    System.out.println("frame" + j + ": " + frames[j]);
                }
               
            }
        }