update standards version
[debian/freetts] / tests / PartOfSpeechTests.java
1 /**
2  * Copyright 2001 Sun Microsystems, Inc.
3  * 
4  * See the file "license.terms" for information on usage and
5  * redistribution of this file, and for a DISCLAIMER OF ALL 
6  * WARRANTIES.
7  */
8 package tests;
9 import junit.framework.*;
10 import java.util.*;
11 import java.io.*;
12 import java.net.URL;
13 import com.sun.speech.freetts.*;
14
15 /**
16  * JUnit Tests for the Utterance class
17  * 
18  * @version 1.0
19  */
20 public class PartOfSpeechTests extends TestCase {
21     PartOfSpeech pos;
22
23     /**
24      * Creates the set of UtteranceTests
25      * 
26      * @param  name the name of the test.
27      */
28     public PartOfSpeechTests(String name) {
29         super(name);
30     }
31
32     /**
33      * Common code run before each test
34      */
35     protected void setUp()  {
36         try {
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");
41         }
42     }
43
44     /**
45      * test that checks for proer determination of part-of-speech
46      */
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"));
53
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"));
58
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"));
63
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"));
68
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"));
73
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"));
78
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"));
85
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"));
94
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"));
102     }
103
104
105
106     /**
107      * Common code run after each test
108      */
109     protected void tearDown() {
110         //utterance = null;
111     } 
112
113
114     /**
115      * Factory method that creates the test suite.
116      * 
117      * @return the test suite.
118      */
119     public static Test suite() {
120         return new TestSuite(PartOfSpeechTests.class);
121     } 
122
123
124
125     /**
126      * Main entry point for this test suite.
127      * 
128      * @param  args    the command line arguments.
129      */
130     public static void main(String[] args) {
131         junit.textui.TestRunner.run(suite());
132     } 
133 }
134
135
136