34 |
34 |
import org.txm.searchengine.cqp.corpus.Property;
|
35 |
35 |
import org.txm.searchengine.cqp.corpus.query.Occurrence;
|
36 |
36 |
|
37 |
|
// TODO: Auto-generated Javadoc
|
38 |
37 |
/**
|
39 |
|
* contains the signature of the line all properties value and counts @ author
|
40 |
|
* mdecorde.
|
|
38 |
* Contains the signature of the line all properties value and counts
|
|
39 |
*
|
|
40 |
* @author mdecorde
|
|
41 |
*
|
41 |
42 |
*/
|
42 |
43 |
public class Line {
|
43 |
|
|
|
44 |
|
44 |
45 |
/** The Units property. */
|
45 |
46 |
public List<List<String>> UnitsProperty; // the values, for each property there is a list of property values
|
46 |
|
|
|
47 |
|
47 |
48 |
/** The Units ids. */
|
48 |
49 |
public List<int[]> UnitsIds; // the values, for each property there is a list of property values
|
49 |
|
|
|
50 |
|
50 |
51 |
/** The properties. */
|
51 |
52 |
public List<Property> properties = new ArrayList<Property>(); // the properties name UnitsProperty and properties have the same order
|
52 |
|
|
|
53 |
|
53 |
54 |
/** The signature. */
|
54 |
55 |
private String signature;
|
55 |
|
|
|
56 |
|
56 |
57 |
/** The counts. */
|
57 |
58 |
private int[] counts;
|
58 |
|
|
|
59 |
|
59 |
60 |
/** The total. */
|
60 |
61 |
private int total;
|
61 |
|
|
|
62 |
|
62 |
63 |
/** The frelatif. */
|
63 |
64 |
private float frelatif = 0;
|
64 |
|
|
|
65 |
|
65 |
66 |
/** The str. */
|
66 |
67 |
private String str;
|
67 |
68 |
|
... | ... | |
105 |
106 |
if (signature == null) {
|
106 |
107 |
//System.out.println("getSignature() props size "+properties.size());
|
107 |
108 |
signature = ""; //$NON-NLS-1$
|
108 |
|
for (int i = 0; i < properties.size(); i++)
|
109 |
|
for (int s : UnitsIds.get(i))
|
|
109 |
for (int i = 0; i < properties.size(); i++) {
|
|
110 |
for (int s : UnitsIds.get(i)) {
|
110 |
111 |
signature += "[" + s + "]"; //$NON-NLS-1$ //$NON-NLS-2$
|
|
112 |
}
|
|
113 |
}
|
111 |
114 |
}
|
112 |
115 |
return signature;
|
113 |
116 |
}
|
... | ... | |
121 |
124 |
public void setCounts(int[] c, float f) {
|
122 |
125 |
counts = c;
|
123 |
126 |
total = 0;
|
124 |
|
for (int i = 0; i < c.length; i++)
|
|
127 |
for (int i = 0; i < c.length; i++) {
|
125 |
128 |
total += c[i];
|
|
129 |
}
|
126 |
130 |
frelatif = f;
|
127 |
131 |
}
|
128 |
132 |
|
... | ... | |
142 |
146 |
* @return the frequency
|
143 |
147 |
*/
|
144 |
148 |
public int getFrequency(int i) {
|
145 |
|
if (i >= counts.length || i < 0)
|
|
149 |
if (i >= counts.length || i < 0) {
|
146 |
150 |
return -1;
|
|
151 |
}
|
147 |
152 |
return counts[i];
|
148 |
153 |
}
|
149 |
154 |
|
... | ... | |
179 |
184 |
*/
|
180 |
185 |
@Override
|
181 |
186 |
public String toString() {
|
182 |
|
if (str == null)
|
|
187 |
if (str == null) {
|
183 |
188 |
str = this.toString("_"); //$NON-NLS-1$
|
|
189 |
}
|
184 |
190 |
return str;
|
185 |
191 |
}
|
186 |
192 |
|
... | ... | |
198 |
204 |
break;
|
199 |
205 |
}
|
200 |
206 |
|
201 |
|
for (int i = 0; i < len; i++)// for each token
|
202 |
|
{
|
|
207 |
for (int i = 0; i < len; i++) { // for each token
|
203 |
208 |
for (int j = 0; j < properties.size(); j++) {
|
204 |
209 |
rez += UnitsProperty.get(j).get(i);
|
205 |
210 |
if (j < properties.size() - 1) {
|
206 |
211 |
rez += separator;
|
207 |
212 |
}
|
208 |
213 |
}
|
209 |
|
if (i < len - 1)
|
|
214 |
|
|
215 |
if (i < len - 1) {
|
210 |
216 |
rez += " "; //$NON-NLS-1$
|
|
217 |
}
|
211 |
218 |
}
|
212 |
219 |
return rez;
|
213 |
220 |
}
|
... | ... | |
243 |
250 |
/**
|
244 |
251 |
* The Class Signature.
|
245 |
252 |
*/
|
246 |
|
public class Signature {
|
247 |
|
|
|
253 |
public static class Signature {
|
|
254 |
|
248 |
255 |
/** The sign. */
|
249 |
256 |
Occurrence[] sign;// [token][prop]
|
250 |
257 |
|
... | ... | |
255 |
262 |
* @return true, if successful
|
256 |
263 |
*/
|
257 |
264 |
public boolean equals(Signature s) {
|
258 |
|
if (sign.length != s.sign.length)
|
|
265 |
|
|
266 |
if (sign.length != s.sign.length) {
|
259 |
267 |
return false;
|
|
268 |
}
|
260 |
269 |
|
261 |
|
for (int i = 0; i < sign.length; i++)
|
262 |
|
if (!sign[i].equals(s.sign[i]))
|
|
270 |
for (int i = 0; i < sign.length; i++) {
|
|
271 |
if (!sign[i].equals(s.sign[i])) {
|
263 |
272 |
return false;
|
|
273 |
}
|
|
274 |
}
|
264 |
275 |
return true;
|
265 |
276 |
}
|
266 |
277 |
}
|