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.classify.feature;
23
24 import java.util.Collection;
25 import java.util.HashSet;
26 import java.util.Set;
27
28 /***
29 * This feature vector implementation stores a set of features.
30 * The order of features is not preserved and duplicates are discarded.
31 *
32 * <p>Instances of this class are not thread-safe and must be synchronized
33 * externally, if required.
34 *
35 * @author Christian Siefkes
36 * @version $Revision: 1.17 $, $Date: 2006/10/21 16:03:57 $, $Author: siefkes $
37 */
38 public class FeatureSet extends FeatureVector {
39
40 /***
41 * Constants specifying that feature frequencies are not considered
42 * when calculating {@linkplain FeatureVector#strength(Feature) strength}
43 * values.
44 */
45
46
47 /***
48 * Constants specifying that the logarithm of feature frequencies is
49 * considered when calculating {@linkplain FeatureVector#strength(Feature)
50 * strength} values (1.0 is added to log(<em>f</em>) to avoid the result
51 * becoming 0).
52 */
53
54
55 /***
56 * Constants specifying that the square root of feature frequencies is
57 * considered when calculating {@linkplain FeatureVector#strength(Feature)
58 * strength} values.
59 */
60
61
62 /***
63 * Constants specifying that feature frequencies are considered linear
64 * (as is) when calculating {@linkplain FeatureVector#strength(Feature)
65 * strength} values (a feature occurring twice as frequently will be
66 * twice as strong).
67 */
68
69
70
71 /***
72 * Store features in an set.
73 */
74 private final Set<Feature> store = new HashSet<Feature>();
75
76
77 /***
78 * The type of method used to consider feature frequencies when determining
79 * {@linkplain #strength(Feature) strength} values.
80 */
81
82
83 /***
84 * Creates a new instance.
85 */
86 public FeatureSet() {
87 super();
88 }
89
90
91 /***
92 * Creates a new instance.
93 *
94 * @param strengthMethod The type of method used to consider feature
95 * frequencies when determining {@linkplain #strength(Feature) strength}
96 * values -- should be one of the <code>STRENGTH</code> constants
97 * defined in this class
98 */
99
100
101
102
103
104
105
106 /***
107 * {@inheritDoc}
108 */
109
110
111
112
113
114
115 /***
116 * Returns the type of method used to consider feature frequencies when
117 * determining {@linkplain #strength(Feature) strength} values.
118 *
119 * @return the value of the attribute -- should be one of the
120 * <code>STRENGTH</code> constants defined in this class
121 */
122
123
124
125
126 /***
127 * Implementation of the hook provided by the superclass to ensure that
128 * the {@linkplain FeatureVector#getSummedStrength() summed strength}
129 * is updated correctly.
130 *
131 * @param feature the feature to add
132 */
133
134
135
136
137
138
139
140
141 /***
142 * {@inheritDoc}
143 */
144
145
146
147
148
149
150 /***
151 * {@inheritDoc}
152 */
153 protected Collection<Feature> store() {
154 return store;
155 }
156
157 /***
158 * Returns a strength value for a feature contained in this vector.
159 *
160 * @param feature the feature to consider
161 * @return a strength value for the specified feature
162 */
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186 }