Révision 2393
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/query/MatchUtils.java (revision 2393) | ||
---|---|---|
13 | 13 |
public static ArrayList<Integer> matchesCoveredByB(List<Match> list, List<Match> b) { |
14 | 14 |
int ai=0, bi=0; |
15 | 15 |
ArrayList<Integer> result = new ArrayList<Integer>(); |
16 |
|
|
16 |
|
|
17 | 17 |
while (ai < list.size() && bi < b.size() ) { |
18 | 18 |
if (b.get(bi).contains(list.get(ai))) { |
19 | 19 |
result.add(bi); |
... | ... | |
22 | 22 |
ai++; |
23 | 23 |
} |
24 | 24 |
} |
25 |
|
|
25 |
|
|
26 | 26 |
return result; |
27 | 27 |
} |
28 |
|
|
29 |
/** |
|
30 |
* |
|
31 |
* @param match |
|
32 |
* @return array of int position from a Match |
|
33 |
*/ |
|
34 |
public int[] toPositions(Match match) { |
|
35 |
return toPositions(match, match); |
|
36 |
} |
|
37 |
|
|
38 |
/** |
|
39 |
* |
|
40 |
* @param match1 |
|
41 |
* @param match2 |
|
42 |
* @return array of int position from a Match start to another Match end |
|
43 |
*/ |
|
44 |
public static int[] toPositions(Match match1, Match match2) { |
|
45 |
int len = match2.end - match1.start + 1; |
|
46 |
|
|
47 |
if (len <= 0 ) { |
|
48 |
return new int[0]; |
|
49 |
} else if (len == 1) { |
|
50 |
return new int[] {match1.start}; |
|
51 |
} else if (len == 2) { |
|
52 |
return new int[] {match1.start, match2.end}; |
|
53 |
} else { |
|
54 |
int[] positions = new int[len]; |
|
55 |
int n = 0; |
|
56 |
for (int i = match1.start ; i <= match2.end ; i++) { |
|
57 |
positions[n++] = i; |
|
58 |
} |
|
59 |
return positions; |
|
60 |
} |
|
61 |
} |
|
28 | 62 |
} |
Formats disponibles : Unified diff