View Javadoc

1   /*
2    * Copyright (C) 2004 Christian Siefkes <christian@siefkes.net>.
3    * Development of this software is supported by the German Research Society,
4    * Berlin-Brandenburg Graduate School in Distributed Information Systems
5    * (DFG grant no. GRK 316).
6    *
7    * This library is free software; you can redistribute it and/or
8    * modify it under the terms of the GNU Lesser General Public
9    * License as published by the Free Software Foundation; either
10   * version 2.1 of the License, or (at your option) any later version.
11   *
12   * This library is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this library; if not, visit
19   * http://www.gnu.org/licenses/lgpl.html or write to the Free Software
20   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
21   */
22  package de.fu_berlin.ties.extract.amend;
23  
24  import de.fu_berlin.ties.classify.feature.FeatureVector;
25  import de.fu_berlin.ties.combi.CombinationState;
26  import de.fu_berlin.ties.text.TokenDetails;
27  
28  /***
29   * Extends the {@link de.fu_berlin.ties.extract.amend.ContextDetails} class by
30   * also storing the expected (true) and predicted state on of a token.
31   * Instances of this class are immutable and thus thread-safe.
32   * 
33   * @author Christian Siefkes
34   * @version $Revision: 1.1 $, $Date: 2004/11/19 14:04:51 $, $Author: siefkes $
35   */
36  public class TrainingContextDetails extends ContextDetails {
37  
38      /***
39       * The expected (true) <code>CombinationState</code> for the token.
40       */
41      private final CombinationState expectedState;
42  
43      /***
44       * The <code>CombinationState</code> predicted by the current classification
45       * model for the token if there was an classification error; or
46       * <code>null</code> if the expected state was correctly predicted.
47       */
48      private final CombinationState predictedState;
49  
50  
51      /***
52       * Creates a new instance.
53       *
54       * @param theToken the token to represent
55       * @param tokenRep the repetition of the token in the document (counting
56       * starts with 0, as the first occurrence is the "0th repetition")
57       * @param tokenIndex the index of the token in the document (counting
58       * starts with 0 for the very first token)
59       * @param wsBefore whether there is whitespace before the main
60       * <code>token</code> (either at the end of <code>left</code> or in the
61       * preceding element)
62       * @param features a feature vector representing the context of the token
63       * @param predicted the <code>CombinationState</code> predicted by the
64       * current classification model for this token if there was an
65       * classification error; or <code>null</code> if the expected state was
66       * correctly predicted
67       * @param expected the expected (true) <code>CombinationState</code> for
68       * this token
69       */
70      public TrainingContextDetails(final String theToken, final int tokenRep,
71              final int tokenIndex, final boolean wsBefore,
72              final FeatureVector features, final CombinationState predicted,
73              final CombinationState expected) {
74          super(theToken, tokenRep, tokenIndex, wsBefore, features);
75          predictedState = predicted;
76          expectedState = expected;
77      }
78  
79      /***
80       * Creates a new instance, re-using field values from a {@link TokenDetails}
81       * instance.
82       *
83       * @param orgDetails an instance of the "grandparent" class whose member
84       * fields are re-used to initialize this instance
85       * @param features a feature vector representing the context of the token
86       * @param predicted the <code>CombinationState</code> predicted by the
87       * current classification model for this token if there was an
88       * classification error; or <code>null</code> if the expected state was
89       * correctly predicted
90       * @param expected the expected (true) <code>CombinationState</code> for
91       * this token
92       */
93      public TrainingContextDetails(final TokenDetails orgDetails,
94              final FeatureVector features, final CombinationState predicted,
95              final CombinationState expected) {
96          this(orgDetails.getToken(), orgDetails.getRep(), orgDetails.getIndex(),
97                  orgDetails.isWhitespaceBefore(), features, predicted, expected);
98      }
99  
100 
101     /***
102      * Returns the expected (true) <code>CombinationState</code> for this
103      * instance.
104      *
105      * @return the value of the attribute
106      */
107     public CombinationState getExpectedState() {
108         return expectedState;
109     }
110 
111     /***
112      * Returns the <code>CombinationState</code> predicted by the current
113      * classification model for this token if there was an classification error;
114      * or <code>null</code> if the expected state was correctly predicted.
115      *
116      * @return the value of the attribute
117      */
118     public CombinationState getPredictedState() {
119         return predictedState;
120     }
121 
122 }