1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
\r
5 <!-- Generated by javadoc (build 1.4.2_16) on Mon Mar 09 18:20:29 CET 2009 -->
\r
7 CARTImpl (FreeTTS 1.2)
\r
10 <META NAME="keywords" CONTENT="com.sun.speech.freetts.cart.CARTImpl class">
\r
12 <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style">
\r
14 <SCRIPT type="text/javascript">
\r
15 function windowTitle()
\r
17 parent.document.title="CARTImpl (FreeTTS 1.2)";
\r
23 <BODY BGCOLOR="white" onload="windowTitle();">
\r
26 <!-- ========= START OF TOP NAVBAR ======= -->
\r
27 <A NAME="navbar_top"><!-- --></A>
28 <A HREF="#skip-navbar_top" title="Skip navigation links"></A>
29 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
\r
31 <TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
\r
32 <A NAME="navbar_top_firstrow"><!-- --></A>
33 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
\r
34 <TR ALIGN="center" VALIGN="top">
\r
35 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
\r
36 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
\r
37 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
\r
38 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
\r
39 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
\r
40 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
\r
41 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
\r
45 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
\r
51 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
\r
52 PREV CLASS
\r
53 <A HREF="../../../../../com/sun/speech/freetts/cart/Durator.html" title="class in com.sun.speech.freetts.cart"><B>NEXT CLASS</B></A></FONT></TD>
\r
54 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
\r
55 <A HREF="../../../../../index.html" target="_top"><B>FRAMES</B></A>
\r
56 <A HREF="CARTImpl.html" target="_top"><B>NO FRAMES</B></A>
\r
57 <SCRIPT type="text/javascript">
\r
60 document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
\r
65 <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
\r
71 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
\r
72 SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
\r
73 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
\r
74 DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
\r
77 <A NAME="skip-navbar_top"></A>
78 <!-- ========= END OF TOP NAVBAR ========= -->
\r
81 <!-- ======== START OF CLASS DATA ======== -->
\r
84 com.sun.speech.freetts.cart</FONT>
\r
89 <IMG SRC="../../../../../resources/inherit.gif" ALT="extended by"><B>com.sun.speech.freetts.cart.CARTImpl</B>
\r
92 <DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../../../com/sun/speech/freetts/cart/CART.html" title="interface in com.sun.speech.freetts.cart">CART</A></DD>
\r
96 <DT>public class <B>CARTImpl</B><DT>extends java.lang.Object<DT>implements <A HREF="../../../../../com/sun/speech/freetts/cart/CART.html" title="interface in com.sun.speech.freetts.cart">CART</A></DL>
\r
99 Implementation of a Classification and Regression Tree (CART) that is
100 used more like a binary decision tree, with each node containing a
101 decision or a final value. The decision nodes in the CART trees
102 operate on an Item and have the following format:
105 NODE feat operand value qfalse
108 <p>Where <code>feat</code> is an string that represents a feature
109 to pass to the <code>findFeature</code> method of an item.
111 <p>The <code>value</code> represents the value to be compared against
112 the feature obtained from the item via the <code>feat</code> string.
113 The <code>operand</code> is the operation to do the comparison. The
114 available operands are as follows:
117 <li>< - the feature is less than value
118 <li>= - the feature is equal to the value
119 <li>> - the feature is greater than the value
120 <li>MATCHES - the feature matches the regular expression stored in value
121 <li>IN - [[[TODO: still guessing because none of the CART's in
122 Flite seem to use IN]]] the value is in the list defined by the
126 <p>[[[TODO: provide support for the IN operator.]]]
128 <p>For < and >, this CART coerces the value and feature to
129 float's. For =, this CART coerces the value and feature to string and
130 checks for string equality. For MATCHES, this CART uses the value as a
131 regular expression and compares the obtained feature to that.
133 <p>A CART is represented by an array in this implementation. The
134 <code>qfalse</code> value represents the index of the array to go to if
135 the comparison does not match. In this implementation, qtrue index
136 is always implied, and represents the next element in the
137 array. The root node of the CART is the first element in the array.
139 <p>The interpretations always start at the root node of the CART
140 and continue until a final node is found. The final nodes have the
147 <p>Where <code>value</code> represents the value of the node.
148 Reaching a final node indicates the interpretation is over and the
149 value of the node is the interpretation result.
\r
156 <!-- ======== NESTED CLASS SUMMARY ======== -->
\r
159 <!-- =========== FIELD SUMMARY =========== -->
\r
162 <!-- ======== CONSTRUCTOR SUMMARY ======== -->
\r
164 <A NAME="constructor_summary"><!-- --></A>
165 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
\r
166 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
\r
167 <TD COLSPAN=2><FONT SIZE="+2">
\r
168 <B>Constructor Summary</B></FONT></TD>
\r
170 <TR BGCOLOR="white" CLASS="TableRowColor">
\r
171 <TD><CODE><B><A HREF="../../../../../com/sun/speech/freetts/cart/CARTImpl.html#CARTImpl(java.io.BufferedReader, int)">CARTImpl</A></B>(java.io.BufferedReader reader,
172 int nodes)</CODE>
\r
175 Creates a new CART by reading from the given reader.</TD>
\r
177 <TR BGCOLOR="white" CLASS="TableRowColor">
\r
178 <TD><CODE><B><A HREF="../../../../../com/sun/speech/freetts/cart/CARTImpl.html#CARTImpl(java.net.URL)">CARTImpl</A></B>(java.net.URL url)</CODE>
\r
181 Creates a new CART by reading from the given URL.</TD>
\r
185 <!-- ========== METHOD SUMMARY =========== -->
\r
187 <A NAME="method_summary"><!-- --></A>
188 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
\r
189 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
\r
190 <TD COLSPAN=2><FONT SIZE="+2">
\r
191 <B>Method Summary</B></FONT></TD>
\r
193 <TR BGCOLOR="white" CLASS="TableRowColor">
\r
194 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
\r
195 <CODE> void</CODE></FONT></TD>
\r
196 <TD><CODE><B><A HREF="../../../../../com/sun/speech/freetts/cart/CARTImpl.html#dumpBinary(java.io.DataOutputStream)">dumpBinary</A></B>(java.io.DataOutputStream os)</CODE>
\r
199 Dumps this CART to the output stream.</TD>
\r
201 <TR BGCOLOR="white" CLASS="TableRowColor">
\r
202 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
\r
203 <CODE>protected com.sun.speech.freetts.cart.CARTImpl.Node</CODE></FONT></TD>
\r
204 <TD><CODE><B><A HREF="../../../../../com/sun/speech/freetts/cart/CARTImpl.html#getNode(java.lang.String, java.util.StringTokenizer, int)">getNode</A></B>(java.lang.String type,
205 java.util.StringTokenizer tokenizer,
206 int currentNode)</CODE>
\r
209 Gets the node based upon the type and tokenizer.</TD>
\r
211 <TR BGCOLOR="white" CLASS="TableRowColor">
\r
212 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
\r
213 <CODE> java.lang.Object</CODE></FONT></TD>
\r
214 <TD><CODE><B><A HREF="../../../../../com/sun/speech/freetts/cart/CARTImpl.html#interpret(com.sun.speech.freetts.Item)">interpret</A></B>(<A HREF="../../../../../com/sun/speech/freetts/Item.html" title="class in com.sun.speech.freetts">Item</A> item)</CODE>
\r
217 Passes the given item through this CART and returns the
218 interpretation.</TD>
\r
220 <TR BGCOLOR="white" CLASS="TableRowColor">
\r
221 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
\r
222 <CODE>static <A HREF="../../../../../com/sun/speech/freetts/cart/CART.html" title="interface in com.sun.speech.freetts.cart">CART</A></CODE></FONT></TD>
\r
223 <TD><CODE><B><A HREF="../../../../../com/sun/speech/freetts/cart/CARTImpl.html#loadBinary(java.nio.ByteBuffer)">loadBinary</A></B>(java.nio.ByteBuffer bb)</CODE>
\r
226 Loads a CART from the input byte buffer.</TD>
\r
228 <TR BGCOLOR="white" CLASS="TableRowColor">
\r
229 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
\r
230 <CODE>static <A HREF="../../../../../com/sun/speech/freetts/cart/CART.html" title="interface in com.sun.speech.freetts.cart">CART</A></CODE></FONT></TD>
\r
231 <TD><CODE><B><A HREF="../../../../../com/sun/speech/freetts/cart/CARTImpl.html#loadBinary(java.io.DataInputStream)">loadBinary</A></B>(java.io.DataInputStream is)</CODE>
\r
234 Loads a CART from the input stream.</TD>
\r
236 <TR BGCOLOR="white" CLASS="TableRowColor">
\r
237 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
\r
238 <CODE>protected void</CODE></FONT></TD>
\r
239 <TD><CODE><B><A HREF="../../../../../com/sun/speech/freetts/cart/CARTImpl.html#parseAndAdd(java.lang.String)">parseAndAdd</A></B>(java.lang.String line)</CODE>
\r
242 Creates a node from the given input line and add it to the CART.
245 <TR BGCOLOR="white" CLASS="TableRowColor">
\r
246 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
\r
247 <CODE>protected java.lang.Object</CODE></FONT></TD>
\r
248 <TD><CODE><B><A HREF="../../../../../com/sun/speech/freetts/cart/CARTImpl.html#parseValue(java.lang.String)">parseValue</A></B>(java.lang.String string)</CODE>
\r
251 Coerces a string into a value.</TD>
\r
254 <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
255 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
\r
256 <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
\r
257 <TD><B>Methods inherited from class java.lang.Object</B></TD>
\r
259 <TR BGCOLOR="white" CLASS="TableRowColor">
\r
260 <TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
\r
266 <!-- ============ FIELD DETAIL =========== -->
\r
269 <!-- ========= CONSTRUCTOR DETAIL ======== -->
\r
271 <A NAME="constructor_detail"><!-- --></A>
272 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
\r
273 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
\r
274 <TD COLSPAN=1><FONT SIZE="+2">
\r
275 <B>Constructor Detail</B></FONT></TD>
\r
279 <A NAME="CARTImpl(java.net.URL)"><!-- --></A><H3>
\r
282 public <B>CARTImpl</B>(java.net.URL url)
283 throws java.io.IOException</PRE>
\r
285 <DD>Creates a new CART by reading from the given URL.
\r
287 <DT><B>Parameters:</B><DD><CODE>url</CODE> - the location of the CART data
289 <DD><CODE>java.io.IOException</CODE> - if errors occur while reading the data</DL>
\r
292 <A NAME="CARTImpl(java.io.BufferedReader, int)"><!-- --></A><H3>
\r
295 public <B>CARTImpl</B>(java.io.BufferedReader reader,
297 throws java.io.IOException</PRE>
\r
299 <DD>Creates a new CART by reading from the given reader.
\r
301 <DT><B>Parameters:</B><DD><CODE>reader</CODE> - the source of the CART data<DD><CODE>nodes</CODE> - the number of nodes to read for this cart
303 <DD><CODE>java.io.IOException</CODE> - if errors occur while reading the data</DL>
\r
305 <!-- ============ METHOD DETAIL ========== -->
\r
307 <A NAME="method_detail"><!-- --></A>
308 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
\r
309 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
\r
310 <TD COLSPAN=1><FONT SIZE="+2">
\r
311 <B>Method Detail</B></FONT></TD>
\r
315 <A NAME="dumpBinary(java.io.DataOutputStream)"><!-- --></A><H3>
\r
318 public void <B>dumpBinary</B>(java.io.DataOutputStream os)
319 throws java.io.IOException</PRE>
\r
321 <DD>Dumps this CART to the output stream.
\r
324 <DT><B>Specified by:</B><DD><CODE><A HREF="../../../../../com/sun/speech/freetts/cart/CART.html#dumpBinary(java.io.DataOutputStream)">dumpBinary</A></CODE> in interface <CODE><A HREF="../../../../../com/sun/speech/freetts/cart/CART.html" title="interface in com.sun.speech.freetts.cart">CART</A></CODE></DL>
\r
327 <DT><B>Parameters:</B><DD><CODE>os</CODE> - the output stream
329 <DD><CODE>java.io.IOException</CODE> - if an error occurs during output</DL>
\r
334 <A NAME="loadBinary(java.nio.ByteBuffer)"><!-- --></A><H3>
\r
337 public static <A HREF="../../../../../com/sun/speech/freetts/cart/CART.html" title="interface in com.sun.speech.freetts.cart">CART</A> <B>loadBinary</B>(java.nio.ByteBuffer bb)
338 throws java.io.IOException</PRE>
\r
340 <DD>Loads a CART from the input byte buffer.
\r
346 <DT><B>Parameters:</B><DD><CODE>bb</CODE> - the byte buffer
347 <DT><B>Returns:</B><DD>the CART
349 <DD><CODE>java.io.IOException</CODE> - if an error occurs during output
351 Note that cart nodes are really saved as strings that
352 have to be parsed.</DL>
\r
357 <A NAME="loadBinary(java.io.DataInputStream)"><!-- --></A><H3>
\r
360 public static <A HREF="../../../../../com/sun/speech/freetts/cart/CART.html" title="interface in com.sun.speech.freetts.cart">CART</A> <B>loadBinary</B>(java.io.DataInputStream is)
361 throws java.io.IOException</PRE>
\r
363 <DD>Loads a CART from the input stream.
\r
369 <DT><B>Parameters:</B><DD><CODE>is</CODE> - the input stream
370 <DT><B>Returns:</B><DD>the CART
372 <DD><CODE>java.io.IOException</CODE> - if an error occurs during output
374 Note that cart nodes are really saved as strings that
375 have to be parsed.</DL>
\r
380 <A NAME="parseAndAdd(java.lang.String)"><!-- --></A><H3>
\r
383 protected void <B>parseAndAdd</B>(java.lang.String line)</PRE>
\r
385 <DD>Creates a node from the given input line and add it to the CART.
386 It expects the TOTAL line to come before any of the nodes.
\r
392 <DT><B>Parameters:</B><DD><CODE>line</CODE> - a line of input to parse</DL>
\r
397 <A NAME="getNode(java.lang.String, java.util.StringTokenizer, int)"><!-- --></A><H3>
\r
400 protected com.sun.speech.freetts.cart.CARTImpl.Node <B>getNode</B>(java.lang.String type,
401 java.util.StringTokenizer tokenizer,
402 int currentNode)</PRE>
\r
404 <DD>Gets the node based upon the type and tokenizer.
\r
410 <DT><B>Parameters:</B><DD><CODE>type</CODE> - <code>NODE</code> or <code>LEAF</code><DD><CODE>tokenizer</CODE> - the StringTokenizer containing the data to get<DD><CODE>currentNode</CODE> - the index of the current node we're looking at
411 <DT><B>Returns:</B><DD>the node</DL>
\r
416 <A NAME="parseValue(java.lang.String)"><!-- --></A><H3>
\r
419 protected java.lang.Object <B>parseValue</B>(java.lang.String string)</PRE>
\r
421 <DD>Coerces a string into a value.
\r
427 <DT><B>Parameters:</B><DD><CODE>string</CODE> - of the form "type(value)"; for example, "Float(2.3)"
428 <DT><B>Returns:</B><DD>the value</DL>
\r
433 <A NAME="interpret(com.sun.speech.freetts.Item)"><!-- --></A><H3>
\r
436 public java.lang.Object <B>interpret</B>(<A HREF="../../../../../com/sun/speech/freetts/Item.html" title="class in com.sun.speech.freetts">Item</A> item)</PRE>
\r
438 <DD>Passes the given item through this CART and returns the
442 <DT><B>Specified by:</B><DD><CODE><A HREF="../../../../../com/sun/speech/freetts/cart/CART.html#interpret(com.sun.speech.freetts.Item)">interpret</A></CODE> in interface <CODE><A HREF="../../../../../com/sun/speech/freetts/cart/CART.html" title="interface in com.sun.speech.freetts.cart">CART</A></CODE></DL>
\r
445 <DT><B>Parameters:</B><DD><CODE>item</CODE> - the item to analyze
446 <DT><B>Returns:</B><DD>the interpretation</DL>
\r
449 <!-- ========= END OF CLASS DATA ========= -->
\r
453 <!-- ======= START OF BOTTOM NAVBAR ====== -->
\r
454 <A NAME="navbar_bottom"><!-- --></A>
455 <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
456 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
\r
458 <TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
\r
459 <A NAME="navbar_bottom_firstrow"><!-- --></A>
460 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
\r
461 <TR ALIGN="center" VALIGN="top">
\r
462 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
\r
463 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
\r
464 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
\r
465 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
\r
466 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
\r
467 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
\r
468 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
\r
472 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
\r
478 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
\r
479 PREV CLASS
\r
480 <A HREF="../../../../../com/sun/speech/freetts/cart/Durator.html" title="class in com.sun.speech.freetts.cart"><B>NEXT CLASS</B></A></FONT></TD>
\r
481 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
\r
482 <A HREF="../../../../../index.html" target="_top"><B>FRAMES</B></A>
\r
483 <A HREF="CARTImpl.html" target="_top"><B>NO FRAMES</B></A>
\r
484 <SCRIPT type="text/javascript">
\r
487 document.writeln('<A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>');
\r
492 <A HREF="../../../../../allclasses-noframe.html"><B>All Classes</B></A>
\r
498 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
\r
499 SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
\r
500 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
\r
501 DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
\r
504 <A NAME="skip-navbar_bottom"></A>
505 <!-- ======== END OF BOTTOM NAVBAR ======= -->
\r