HaoWei He
2 min readOct 18, 2020

--

[ToolKit] VerbNet Api Tutorial

(This article is reposted from my previous blog website)

To implement the language understanding, we leverage some resource like syntatic frame and verbnet is one of them.

What’s verbnet?
Verbnet is a class-based verb Lexicon. Each verb in the verbnet is described by it’s semantic role, retractions on the argument and frames consisting of a syntactic description and semantic predicates with a temporal function.

Vebnet refined its subclass to achieve syntactics and semantic coherence.

Here, we just need a few steps to check out what’s happening and what kind of data we can get.

1. downlaod jar: http://projects.csail.mit.edu/jverbnet/

2. download : http://verbs.colorado.edu/verbnet_downloads/downloads.html

3. sample code :

Noted: I mkdir folder named “Data” and put the downloaded corpus in it.

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;
import java.util.Set;

import edu.mit.jverbnet.data.FrameType;
import edu.mit.jverbnet.data.IFrame;
import edu.mit.jverbnet.data.IMember;
import edu.mit.jverbnet.data.IVerbClass;
import edu.mit.jverbnet.data.IWordnetKey;
import edu.mit.jverbnet.data.WordnetKey;
import edu.mit.jverbnet.index.IVerbIndex;
import edu.mit.jverbnet.index.VerbIndex;
public class demo {

public static void main(String[] args) throws IOException {
String pathToVerbnet = “Data\\”;
URL url = new URL(“file”, null , pathToVerbnet );

// construct the index and open it
IVerbIndex index = new VerbIndex ( url );
index.open ();

// look up a verb class and print out some info
IVerbClass verb = index.getRootVerb (“accept-77”);
System.out.println();
IMember member = verb.getMembers().get(0) ;
Set < IWordnetKey > keys = member . getWordnetTypes (). keySet ();
IFrame frame = verb.getFrames (). get (0) ;
FrameType type = frame . getPrimaryType ();
String example = frame . getExamples (). get (0) ;
System . out . println (“id: “ + verb . getID ());
System . out . println (“ first wordnet keys : “ + keys );
System . out . println (“ first frame type : “ + type . getID ());
System . out . println (“ first example : “ + example );

}

}

output:
id: accept-77
first wordnet keys : [accept%2:31:01, accept%2:31:03]
first frame type : NP V how S
first example : I accept how you do it.

Noted:

  1. wordnet keys is senses of this word.
  2. One word can have several senses. You can take it as different definitions for a word.

--

--

HaoWei He
0 Followers

Software Engineer. Interested in NLP, algorithm, Data Science & Cycling.