2 * Copyright 2001 Sun Microsystems, Inc.
4 * See the file "license.terms" for information on usage and
5 * redistribution of this file, and for a DISCLAIMER OF ALL
9 import junit.framework.*;
13 import com.sun.speech.freetts.*;
16 * JUnit Tests for the Utterance class
20 public class PartOfSpeechTests extends TestCase {
24 * Creates the set of UtteranceTests
26 * @param name the name of the test.
28 public PartOfSpeechTests(String name) {
33 * Common code run before each test
35 protected void setUp() {
37 URL url = new URL("file:./part_of_speech.txt");
38 pos = new PartOfSpeechImpl(url, "content");
39 } catch (IOException ioe) {
40 System.out.println("Can't open part_of_speech.txt");
45 * test that checks for proer determination of part-of-speech
47 public void testPartOfSpeech() {
48 assertTrue(pos.getPartOfSpeech("of").equals("in"));
49 assertTrue(pos.getPartOfSpeech("from").equals("in"));
50 assertTrue(pos.getPartOfSpeech("about").equals("in"));
51 assertTrue(pos.getPartOfSpeech("up").equals("in"));
52 assertTrue(pos.getPartOfSpeech("down").equals("in"));
54 assertTrue(pos.getPartOfSpeech("each").equals("det"));
55 assertTrue(pos.getPartOfSpeech("both").equals("det"));
56 assertTrue(pos.getPartOfSpeech("no").equals("det"));
57 assertTrue(pos.getPartOfSpeech("this").equals("det"));
59 assertTrue(pos.getPartOfSpeech("will").equals("md"));
60 assertTrue(pos.getPartOfSpeech("can").equals("md"));
61 assertTrue(pos.getPartOfSpeech("ought").equals("md"));
62 assertTrue(pos.getPartOfSpeech("might").equals("md"));
64 assertTrue(pos.getPartOfSpeech("and").equals("cc"));
65 assertTrue(pos.getPartOfSpeech("but").equals("cc"));
66 assertTrue(pos.getPartOfSpeech("or").equals("cc"));
67 assertTrue(pos.getPartOfSpeech("yet").equals("cc"));
69 assertTrue(pos.getPartOfSpeech("who").equals("wp"));
70 assertTrue(pos.getPartOfSpeech("what").equals("wp"));
71 assertTrue(pos.getPartOfSpeech("where").equals("wp"));
72 assertTrue(pos.getPartOfSpeech("when").equals("wp"));
74 assertTrue(pos.getPartOfSpeech("her").equals("pps"));
75 assertTrue(pos.getPartOfSpeech("his").equals("pps"));
76 assertTrue(pos.getPartOfSpeech("our").equals("pps"));
77 assertTrue(pos.getPartOfSpeech("mine").equals("pps"));
79 assertTrue(pos.getPartOfSpeech("is").equals("aux"));
80 assertTrue(pos.getPartOfSpeech("am").equals("aux"));
81 assertTrue(pos.getPartOfSpeech("are").equals("aux"));
82 assertTrue(pos.getPartOfSpeech("was").equals("aux"));
83 assertTrue(pos.getPartOfSpeech("were").equals("aux"));
84 assertTrue(pos.getPartOfSpeech("be").equals("aux"));
86 assertTrue(pos.getPartOfSpeech(".").equals("punc"));
87 assertTrue(pos.getPartOfSpeech(",").equals("punc"));
88 assertTrue(pos.getPartOfSpeech(":").equals("punc"));
89 assertTrue(pos.getPartOfSpeech(";").equals("punc"));
90 assertTrue(pos.getPartOfSpeech("'").equals("punc"));
91 assertTrue(pos.getPartOfSpeech("(").equals("punc"));
92 assertTrue(pos.getPartOfSpeech("?").equals("punc"));
93 assertTrue(pos.getPartOfSpeech(")").equals("punc"));
95 assertTrue(pos.getPartOfSpeech("bear").equals("content"));
96 assertTrue(pos.getPartOfSpeech("lamere").equals("content"));
97 assertTrue(pos.getPartOfSpeech("walker").equals("content"));
98 assertTrue(pos.getPartOfSpeech("kwok").equals("content"));
99 assertTrue(pos.getPartOfSpeech("cumquat").equals("content"));
100 assertTrue(pos.getPartOfSpeech("marshmellow").equals("content"));
101 assertTrue(pos.getPartOfSpeech("tryptich").equals("content"));
107 * Common code run after each test
109 protected void tearDown() {
115 * Factory method that creates the test suite.
117 * @return the test suite.
119 public static Test suite() {
120 return new TestSuite(PartOfSpeechTests.class);
126 * Main entry point for this test suite.
128 * @param args the command line arguments.
130 public static void main(String[] args) {
131 junit.textui.TestRunner.run(suite());