Révision 3457
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/ImporterCorpusOkapiMacro.groovy (revision 3457) | ||
---|---|---|
111 | 111 |
println "("+regex_identifiants_sujets.size()+")" + regex_identifiants_sujets |
112 | 112 |
if (query.length() > maxCQLLimit) { |
113 | 113 |
monitorShowError("Erreur : impossible de créer le sous-corpus, la requête CQL est trop longue (${query.length()}).") |
114 |
return |
|
114 |
return
|
|
115 | 115 |
} |
116 |
|
|
116 | 117 |
} |
117 | 118 |
|
119 |
for (String id : liste_identifiants_sujets) { |
|
120 |
if (!id.matches(regex_identifiants_sujets)) { |
|
121 |
println "ERROR: $id not matching with regex" |
|
122 |
} else { |
|
123 |
//println " OK: $id matching with regex" |
|
124 |
} |
|
125 |
} |
|
126 |
|
|
118 | 127 |
println "CQL = $query" |
119 | 128 |
|
120 | 129 |
Subcorpus sub = parentCorpus.createSubcorpus(new CQLQuery(query), nom_sous_corpus) |
... | ... | |
123 | 132 |
// println nom_sous_corpus+" est composé de "+nb_matches+" éléments." |
124 | 133 |
|
125 | 134 |
int s = sub.getSize() |
126 |
if (nb_matches == nb_identifiers) { |
|
135 |
|
|
127 | 136 |
println "$nom_sous_corpus subcorpus is created." |
128 | 137 |
monitor.syncExec(new Runnable() { |
129 | 138 |
public void run() { |
... | ... | |
131 | 140 |
CorporaView.expand(parentCorpus); |
132 | 141 |
} |
133 | 142 |
}); |
134 |
} else { |
|
135 |
println "Error: bad query, $nb_matches elements in sub-corpus instead of $nb_identifiers" |
|
136 |
monitorShowError("Error: bad query, $nb_matches elements in sub-corpus instead of $nb_identifiers") |
|
143 |
|
|
144 |
if (nb_matches != nb_identifiers) { |
|
145 |
println "Warning $nb_matches elements in sub-corpus instead of $nb_identifiers identifiers" |
|
146 |
// monitorShowError("Error: bad query, $nb_matches elements in sub-corpus instead of $nb_identifiers") |
|
137 | 147 |
} |
138 | 148 |
|
139 | 149 |
// UTILS UTILS UTILS UTILS UTILS UTILS UTILS |
... | ... | |
143 | 153 |
breakNode(origtree, "", 0) |
144 | 154 |
def CQL1 = list.join("|") |
145 | 155 |
def CQL2 = writeNode(origtree) |
156 |
//CQL2 = CQL2.replaceAll("\\(\\[()\\]\\)", "") |
|
157 |
|
|
158 |
|
|
146 | 159 |
if (CQL1.length() < CQL2.length()) { |
147 | 160 |
return CQL1; |
148 | 161 |
} else { |
162 |
CQL2 = CQL2.replace("(\\d)", "\\d") |
|
163 |
CQL2 = CQL2.replaceAll("\\(\\[([0-9])-([0-9])\\]\\)", "[\$1-\$2]") // ([0-9]) -> [0-9] |
|
164 |
CQL2 = CQL2.replaceAll("\\(([0-9])\\|([0-9])\\)", "[\$1\$2]") // (1|2) -> [12] |
|
149 | 165 |
return CQL2; |
150 | 166 |
} |
151 | 167 |
} |
... | ... | |
191 | 207 |
} |
192 | 208 |
|
193 | 209 |
if (ss.matches("([0-9]\\|){2,10}[0-9]")) ss = "["+ss.replace("|", "") +"]" |
194 |
if (ss == "[0123456789]") ss = "[0-9]"
|
|
210 |
if (ss == "[0123456789]") ss = "\\d"
|
|
195 | 211 |
if (ss == "[012345678]") ss = "[0-8]" |
196 | 212 |
if (ss == "[01234567]") ss = "[0-7]" |
197 | 213 |
if (ss == "[0123456]") ss = "[0-6]" |
214 |
if (ss == "[012345]") ss = "[0-5]" |
|
198 | 215 |
if (ss == "[123456789]") ss = "[1-9]" |
199 | 216 |
if (ss == "[12345678]") ss = "[1-8]" |
200 | 217 |
if (ss == "[1234567]") ss = "[1-7]" |
201 | 218 |
if (ss == "[123456]") ss = "[1-6]" |
219 |
if (ss == "[12345]") ss = "[1-5]" |
|
202 | 220 |
if (ss == "[23456789]") ss = "[2-9]" |
203 | 221 |
if (ss == "[2345678]") ss = "[2-8]" |
204 | 222 |
if (ss == "[3456789]") ss = "[3-9]" |
... | ... | |
206 | 224 |
if (ss == "[456789]") ss = "[4-9]" |
207 | 225 |
if (ss == "[45678]") ss = "[4-8]" |
208 | 226 |
|
227 |
if (ss == "[012345689]") ss = "[0-689]" |
|
228 |
if (ss == "[012356789]") ss = "[0-35-9]"; |
|
229 |
if (ss == "[012456789]") ss = "[0-24-9]"; |
|
209 | 230 |
s += ss |
210 | 231 |
|
211 | 232 |
if (tree.size() > 1) s += ")" |
Formats disponibles : Unified diff