1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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.text.TokenDetails;
26
27 /***
28 * Extends the {@link de.fu_berlin.ties.text.TokenDetails} class by also storing
29 * the context of a token. Instances of this class are immutable and thus
30 * thread-safe.
31 *
32 * @author Christian Siefkes
33 * @version $Revision: 1.2 $, $Date: 2004/11/19 14:04:51 $, $Author: siefkes $
34 */
35 public class ContextDetails extends TokenDetails {
36
37 /***
38 * A feature vector representing the context of the token.
39 */
40 private final FeatureVector context;
41
42
43 /***
44 * Creates a new instance.
45 *
46 * @param theToken the token to represent
47 * @param tokenRep the repetition of the token in the document (counting
48 * starts with 0, as the first occurrence is the "0th repetition")
49 * @param tokenIndex the index of the token in the document (counting
50 * starts with 0 for the very first token)
51 * @param wsBefore whether there is whitespace before the main
52 * <code>token</code> (either at the end of <code>left</code> or in the
53 * preceding element)
54 * @param features a feature vector representing the context of the token
55 */
56 public ContextDetails(final String theToken, final int tokenRep,
57 final int tokenIndex, final boolean wsBefore,
58 final FeatureVector features) {
59 super(theToken, tokenRep, tokenIndex, wsBefore);
60 context = features;
61 }
62
63 /***
64 * Creates a new instance, re-using field values from a {@link TokenDetails}
65 * instance.
66 *
67 * @param orgDetails an instance of the parent class whose member fields
68 * are re-used to initialize this instance
69 * @param features a feature vector representing the context of the token
70 */
71 public ContextDetails(final TokenDetails orgDetails,
72 final FeatureVector features) {
73 this(orgDetails.getToken(), orgDetails.getRep(), orgDetails.getIndex(),
74 orgDetails.isWhitespaceBefore(), features);
75 }
76
77
78 /***
79 * Returns a feature vector representing the context of the token.
80 * @return the value of the attribute
81 */
82 public FeatureVector getContext() {
83 return context;
84 }
85
86 }