Using the Jet API
In addition to running JET stand-alone, you can use
it as part of another application. In this case jet.jar (i.e., jet-jar-1xx.zip)
must be included among the libraries when running your application.
Here is a small sample program which uses Jet:
1 import Jet.*;
2 import Jet.Tipster.*;
3 import java.util.Vector;
4 import java.io.IOException;
5
6 class UseJet {
7
8 public static void main(String
args[]) throws IOException {
9 System.out.println("Starting
UseJet...");
10 JetTest.initializeFromConfig("C:/My
Documents/Jet/chunk3.properties");
11 String txt = "<TEXT>My
first sentence to be analyzed for class.</TEXT>";
12 Document doc =
new Document(txt);
13 Control.processDocument
(doc, "", true, 1);
14 Vector v = doc.annotationsOfType("constit");
15 for (int i=0;
i<v.size(); i++) {
16 Annotation
a = (Annotation) v.get(i);
17 System.out.println
("Constit " + a.get("cat") + " over " + doc.text(a));
18 }
19 }
20 }
and a brief explanation of this program:
-
10
-
initializeFromConfig loads a JET properties file and all the associated
resources (grammars, lexicons, patterns, HMMs, etc.). The properties
file should be the same as for a stand-alone run.
-
11-12
-
sets up the document to be analyzed. By default, only text inside
<TEXT> ... </TEXT> is analyzed.
-
13
-
processes the document. The parameters to processDocument
are
-
the document itself
-
a String S ... if output is generated by WriteSGML, it is written to file
response-S
-
true to pop up a window showing the processed document
-
an integer used to label the pop-up window ("Jet Document i")
-
14-17
-
retrieve annotations of type constit from the document and print
out, one per line, the cat feature of the annotation and the text
spanned by the annotation
-