Révision 1804
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/bfm/compiler.groovy (revision 1804) | ||
|---|---|---|
| 755 | 755 |
return false; |
| 756 | 756 |
} |
| 757 | 757 |
|
| 758 |
CorpusBuild corpus = project.getCorpusBuild(project.getName()); |
|
| 758 |
CorpusBuild corpus = project.getCorpusBuild(project.getName(), MainCorpus.class);
|
|
| 759 | 759 |
if (corpus != null) {
|
| 760 |
//println "CLEAN PREVIOUS CORPUS" |
|
| 761 |
corpus.delete(); // remove old files |
|
| 760 |
if (project.getDoUpdate()) {
|
|
| 761 |
corpus.clean(); // remove old files |
|
| 762 |
} else {
|
|
| 763 |
corpus.delete(); // remove old files and TXMResult children |
|
| 764 |
} |
|
| 765 |
} else {
|
|
| 766 |
corpus = new MainCorpus(project); |
|
| 767 |
corpus.setID(project.getName()); |
|
| 768 |
corpus.setName(project.getName()); |
|
| 762 | 769 |
} |
| 763 |
|
|
| 764 |
// make new one |
|
| 765 |
corpus = new MainCorpus(project); |
|
| 766 |
corpus.setID(project.getName()); |
|
| 767 |
corpus.setName(project.getName()); |
|
| 768 | 770 |
corpus.setDescription("Built with the BFM import module");
|
| 769 | 771 |
|
| 770 | 772 |
File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp"); |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/compiler.groovy (revision 1804) | ||
|---|---|---|
| 480 | 480 |
//String lang = langs.get(langGroups.get(group)[0]); |
| 481 | 481 |
cqpName = basename+"_"+corpusIDS.get(group); |
| 482 | 482 |
|
| 483 |
CorpusBuild corpus = project.getCorpusBuild(cqpName); |
|
| 484 |
if (corpus != null) {
|
|
| 485 |
//println "CLEAN PREVIOUS CORPUS" |
|
| 486 |
corpus.delete(); // remove old files |
|
| 483 |
CorpusBuild corpus = project.getCorpusBuild(project.getName(), MainCorpus.class); |
|
| 484 |
if (corpus != null) {
|
|
| 485 |
if (project.getDoUpdate()) {
|
|
| 486 |
corpus.clean(); // remove old files |
|
| 487 |
} else {
|
|
| 488 |
corpus.delete(); // remove old files and TXMResult children |
|
| 487 | 489 |
} |
| 488 |
|
|
| 489 |
// make new one |
|
| 490 |
} else {
|
|
| 490 | 491 |
corpus = new MainCorpus(project); |
| 491 |
corpus.setID(cqpName); |
|
| 492 |
corpus.setName(cqpName); |
|
| 492 |
corpus.setID(project.getName()); |
|
| 493 |
corpus.setName(project.getName()); |
|
| 494 |
} |
|
| 493 | 495 |
corpus.setDescription("Built with the TMX import module");
|
| 494 | 496 |
|
| 495 | 497 |
File cqpFile = new File(binDir,"cqp/"+cqpName+".cqp"); |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/compiler.groovy (revision 1804) | ||
|---|---|---|
| 131 | 131 |
|
| 132 | 132 |
sectionAttrs = new HashSet<String>() // reset section attributs set |
| 133 | 133 |
|
| 134 |
CorpusBuild corpus = project.getCorpusBuild(project.getName()); |
|
| 134 |
Project project = module.getProject(); |
|
| 135 |
CorpusBuild corpus = project.getCorpusBuild(project.getName(), MainCorpus.class); |
|
| 135 | 136 |
if (corpus != null) {
|
| 136 |
//println "CLEAN PREVIOUS CORPUS" |
|
| 137 |
corpus.delete(); // remove old files |
|
| 137 |
if (project.getDoUpdate()) {
|
|
| 138 |
corpus.clean(); // remove old files |
|
| 139 |
} else {
|
|
| 140 |
corpus.delete(); // remove old files and TXMResult children |
|
| 141 |
} |
|
| 142 |
} else {
|
|
| 143 |
corpus = new MainCorpus(project); |
|
| 144 |
corpus.setID(project.getName()); |
|
| 145 |
corpus.setName(project.getName()); |
|
| 138 | 146 |
} |
| 139 |
|
|
| 140 |
// make new one |
|
| 141 |
corpus = new MainCorpus(project); |
|
| 142 |
corpus.setID(project.getName()); |
|
| 143 |
corpus.setName(project.getName()); |
|
| 144 | 147 |
corpus.setDescription("Built with the XML-TRS import module");
|
| 145 | 148 |
|
| 146 | 149 |
cqpFile = new File(binDir,"cqp/"+corpusname+".cqp"); |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/txt/compiler.groovy (revision 1804) | ||
|---|---|---|
| 177 | 177 |
File txmDir = new File(binDir, "txm/"+corpusname) |
| 178 | 178 |
|
| 179 | 179 |
if (!(CwbEncode.isExecutableAvailable() && CwbMakeAll.isExecutableAvailable())) {
|
| 180 |
println ("Error: CWB executables rights are not well setted.")
|
|
| 180 |
println ("Error: CWB executable rights are not well setted.")
|
|
| 181 | 181 |
return false; |
| 182 | 182 |
} |
| 183 | 183 |
|
| 184 |
CorpusBuild corpus = project.getCorpusBuild(project.getName()); |
|
| 184 |
CorpusBuild corpus = project.getCorpusBuild(project.getName(), MainCorpus.class);
|
|
| 185 | 185 |
if (corpus != null) {
|
| 186 |
//println "CLEAN PREVIOUS CORPUS" |
|
| 187 |
corpus.delete(); // remove old files |
|
| 186 |
if (project.getDoUpdate()) {
|
|
| 187 |
corpus.clean(); // remove old files |
|
| 188 |
} else {
|
|
| 189 |
corpus.delete(); // remove old files and TXMResult children |
|
| 190 |
} |
|
| 191 |
} else {
|
|
| 192 |
corpus = new MainCorpus(project); |
|
| 193 |
corpus.setID(project.getName()); |
|
| 194 |
corpus.setName(project.getName()); |
|
| 188 | 195 |
} |
| 189 |
|
|
| 190 |
// make new one |
|
| 191 |
corpus = new MainCorpus(project); |
|
| 192 |
corpus.setID(project.getName()); |
|
| 193 |
corpus.setName(project.getName()); |
|
| 194 | 196 |
corpus.setDescription("Built with the TXT+CSV import module");
|
| 195 | 197 |
|
| 196 | 198 |
File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp"); |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/alceste/compiler.groovy (revision 1804) | ||
|---|---|---|
| 151 | 151 |
return false; |
| 152 | 152 |
} |
| 153 | 153 |
|
| 154 |
CorpusBuild corpus = project.getCorpusBuild(project.getName()); |
|
| 154 |
|
|
| 155 |
CorpusBuild corpus = project.getCorpusBuild(project.getName(), MainCorpus.class); |
|
| 155 | 156 |
if (corpus != null) {
|
| 156 |
println "CLEAN PREVIOUS CORPUS" |
|
| 157 |
corpus.delete(); // remove old files |
|
| 157 |
if (project.getDoUpdate()) {
|
|
| 158 |
corpus.clean(); // remove old files |
|
| 159 |
} else {
|
|
| 160 |
corpus.delete(); // remove old files and TXMResult children |
|
| 161 |
} |
|
| 162 |
} else {
|
|
| 163 |
corpus = new MainCorpus(project); |
|
| 164 |
corpus.setID(project.getName()); |
|
| 165 |
corpus.setName(project.getName()); |
|
| 158 | 166 |
} |
| 159 |
|
|
| 160 |
// make new one |
|
| 161 |
corpus = new MainCorpus(project); |
|
| 162 |
corpus.setID(project.getName()); |
|
| 163 |
corpus.setName(project.getName()); |
|
| 164 | 167 |
corpus.setDescription("Build the Alceste import module");
|
| 165 | 168 |
|
| 166 | 169 |
File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp"); |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/hyperbase/compiler.groovy (revision 1804) | ||
|---|---|---|
| 160 | 160 |
println ("Error: CWB executables not well set.")
|
| 161 | 161 |
return false; |
| 162 | 162 |
} |
| 163 |
CorpusBuild corpus = project.getCorpusBuild(project.getName()); |
|
| 163 |
CorpusBuild corpus = project.getCorpusBuild(project.getName(), MainCorpus.class);
|
|
| 164 | 164 |
if (corpus != null) {
|
| 165 |
//println "CLEAN PREVIOUS CORPUS" |
|
| 166 |
corpus.delete(); // remove old files |
|
| 165 |
if (project.getDoUpdate()) {
|
|
| 166 |
corpus.clean(); // remove old files |
|
| 167 |
} else {
|
|
| 168 |
corpus.delete(); // remove old files and TXMResult children |
|
| 169 |
} |
|
| 170 |
} else {
|
|
| 171 |
corpus = new MainCorpus(project); |
|
| 172 |
corpus.setID(project.getName()); |
|
| 173 |
corpus.setName(project.getName()); |
|
| 167 | 174 |
} |
| 168 |
|
|
| 169 |
// make new one |
|
| 170 |
corpus = new MainCorpus(project); |
|
| 171 |
corpus.setID(project.getName()); |
|
| 172 |
corpus.setName(project.getName()); |
|
| 173 | 175 |
corpus.setDescription("Built with the Hyperbase import module");
|
| 174 | 176 |
|
| 175 | 177 |
File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp"); |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/cqp/compiler.groovy (revision 1804) | ||
|---|---|---|
| 88 | 88 |
println ("Error: CWB executables not well set.")
|
| 89 | 89 |
return false; |
| 90 | 90 |
} |
| 91 |
CorpusBuild corpus = project.getCorpusBuild(project.getName()); |
|
| 91 |
CorpusBuild corpus = project.getCorpusBuild(project.getName(), MainCorpus.class);
|
|
| 92 | 92 |
if (corpus != null) {
|
| 93 |
//println "CLEAN PREVIOUS CORPUS" |
|
| 94 |
corpus.delete(); // remove old files |
|
| 93 |
if (project.getDoUpdate()) {
|
|
| 94 |
corpus.clean(); // remove old files |
|
| 95 |
} else {
|
|
| 96 |
corpus.delete(); // remove old files and TXMResult children |
|
| 97 |
} |
|
| 98 |
} else {
|
|
| 99 |
corpus = new MainCorpus(project); |
|
| 100 |
corpus.setID(project.getName()); |
|
| 101 |
corpus.setName(project.getName()); |
|
| 95 | 102 |
} |
| 96 |
|
|
| 97 |
// make new one |
|
| 98 |
corpus = new MainCorpus(project); |
|
| 99 |
corpus.setID(project.getName()); |
|
| 100 |
corpus.setName(project.getName()); |
|
| 101 | 103 |
corpus.setDescription("Built with the CQP import module");
|
| 102 | 104 |
|
| 103 | 105 |
File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp"); |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZCompiler.groovy (revision 1804) | ||
|---|---|---|
| 44 | 44 |
|
| 45 | 45 |
if (files == null) files = inputDirectory.listFiles(); |
| 46 | 46 |
|
| 47 |
Project project = module.getProject(); |
|
| 48 |
CorpusBuild corpus = project.getCorpusBuild(project.getName(), MainCorpus.class); |
|
| 49 |
if (corpus != null) {
|
|
| 50 |
if (project.getDoUpdate()) {
|
|
| 51 |
corpus.clean(); // remove old files |
|
| 52 |
} else {
|
|
| 53 |
corpus.delete(); // remove old files and TXMResult children |
|
| 54 |
} |
|
| 55 |
} else {
|
|
| 56 |
corpus = new MainCorpus(project); |
|
| 57 |
corpus.setID(project.getName()); |
|
| 58 |
corpus.setName(project.getName()); |
|
| 59 |
} |
|
| 60 |
corpus.setDescription("Built with the XTZ import module");
|
|
| 61 |
|
|
| 47 | 62 |
if (!doScanStep()) return; |
| 48 | 63 |
if (!doCQPStep()) return; |
| 49 | 64 |
if (!doCWBEncodeStep()) return; |
| 50 | 65 |
if (!doCWBMakeAllStep()) return; |
| 51 | 66 |
|
| 52 |
CorpusBuild corpus = module.getProject().getCorpusBuild(corpusname); |
|
| 53 |
if (corpus != null) {
|
|
| 54 |
//println "CLEAN PREVIOUS CORPUS" |
|
| 55 |
corpus.delete(); // remove old files |
|
| 56 |
} |
|
| 57 |
|
|
| 58 |
// make new one |
|
| 59 |
corpus = new MainCorpus(module.getProject()); |
|
| 60 |
corpus.setID(corpusname); |
|
| 61 |
corpus.setName(corpusname); |
|
| 62 |
corpus.setDescription("Built with the XTZ import module");
|
|
| 63 |
|
|
| 64 | 67 |
if (module.getProject().getCleanAfterBuild()) {
|
| 65 | 68 |
new File(module.getBinaryDirectory(), "cqp").deleteDir() |
| 66 | 69 |
} |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xmltxm/compiler.groovy (revision 1804) | ||
|---|---|---|
| 354 | 354 |
println ("Error: CWB executables not well set.")
|
| 355 | 355 |
return false; |
| 356 | 356 |
} |
| 357 |
CorpusBuild corpus = project.getCorpusBuild(project.getName()); |
|
| 357 |
CorpusBuild corpus = project.getCorpusBuild(project.getName(), MainCorpus.class);
|
|
| 358 | 358 |
if (corpus != null) {
|
| 359 |
//println "CLEAN PREVIOUS CORPUS" |
|
| 360 |
corpus.delete(); // remove old files |
|
| 359 |
if (project.getDoUpdate()) {
|
|
| 360 |
corpus.clean(); // remove old files |
|
| 361 |
} else {
|
|
| 362 |
corpus.delete(); // remove old files and TXMResult children |
|
| 363 |
} |
|
| 364 |
} else {
|
|
| 365 |
corpus = new MainCorpus(project); |
|
| 366 |
corpus.setID(project.getName()); |
|
| 367 |
corpus.setName(project.getName()); |
|
| 361 | 368 |
} |
| 362 |
|
|
| 363 |
// make new one |
|
| 364 |
corpus = new MainCorpus(project); |
|
| 365 |
corpus.setID(project.getName()); |
|
| 366 |
corpus.setName(project.getName()); |
|
| 367 | 369 |
corpus.setDescription("Built with the XML-TXM import module");
|
| 368 | 370 |
|
| 369 | 371 |
File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp"); |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/discours/compiler.groovy (revision 1804) | ||
|---|---|---|
| 151 | 151 |
println ("Error: CWB executables not well set.")
|
| 152 | 152 |
return false; |
| 153 | 153 |
} |
| 154 |
CorpusBuild corpus = project.getCorpusBuild(project.getName()); |
|
| 154 |
CorpusBuild corpus = project.getCorpusBuild(project.getName(), MainCorpus.class);
|
|
| 155 | 155 |
if (corpus != null) {
|
| 156 |
//println "CLEAN PREVIOUS CORPUS" |
|
| 157 |
corpus.delete(); // remove old files |
|
| 156 |
if (project.getDoUpdate()) {
|
|
| 157 |
corpus.clean(); // remove old files |
|
| 158 |
} else {
|
|
| 159 |
corpus.delete(); // remove old files and TXMResult children |
|
| 160 |
} |
|
| 161 |
} else {
|
|
| 162 |
corpus = new MainCorpus(project); |
|
| 163 |
corpus.setID(project.getName()); |
|
| 164 |
corpus.setName(project.getName()); |
|
| 158 | 165 |
} |
| 159 |
|
|
| 160 |
// make new one |
|
| 161 |
corpus = new MainCorpus(project); |
|
| 162 |
corpus.setID(project.getName()); |
|
| 163 |
corpus.setName(project.getName()); |
|
| 164 | 166 |
corpus.setDescription("Built with the CNR+CSV import module");
|
| 165 | 167 |
|
| 166 | 168 |
File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp"); |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xml/compiler.groovy (revision 1804) | ||
|---|---|---|
| 454 | 454 |
return false; |
| 455 | 455 |
} |
| 456 | 456 |
|
| 457 |
CorpusBuild corpus = project.getCorpusBuild(project.getName()); |
|
| 457 |
CorpusBuild corpus = project.getCorpusBuild(project.getName(), MainCorpus.class);
|
|
| 458 | 458 |
if (corpus != null) {
|
| 459 |
//println "CLEAN PREVIOUS CORPUS" |
|
| 460 |
corpus.delete(); // remove old files |
|
| 459 |
if (project.getDoUpdate()) {
|
|
| 460 |
corpus.clean(); // remove old files |
|
| 461 |
} else {
|
|
| 462 |
corpus.delete(); // remove old files and TXMResult children |
|
| 463 |
} |
|
| 464 |
} else {
|
|
| 465 |
corpus = new MainCorpus(project); |
|
| 466 |
corpus.setID(project.getName()); |
|
| 467 |
corpus.setName(project.getName()); |
|
| 461 | 468 |
} |
| 462 |
|
|
| 463 |
// make new one |
|
| 464 |
corpus = new MainCorpus(project); |
|
| 465 |
corpus.setID(project.getName()); |
|
| 466 |
corpus.setName(project.getName()); |
|
| 467 | 469 |
corpus.setDescription("Built with the XML/w import module");
|
| 468 | 470 |
|
| 469 | 471 |
File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp"); |
| tmp/org.txm.groovy.core/src/groovy/org/txm/macro/debug/DescribeTXMResultMacro.groovy (revision 1804) | ||
|---|---|---|
| 1 |
// Copyright © 2016 ENS de Lyon, CNRS, University of Franche-Comté |
|
| 2 |
// Licensed under the terms of the GNU General Public License (http://www.gnu.org/licenses) |
|
| 3 |
// @author sheiden |
|
| 4 |
package org.txm.macro.debug |
|
| 5 |
|
|
| 6 |
def printResult(def obj, String prof) {
|
|
| 7 |
println (prof+obj.getClass().getSimpleName()+"="+obj) |
|
| 8 |
for (def c : obj.getChildren()) {
|
|
| 9 |
printResult(c, prof+ " ") |
|
| 10 |
} |
|
| 11 |
} |
|
| 12 |
|
|
| 13 |
if (corpusViewSelection != null) |
|
| 14 |
printResult(corpusViewSelection.getProject(), "") |
|
| 15 |
else |
|
| 16 |
println "no selection." |
|
| tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/GroovyScriptedImportEngine.java (revision 1804) | ||
|---|---|---|
| 63 | 63 |
} |
| 64 | 64 |
|
| 65 | 65 |
if (project.getDoUpdate()) {
|
| 66 |
// drop CorpusBuild and Editions
|
|
| 67 |
List<? extends CorpusBuild> corpora = project.getCorpora(); |
|
| 68 |
while (project.getCorpora().size() > 0) {
|
|
| 69 |
CorpusBuild c = project.getCorpora().get(0); |
|
| 70 |
c.delete(); |
|
| 71 |
} |
|
| 66 |
// drop CorpusBuild and Editions |
|
| 67 |
// List<? extends CorpusBuild> corpora = project.getCorpora();
|
|
| 68 |
// while (project.getCorpora().size() > 0) {
|
|
| 69 |
// CorpusBuild c = project.getCorpora().get(0);
|
|
| 70 |
// c.delete();
|
|
| 71 |
// }
|
|
| 72 | 72 |
List<Text> texts = project.getTexts(); |
| 73 | 73 |
for (Text t : texts) {
|
| 74 | 74 |
while (t.getEditions().size() > 0) {
|
| ... | ... | |
| 143 | 143 |
|
| 144 | 144 |
if (!project.getDoUpdate()) { // clear all
|
| 145 | 145 |
project.deleteChildren(); |
| 146 |
} else {
|
|
| 147 |
Log.fine("Deleting all project CorpusBuild & Edition children...");
|
|
| 148 |
for (TXMResult c : project.getChildren(CorpusBuild.class)) {
|
|
| 149 |
c.delete(); |
|
| 150 |
} |
|
| 151 |
for (TXMResult c : project.getChildren(Edition.class)) {
|
|
| 152 |
c.delete(); |
|
| 153 |
} |
|
| 154 | 146 |
} |
| 155 | 147 |
|
| 156 | 148 |
// if (basedir.exists()) basedir.renameTo(errorBinDirectory); |
| tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/BackToText.java (revision 1804) | ||
|---|---|---|
| 178 | 178 |
if (wordid != null) {
|
| 179 | 179 |
editor.addHighlightWordsById(red, wordid); |
| 180 | 180 |
} |
| 181 |
editor.updateWordStyles(); |
|
| 181 | 182 |
return false; |
| 182 | 183 |
} |
| 183 | 184 |
|
| ... | ... | |
| 332 | 333 |
|
| 333 | 334 |
// reload the page and styles |
| 334 | 335 |
attachedBrowserEditor.backToText(text, line_wordid);// open the page(S) containing the word with id=line_wordid |
| 335 |
|
|
| 336 |
attachedBrowserEditor.updateWordStyles(); // update styles if any new one |
|
| 336 | 337 |
IWorkbenchPage attachedPage = attachedBrowserEditor.getEditorSite().getPage(); |
| 337 | 338 |
attachedPage.activate(attachedBrowserEditor); |
| 338 | 339 |
|
| tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java (revision 1804) | ||
|---|---|---|
| 229 | 229 |
if (Log.getLevel().intValue() <= Level.FINEST.intValue()) System.out.println(code); |
| 230 | 230 |
return getBrowser().evaluate(code); |
| 231 | 231 |
} |
| 232 |
public Object execute(String code) {
|
|
| 232 |
public boolean execute(String code) {
|
|
| 233 | 233 |
if (Log.getLevel().intValue() <= Level.FINEST.intValue()) System.out.println(code); |
| 234 | 234 |
return getBrowser().execute(code); |
| 235 | 235 |
} |
| ... | ... | |
| 266 | 266 |
|
| 267 | 267 |
// System.out.println("EditionPanel "+currentEdition.getName()+" reload "+getCurrentPage().getName());
|
| 268 | 268 |
Object rez = evaluate("return typeof sheet"); //$NON-NLS-1$
|
| 269 |
if ("undefined".equals(rez)) execute(functions); // build the sheet if not present in the HTML DOM //$NON-NLS-1$
|
|
| 269 |
if ("undefined".equals(rez)) {
|
|
| 270 |
if (!execute(functions)) { // build the sheet if not present in the HTML DOM //$NON-NLS-1$
|
|
| 271 |
Log.warning("JS execution (init) error with="+functions);
|
|
| 272 |
} |
|
| 273 |
} |
|
| 270 | 274 |
|
| 271 | 275 |
// do something before the highlight is done |
| 272 | 276 |
for (ProgressListener pl : beforeHighlighListeners) { pl.completed(event);}
|
| ... | ... | |
| 282 | 286 |
buffer.append("try { while(sheet.cssRules.length > 0) sheet.deleteRule(0); } catch (e) {};\n"); // empty style //$NON-NLS-1$
|
| 283 | 287 |
} |
| 284 | 288 |
|
| 285 |
if (buffer.length() > 0) execute(buffer.toString()); |
|
| 289 |
if (buffer.length() > 0) {
|
|
| 290 |
if (!execute(buffer.toString())) {
|
|
| 291 |
Log.warning("JS execution error (delete cssRules) with="+buffer);
|
|
| 292 |
} |
|
| 293 |
} |
|
| 286 | 294 |
buffer = new StringBuilder(); |
| 287 | 295 |
|
| 288 | 296 |
String firstWord = currentPage.getWordId(); |
| ... | ... | |
| 334 | 342 |
buffer.append(s+"\n"); //$NON-NLS-1$ |
| 335 | 343 |
} |
| 336 | 344 |
|
| 337 |
if (buffer.length() > 0) execute(buffer.toString()); |
|
| 345 |
if (buffer.length() > 0) {
|
|
| 346 |
if (!execute(buffer.toString())) {
|
|
| 347 |
Log.warning("JS execution (highlight) error with="+buffer);
|
|
| 348 |
} |
|
| 349 |
} |
|
| 338 | 350 |
buffer = new StringBuilder(); |
| 339 | 351 |
|
| 340 | 352 |
// for (String wordidslist : highlightedColorSpans.keySet()) {
|
| ... | ... | |
| 376 | 388 |
buffer.append(s+"\n"); //$NON-NLS-1$ |
| 377 | 389 |
} |
| 378 | 390 |
|
| 379 |
if (buffer.length() > 0) execute(buffer.toString()); |
|
| 391 |
if (buffer.length() > 0) {
|
|
| 392 |
if (!execute(buffer.toString())) {
|
|
| 393 |
Log.warning("JS execution (color) error with="+buffer);
|
|
| 394 |
} |
|
| 395 |
} |
|
| 380 | 396 |
buffer = new StringBuilder(); |
| 381 | 397 |
|
| 382 | 398 |
for (String wordid : fontSizePerWordIDS.keySet()) {
|
| ... | ... | |
| 414 | 430 |
buffer.append(s+"\n"); //$NON-NLS-1$ |
| 415 | 431 |
} |
| 416 | 432 |
|
| 417 |
if (buffer.length() > 0) execute(buffer.toString()); |
|
| 433 |
if (buffer.length() > 0) {
|
|
| 434 |
if (!execute(buffer.toString())) {
|
|
| 435 |
Log.warning("JS execution (font) error with="+buffer);
|
|
| 436 |
} |
|
| 437 |
} |
|
| 418 | 438 |
buffer = new StringBuilder(); |
| 419 | 439 |
|
| 420 | 440 |
if (focusedWordID != null) {
|
| 421 | 441 |
//System.out.println("Focus on: "+focusedWordID);
|
| 422 | 442 |
String s = "try { showElementIfNeeded(document.getElementById(\"" + focusedWordID + "\")); } catch (e) {document.getElementById(\"" + focusedWordID + "\").scrollIntoView();};"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
| 423 | 443 |
buffer.append(s+"\n"); //$NON-NLS-1$ |
| 424 |
focusedWordID = null; // focus one time |
|
| 425 | 444 |
} |
| 426 | 445 |
|
| 427 |
if (buffer.length() > 0) execute(buffer.toString()); |
|
| 446 |
if (buffer.length() > 0) {
|
|
| 447 |
if (execute(buffer.toString())) {
|
|
| 448 |
focusedWordID = null; // focus one time |
|
| 449 |
} else {
|
|
| 450 |
Log.warning("JS execution (focus) error with="+buffer);
|
|
| 451 |
} |
|
| 452 |
} |
|
| 428 | 453 |
buffer = new StringBuilder(); |
| 429 | 454 |
|
| 430 | 455 |
if (highlightedAreas != null) {
|
| ... | ... | |
| 437 | 462 |
} |
| 438 | 463 |
|
| 439 | 464 |
//System.out.println(buffer); |
| 440 |
if (buffer.length() > 0) execute(buffer.toString()); |
|
| 465 |
if (buffer.length() > 0) {
|
|
| 466 |
if (!execute(buffer.toString())) {
|
|
| 467 |
Log.warning("JS execution (area focus) error with="+buffer);
|
|
| 468 |
} |
|
| 469 |
} |
|
| 441 | 470 |
//System.out.println("n="+n+" time="+(System.currentTimeMillis()-start));
|
| 442 | 471 |
|
| 443 | 472 |
// do something after the highlight is done |
| ... | ... | |
| 549 | 578 |
return true; |
| 550 | 579 |
} |
| 551 | 580 |
} |
| 552 |
updateWordStyles(); // update styles if any new one |
|
| 581 |
|
|
| 553 | 582 |
return false; |
| 554 | 583 |
} |
| 555 | 584 |
|
| tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java (revision 1804) | ||
|---|---|---|
| 706 | 706 |
p.backToText(text, line_wordid); |
| 707 | 707 |
} |
| 708 | 708 |
updatePageLabel(); |
| 709 |
|
|
| 709 |
updateWordStyles(); |
|
| 710 | 710 |
notifyExtensions("onBackToText"); //$NON-NLS-1$
|
| 711 | 711 |
} catch (Exception e) {
|
| 712 | 712 |
// TODO Auto-generated catch block |
| tmp/org.txm.core/src/java/org/txm/objects/Project.java (revision 1804) | ||
|---|---|---|
| 296 | 296 |
|
| 297 | 297 |
Log.finest("RUNNING IMPORT MODULE WITH NAME = " + getImportModuleName());
|
| 298 | 298 |
|
| 299 |
// This step could be done only if the compiler step if done and only if it modifying/deleting the corpus builds |
|
| 300 |
for (CorpusBuild corpus : getCorpusBuilds()) {
|
|
| 301 |
if (corpus != null) {
|
|
| 302 |
corpus.deleteChildren(null); // remove all Corpus results |
|
| 303 |
} |
|
| 304 |
} |
|
| 305 |
|
|
| 306 | 299 |
boolean state = engine.build(this, monitor).isOK(); |
| 307 | 300 |
if (state == true) {
|
| 308 | 301 |
this.needToBuild = false; |
| 309 | 302 |
// This step could be done only if the compiler step if done and only if it modifying/deleting the corpus builds |
| 310 | 303 |
for (CorpusBuild corpus : getCorpusBuilds()) {
|
| 311 | 304 |
if (corpus != null) {
|
| 312 |
corpus.compute(); |
|
| 305 |
corpus.compute(false);
|
|
| 313 | 306 |
} |
| 314 | 307 |
} |
| 315 | 308 |
} else { // import failed
|
| ... | ... | |
| 389 | 382 |
|
| 390 | 383 |
try {
|
| 391 | 384 |
Preferences node = TXMPreferences.preferencesRootNode.node(resultNodePath); |
| 392 |
|
|
| 393 |
|
|
| 385 |
|
|
| 386 |
|
|
| 394 | 387 |
String className = node.get("class", ""); //$NON-NLS-1$ //$NON-NLS-2$
|
| 395 |
|
|
| 388 |
|
|
| 396 | 389 |
// Skip Project object |
| 397 | 390 |
if (Project.class.getName().equals(className)) { // already loaded in loadProjectFromProjectScope
|
| 398 | 391 |
continue; |
| 399 | 392 |
} |
| 400 |
|
|
| 393 |
|
|
| 401 | 394 |
if (className == null || className.length() == 0) {
|
| 402 | 395 |
errors.add(NLS.bind("Warning: can not restore object with no class name set with path={0}.", resultNodePath)); //$NON-NLS-1$
|
| 403 | 396 |
node.removeNode(); |
| 404 | 397 |
continue; |
| 405 | 398 |
} |
| 406 |
|
|
| 399 |
|
|
| 407 | 400 |
if (clazz != null && !clazz.getName().equals(className)) {
|
| 408 | 401 |
continue; // only load the result of class=clazz |
| 409 | 402 |
} |
| ... | ... | |
| 453 | 446 |
Log.fine("more: "+(errors.size()-20)+"...");
|
| 454 | 447 |
} |
| 455 | 448 |
} |
| 456 |
|
|
| 457 |
// // load the corpus builds |
|
| 458 |
// for (CorpusBuild corpus : getCorpusBuilds()) {
|
|
| 459 |
// if (corpus != null) {
|
|
| 460 |
// corpus.compute(false); |
|
| 461 |
// } |
|
| 462 |
// } |
|
| 449 |
|
|
| 450 |
// // load the corpus builds
|
|
| 451 |
// for (CorpusBuild corpus : getCorpusBuilds()) {
|
|
| 452 |
// if (corpus != null) {
|
|
| 453 |
// corpus.compute(false);
|
|
| 454 |
// }
|
|
| 455 |
// }
|
|
| 463 | 456 |
} |
| 464 | 457 |
|
| 465 | 458 |
// public BasePreferenceScope getPreferenceScope() {
|
| ... | ... | |
| 928 | 921 |
if (rcpProject != null) {
|
| 929 | 922 |
try {
|
| 930 | 923 |
//Toolbox.getEngineManager(EngineType.SEARCH).getEngine("CQP").stop(); //$NON-NLS-1$
|
| 931 |
|
|
| 924 |
|
|
| 932 | 925 |
rcpProject.delete(true, new LogMonitor("Cleaning "+this));
|
| 933 |
|
|
| 934 |
|
|
| 926 |
|
|
| 927 |
|
|
| 935 | 928 |
//Toolbox.getEngineManager(EngineType.SEARCH).getEngine("CQP").start(null); //$NON-NLS-1$
|
| 936 |
|
|
| 929 |
|
|
| 937 | 930 |
} catch (Exception e) {
|
| 938 | 931 |
// TODO Auto-generated catch block |
| 939 | 932 |
e.printStackTrace(); |
| ... | ... | |
| 1137 | 1130 |
} |
| 1138 | 1131 |
|
| 1139 | 1132 |
public CorpusBuild getCorpusBuild(String id) {
|
| 1140 |
for (CorpusBuild build : getCorpusBuilds()) {
|
|
| 1133 |
return getCorpusBuild(id, null); |
|
| 1134 |
} |
|
| 1135 |
|
|
| 1136 |
public CorpusBuild getCorpusBuild(String id, Class<CorpusBuild> clazz) {
|
|
| 1137 |
// System.out.println("CLASS="+clazz);
|
|
| 1138 |
List<CorpusBuild> builds = getCorpusBuilds(); |
|
| 1139 |
// System.out.println("BUILDS="+builds);
|
|
| 1140 |
for (CorpusBuild build : builds) {
|
|
| 1141 | 1141 |
if (id.equals(build.getID())) {
|
| 1142 |
return build; |
|
| 1142 |
if (clazz == null) {
|
|
| 1143 |
return build; |
|
| 1144 |
} else if (build.getClass().equals(clazz)) {
|
|
| 1145 |
return build; |
|
| 1146 |
} |
|
| 1143 | 1147 |
} |
| 1144 | 1148 |
} |
| 1145 | 1149 |
return null; |
| ... | ... | |
| 1236 | 1240 |
|
| 1237 | 1241 |
Preferences node = TXMPreferences.preferencesRootNode.node(parametersNodePath); |
| 1238 | 1242 |
String className = node.get("class", ""); //$NON-NLS-1$
|
| 1239 |
|
|
| 1243 |
|
|
| 1240 | 1244 |
if (className == null || className.length() == 0) {
|
| 1241 | 1245 |
Log.warning(NLS.bind("Warning: can not restore object with no class name set with path={0}.", parametersNodePath)); //$NON-NLS-1$
|
| 1242 | 1246 |
node.removeNode(); |
| 1243 | 1247 |
continue; |
| 1244 | 1248 |
} |
| 1245 |
|
|
| 1249 |
|
|
| 1246 | 1250 |
if (!className.equals(Project.class.getName())) { // only load the Project class
|
| 1247 | 1251 |
continue; |
| 1248 | 1252 |
} |
| ... | ... | |
| 1252 | 1256 |
|
| 1253 | 1257 |
String bundleId = node.get(TXMPreferences.BUNDLE_ID, ""); //$NON-NLS-1$ |
| 1254 | 1258 |
Log.finest("Toolbox.initialize(): bundle_id = " + bundleId); //$NON-NLS-1$
|
| 1255 |
|
|
| 1259 |
|
|
| 1256 | 1260 |
Bundle bundle = Platform.getBundle(bundleId); |
| 1257 | 1261 |
if (bundle == null) {
|
| 1258 | 1262 |
Log.finest("Warning: can not restore object with bundle name " + bundleId); //$NON-NLS-1$
|
| ... | ... | |
| 1269 | 1273 |
if (!result.isInternalPersistable()) {
|
| 1270 | 1274 |
result.setUserPersistable(true); |
| 1271 | 1275 |
} |
| 1272 |
|
|
| 1276 |
|
|
| 1273 | 1277 |
return; // only one Project.class loaded per RCP project |
| 1274 | 1278 |
} catch (Exception e) {
|
| 1275 | 1279 |
// TODO Auto-generated catch block |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/AssistedChoiceQueryWidget.java (revision 1804) | ||
|---|---|---|
| 140 | 140 |
} |
| 141 | 141 |
} |
| 142 | 142 |
|
| 143 |
public QueryWidget getQueryWidget() {
|
|
| 144 |
return querywidget; |
|
| 145 |
} |
|
| 146 |
|
|
| 143 | 147 |
public boolean setFocus() {
|
| 144 | 148 |
return this.querywidget.setFocus(); |
| 145 | 149 |
} |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/utils/JobHandler.java (revision 1804) | ||
|---|---|---|
| 51 | 51 |
/** The parent. */ |
| 52 | 52 |
IProgressMonitor currentMonitor; |
| 53 | 53 |
|
| 54 |
protected Thread myThread = null; |
|
| 55 | 54 |
protected Semaphore mySemaphore; |
| 56 | 55 |
protected boolean canBeInterrupted = false; |
| 57 | 56 |
|
| ... | ... | |
| 222 | 221 |
* @param monitor |
| 223 | 222 |
*/ |
| 224 | 223 |
protected void runInit(IProgressMonitor monitor) {
|
| 225 |
this.myThread = Thread.currentThread(); |
|
| 226 | 224 |
this.mySemaphore = new Semaphore(1); |
| 227 | 225 |
this.currentMonitor = monitor; |
| 228 | 226 |
this.canBeInterrupted = true; |
| ... | ... | |
| 233 | 231 |
*/ |
| 234 | 232 |
@Override |
| 235 | 233 |
protected void canceling() {
|
| 236 |
if (this.myThread == null) |
|
| 237 |
return; |
|
| 238 | 234 |
if (!this.canBeInterrupted) // Prevent thread system interruption (ThreadDeath not handled by the programmer) |
| 239 | 235 |
return; |
| 240 | 236 |
|
| ... | ... | |
| 248 | 244 |
}); |
| 249 | 245 |
if (currentMonitor != null) this.currentMonitor.setTaskName(TXMUIMessages.canceling); |
| 250 | 246 |
this.mySemaphore.acquire(); |
| 251 |
this.myThread.stop();
|
|
| 247 |
this.getThread().stop();
|
|
| 252 | 248 |
} catch (Exception e) {
|
| 253 | 249 |
Log.printStackTrace(e); |
| 254 | 250 |
Log.severe(TXMUIMessages.failedToCancel + this.getName()); |
| tmp/org.txm.index.core/src/org/txm/index/core/functions/Lexicon.java (revision 1804) | ||
|---|---|---|
| 47 | 47 |
public class Lexicon extends Index {
|
| 48 | 48 |
|
| 49 | 49 |
|
| 50 |
/** The lexicon used to compute the index (if query = null || query == [] && properties.size() == 1 */ |
|
| 51 |
protected CQPLexicon lexicon; |
|
| 50 |
// /** The lexicon used to compute the index (if query = null || query == [] && properties.size() == 1 */
|
|
| 51 |
// protected CQPLexicon lexicon;
|
|
| 52 | 52 |
|
| 53 | 53 |
public Lexicon(CQPCorpus parent) {
|
| 54 | 54 |
super(parent); |
| ... | ... | |
| 67 | 67 |
// this.props.add(property); |
| 68 | 68 |
Property property = pProperties.get(0); |
| 69 | 69 |
|
| 70 |
if (lexicon == null // never computed |
|
| 71 |
|| this.hasParameterChanged(TXMPreferences.UNIT_PROPERTIES)) { // already computed but the property changed
|
|
| 72 |
lexicon = CQPLexicon.getLexicon(getCorpus(), property, monitor); |
|
| 73 |
lexicon.setProperty(property); |
|
| 74 |
lexicon._compute(); |
|
| 75 |
} |
|
| 70 |
CQPLexicon lexicon = CQPLexicon.getLexicon(getCorpus(), property, monitor); |
|
| 71 |
lexicon.setProperty(property); |
|
| 72 |
lexicon._compute(); |
|
| 76 | 73 |
|
| 77 | 74 |
this.nTotalTokens = lexicon.nbrOfToken(); |
| 78 | 75 |
String[] forms = lexicon.getForms(); |
| ... | ... | |
| 130 | 127 |
|
| 131 | 128 |
@Override |
| 132 | 129 |
public String getSimpleName() {
|
| 133 |
if (lexicon != null) {
|
|
| 134 |
return lexicon.getSimpleName(); |
|
| 135 |
} |
|
| 136 |
else if (pProperties != null && pProperties.size() > 0) {
|
|
| 130 |
if (pProperties != null && pProperties.size() > 0) {
|
|
| 137 | 131 |
return pProperties.get(0).getName(); |
| 138 | 132 |
} |
| 139 | 133 |
else {
|
| ... | ... | |
| 141 | 135 |
} |
| 142 | 136 |
} |
| 143 | 137 |
|
| 144 |
/** |
|
| 145 |
* |
|
| 146 |
* @return the lexicon used to compute the result. The Lexicon is not altered |
|
| 147 |
*/ |
|
| 148 |
public CQPLexicon getLexicon() {
|
|
| 149 |
return lexicon; |
|
| 150 |
} |
|
| 138 |
// /**
|
|
| 139 |
// *
|
|
| 140 |
// * @return the lexicon used to compute the result. The Lexicon is not altered
|
|
| 141 |
// */
|
|
| 142 |
// public CQPLexicon getLexicon() {
|
|
| 143 |
// return lexicon;
|
|
| 144 |
// }
|
|
| 151 | 145 |
} |
| tmp/org.txm.index.rcp/src/org/txm/index/rcp/editors/IndexEditor.java (revision 1804) | ||
|---|---|---|
| 211 | 211 |
layoutData.grabExcessHorizontalSpace = true; |
| 212 | 212 |
queryWidget.setLayoutData(layoutData); |
| 213 | 213 |
queryWidget.addKeyListener(computeKeyListener); |
| 214 |
|
|
| 214 |
queryWidget.getQueryWidget().addModifyListener(computeKeyListener); |
|
| 215 | 215 |
|
| 216 | 216 |
// Word properties selector |
| 217 | 217 |
propertiesSelector = new PropertiesSelector<WordProperty>(this.getMainParametersComposite(), SWT.NONE); |
| tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 1804) | ||
|---|---|---|
| 1928 | 1928 |
|
| 1929 | 1929 |
StructuredSelection select = (StructuredSelection) viewer.getSelection(); |
| 1930 | 1930 |
if (select == null) return false; |
| 1931 |
|
|
| 1931 | 1932 |
Line line = (Line) select.getFirstElement(); |
| 1932 | 1933 |
if (line == null) return false; |
| 1933 | 1934 |
|
| 1934 | 1935 |
try {
|
| 1935 |
IConfigurationElement[] config = Platform.getExtensionRegistry() |
|
| 1936 |
.getConfigurationElementsFor(BACKTOTEXT_COMMAND_ID); |
|
| 1936 |
IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(BACKTOTEXT_COMMAND_ID); |
|
| 1937 | 1937 |
for (IConfigurationElement e : config) {
|
| 1938 | 1938 |
Object o = e.createExecutableExtension("class"); // //$NON-NLS-1$
|
| 1939 | 1939 |
if (o instanceof BackToTextCommand) {
|
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java (revision 1804) | ||
|---|---|---|
| 2 | 2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
| 3 | 3 |
// Lyon 2, University of Franche-Comté, University of Nice |
| 4 | 4 |
// Sophia Antipolis, University of Paris 3. |
| 5 |
//
|
|
| 5 |
// |
|
| 6 | 6 |
// The TXM platform is free software: you can redistribute it |
| 7 | 7 |
// and/or modify it under the terms of the GNU General Public |
| 8 | 8 |
// License as published by the Free Software Foundation, |
| 9 | 9 |
// either version 2 of the License, or (at your option) any |
| 10 | 10 |
// later version. |
| 11 |
//
|
|
| 11 |
// |
|
| 12 | 12 |
// The TXM platform is distributed in the hope that it will be |
| 13 | 13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
| 14 | 14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 15 | 15 |
// PURPOSE. See the GNU General Public License for more |
| 16 | 16 |
// details. |
| 17 |
//
|
|
| 17 |
// |
|
| 18 | 18 |
// You should have received a copy of the GNU General |
| 19 | 19 |
// Public License along with the TXM platform. If not, see |
| 20 | 20 |
// http://www.gnu.org/licenses. |
| 21 |
//
|
|
| 22 |
//
|
|
| 23 |
//
|
|
| 21 |
// |
|
| 22 |
// |
|
| 23 |
// |
|
| 24 | 24 |
// $LastChangedDate: 2016-11-29 16:47:07 +0100 (Tue, 29 Nov 2016) $ |
| 25 | 25 |
// $LastChangedRevision: 3349 $ |
| 26 |
// $LastChangedBy: mdecorde $
|
|
| 26 |
// $LastChangedBy: mdecorde $ |
|
| 27 | 27 |
// |
| 28 | 28 |
package org.txm.searchengine.cqp.corpus; |
| 29 | 29 |
|
| ... | ... | |
| 57 | 57 |
import org.w3c.dom.NodeList; |
| 58 | 58 |
|
| 59 | 59 |
/** |
| 60 |
* The Class Corpus. A corpus is either a whole corpus, as managed by CQP or a subcorpus. |
|
| 60 |
* The Class Corpus. A corpus is either a whole corpus, as managed by CQP or a |
|
| 61 |
* subcorpus. |
|
| 61 | 62 |
* |
| 62 | 63 |
* @see org.txm.searchengine.cqp.corpus.MainCorpus |
| 63 | 64 |
* @see org.txm.searchengine.cqp.corpus.Subcorpus |
| ... | ... | |
| 66 | 67 |
*/ |
| 67 | 68 |
public abstract class CQPCorpus extends org.txm.objects.CorpusBuild implements CqpObject {
|
| 68 | 69 |
|
| 70 |
protected static HashMap<Class<?>, ArrayList<?>> cache = new HashMap<Class<?>, ArrayList<?>>(); |
|
| 71 |
|
|
| 72 |
private static final int CACHE_MAXIMUM_SIZE = 5; |
|
| 73 |
|
|
| 74 |
/** The nocorpus. */ |
|
| 75 |
protected static int nocorpus = 1; |
|
| 76 |
|
|
| 77 |
/** The prefix r. */ |
|
| 78 |
protected static String prefixR = "Corpus"; //$NON-NLS-1$ |
|
| 79 |
private static Integer QUERY_COUNTER = new Integer(0); |
|
| 80 |
protected static Integer SUBCORPUS_COUNTER = new Integer(0); |
|
| 81 |
protected static String WORD = TXMPreferences.DEFAULT_UNIT_PROPERTY; |
|
| 82 |
|
|
| 83 |
public static final Comparator<WordProperty> wordFirstComparator = new Comparator<WordProperty>() {
|
|
| 84 |
@Override |
|
| 85 |
public int compare(WordProperty o1, WordProperty o2) {
|
|
| 86 |
if (o1.getName().equals("word"))
|
|
| 87 |
return -1; |
|
| 88 |
if (o2.getName().equals("word"))
|
|
| 89 |
return 1; |
|
| 90 |
return o1.compareTo(o2); |
|
| 91 |
} |
|
| 92 |
}; |
|
| 93 |
|
|
| 69 | 94 |
/** |
| 95 |
* store an object for a maximum of 5 object cached per object |
|
| 70 | 96 |
* |
| 71 |
* @param project |
|
| 97 |
* @param forObject |
|
| 98 |
* @param toCache |
|
| 99 |
* @return |
|
| 72 | 100 |
*/ |
| 73 |
protected CQPCorpus(Project project) {
|
|
| 74 |
super(project); |
|
| 101 |
public static Object cache(Object toCache) {
|
|
| 102 |
if (toCache == null) |
|
| 103 |
return null; |
|
| 104 |
|
|
| 105 |
ArrayList<?> ocCache = getObjectCacheForClass(toCache.getClass()); |
|
| 106 |
if (ocCache.size() > CACHE_MAXIMUM_SIZE) {
|
|
| 107 |
ocCache.remove(0); // oldest value |
|
| 108 |
} |
|
| 109 |
return toCache; |
|
| 75 | 110 |
} |
| 76 |
|
|
| 111 |
|
|
| 77 | 112 |
/** |
| 113 |
* Returns the first parent object that is a Subcorpus, a Corpus or a |
|
| 114 |
* MainCorpus. Returns the object itself if its class is one of the the three |
|
| 115 |
* listed below. |
|
| 78 | 116 |
* |
| 79 |
* @param corpus
|
|
| 117 |
* @return
|
|
| 80 | 118 |
*/ |
| 81 |
public CQPCorpus(CQPCorpus corpus) {
|
|
| 82 |
super(corpus); |
|
| 119 |
synchronized public static CQPCorpus getFirstParentCorpus(TXMResult result) {
|
|
| 120 |
CQPCorpus corpus = (CQPCorpus) result.getFirstParent(Subcorpus.class); |
|
| 121 |
if (corpus == null) {
|
|
| 122 |
corpus = (CQPCorpus) result.getFirstParent(CQPCorpus.class); |
|
| 123 |
} |
|
| 124 |
if (corpus == null) {
|
|
| 125 |
corpus = (CQPCorpus) getParentMainCorpus(result); |
|
| 126 |
} |
|
| 127 |
return corpus; |
|
| 83 | 128 |
} |
| 84 |
|
|
| 129 |
public static String getNextQueryCounter() {
|
|
| 130 |
QUERY_COUNTER++; |
|
| 131 |
return QUERY_COUNTER.toString(); |
|
| 132 |
} |
|
| 133 |
public static String getNextSubcorpusCounter() {
|
|
| 134 |
SUBCORPUS_COUNTER++; |
|
| 135 |
return SUBCORPUS_COUNTER.toString(); |
|
| 136 |
} |
|
| 137 |
|
|
| 85 | 138 |
/** |
| 139 |
* retrieve all cached objects for an object |
|
| 86 | 140 |
* |
| 87 |
* @param partition |
|
| 141 |
* @param forObject |
|
| 142 |
* @param c |
|
| 143 |
* @return |
|
| 88 | 144 |
*/ |
| 89 |
public CQPCorpus(Partition partition) {
|
|
| 90 |
super(partition);
|
|
| 145 |
public static HashMap<Class<?>, ArrayList<?>> getObjectCache() {
|
|
| 146 |
return cache;
|
|
| 91 | 147 |
} |
| 92 |
|
|
| 148 |
|
|
| 93 | 149 |
/** |
| 94 |
* Empty the corpus cache |
|
| 150 |
* retrieve all cached objects of a certain class for an object |
|
| 151 |
* |
|
| 152 |
* @param forObject |
|
| 153 |
* @param c |
|
| 154 |
* @return |
|
| 95 | 155 |
*/ |
| 96 |
@Override
|
|
| 97 |
public void clean() {
|
|
| 98 |
if (cache != null) {
|
|
| 99 |
cache.clear();
|
|
| 156 |
public static ArrayList<?> getObjectCacheForClass(Class<?> c) {
|
|
| 157 |
HashMap<Class<?>, ArrayList<?>> oCache = getObjectCache();
|
|
| 158 |
if (!oCache.containsKey(c)) {
|
|
| 159 |
oCache.put(c, new ArrayList<Object>());
|
|
| 100 | 160 |
} |
| 161 |
return oCache.get(c); |
|
| 101 | 162 |
} |
| 102 |
|
|
| 163 |
|
|
| 103 | 164 |
/** |
| 104 |
* recursive method to clone a result
|
|
| 165 |
* Gets the main corpus parent.
|
|
| 105 | 166 |
* |
| 106 |
* @param newParent |
|
| 107 |
* necessary for cloning children in the right clone parent |
|
| 108 |
* @param all |
|
| 109 |
* @return |
|
| 167 |
* @return the first parent of class MainCorpus or the object itself if it is |
|
| 168 |
* its class. |
|
| 110 | 169 |
*/ |
| 111 |
protected TXMResult clone(TXMResult newParent, boolean all) {
|
|
| 112 |
CQPCorpus c = (CQPCorpus) super.clone(newParent, all); |
|
| 113 |
c.pID = "S"+getNextSubcorpusCounter(); |
|
| 114 |
return c; |
|
| 170 |
synchronized public static TXMResult getParentMainCorpus(TXMResult result) {
|
|
| 171 |
return result.getFirstParent(MainCorpus.class); |
|
| 115 | 172 |
} |
| 116 | 173 |
|
| 117 | 174 |
/** |
| 175 |
* remove a cached object |
|
| 118 | 176 |
* |
| 119 |
* @param parametersNodePath |
|
| 177 |
* @param forObject |
|
| 178 |
* @param toCache |
|
| 179 |
* @return |
|
| 120 | 180 |
*/ |
| 121 |
public CQPCorpus(String parametersNodePath) {
|
|
| 122 |
super(parametersNodePath); |
|
| 181 |
public static ArrayList<?> uncache(Class classToUnCache) {
|
|
| 182 |
if (classToUnCache == null) |
|
| 183 |
return null; |
|
| 184 |
|
|
| 185 |
return cache.remove(classToUnCache); |
|
| 123 | 186 |
} |
| 124 | 187 |
|
| 125 |
|
|
| 126 |
public static String getNextQueryCounter() {
|
|
| 127 |
QUERY_COUNTER++; |
|
| 128 |
return QUERY_COUNTER.toString(); |
|
| 188 |
/** |
|
| 189 |
* remove a cached object |
|
| 190 |
* |
|
| 191 |
* @param forObject |
|
| 192 |
* @param toCache |
|
| 193 |
* @return |
|
| 194 |
*/ |
|
| 195 |
public static boolean uncache(Object toUnCache) {
|
|
| 196 |
if (toUnCache == null) |
|
| 197 |
return false; |
|
| 198 |
|
|
| 199 |
ArrayList<?> ocCache = getObjectCacheForClass(toUnCache.getClass()); |
|
| 200 |
return ocCache.remove(toUnCache); |
|
| 129 | 201 |
} |
| 130 |
public static String getNextSubcorpusCounter() {
|
|
| 131 |
SUBCORPUS_COUNTER++; |
|
| 132 |
return SUBCORPUS_COUNTER.toString(); |
|
| 133 |
} |
|
| 134 | 202 |
|
| 203 |
/** All private infos of the corpus. */ |
|
| 204 |
protected String charset = "latin1"; //$NON-NLS-1$ |
|
| 205 |
|
|
| 206 |
/** |
|
| 207 |
* Gets the locale of the corpus. |
|
| 208 |
* |
|
| 209 |
* @return the locale |
|
| 210 |
*/ |
|
| 211 |
protected String lang = null; |
|
| 212 |
|
|
| 213 |
/** The language. */ |
|
| 214 |
protected String language = "???"; //$NON-NLS-1$ |
|
| 215 |
|
|
| 216 |
/** The corpus lexical units properties. */ |
|
| 217 |
protected List<WordProperty> lexicalUnitsProperties; |
|
| 218 |
|
|
| 135 | 219 |
/** The size. */ |
| 136 | 220 |
protected int size = -1; |
| 137 | 221 |
|
| 222 |
// /** |
|
| 223 |
// * Creates a new object mapping a CQP corpus. This constructor is not |
|
| 224 |
// * intended to be used directly. Use {@link CorpusManager#getCorpus(String)}
|
|
| 225 |
// * . |
|
| 226 |
// * |
|
| 227 |
// * @param pID |
|
| 228 |
// * the id of the cqp corpus |
|
| 229 |
// * |
|
| 230 |
// * @throws InvalidCqpIdException |
|
| 231 |
// * the invalid cqp id exception |
|
| 232 |
// */ |
|
| 233 |
// protected Corpus(Corpus parentCorpus) throws InvalidCqpIdException {
|
|
| 234 |
// super(parentCorpus); |
|
| 235 |
// if (parentCorpus ins) |
|
| 236 |
//// checkCqpId(pID); |
|
| 237 |
//// this.pID = pID; |
|
| 238 |
//// |
|
| 239 |
//// // FIXME: at this moment, store the CQPID as UUIDD for persistence tests |
|
| 240 |
//// this.uniqueID = this.pID; |
|
| 241 |
// } |
|
| 242 |
// |
|
| 243 |
// /** |
|
| 244 |
// * Creates a new object mapping a CQP corpus. This constructor is not |
|
| 245 |
// * intended to be used directly. Use {@link CorpusManager#getCorpus(String)}
|
|
| 246 |
// * . |
|
| 247 |
// * |
|
| 248 |
// * @param pID |
|
| 249 |
// * the id of the cqp corpus |
|
| 250 |
// * |
|
| 251 |
// * @throws InvalidCqpIdException |
|
| 252 |
// * the invalid cqp id exception |
|
| 253 |
// */ |
|
| 254 |
// protected Corpus(Corpus parentCorpus) throws InvalidCqpIdException {
|
|
| 255 |
// super(null, null, pID); |
|
| 256 |
//// checkCqpId(pID); |
|
| 257 |
//// this.pID = pID; |
|
| 258 |
//// |
|
| 259 |
//// // FIXME: at this moment, store the CQPID as UUIDD for persistence tests |
|
| 260 |
//// this.uniqueID = this.pID; |
|
| 261 |
// } |
|
| 262 |
|
|
| 138 | 263 |
/** The corpus structural units. */ |
| 139 | 264 |
protected List<StructuralUnit> structuralUnits; |
| 140 | 265 |
|
| 141 |
/** The corpus lexical units properties. */
|
|
| 142 |
protected List<WordProperty> lexicalUnitsProperties;
|
|
| 266 |
/** The symbol. */
|
|
| 267 |
protected String symbol;
|
|
| 143 | 268 |
|
| 269 |
protected StructuralUnitProperty textIdStructuralUnitProperty; |
|
| 270 |
// public HashSet<Object> getStoredData(Class class1) {
|
|
| 271 |
// |
|
| 272 |
// if (!storedData.containsKey(class1)) {
|
|
| 273 |
// storedData.put(class1, new HashSet<Object>()); |
|
| 274 |
// } |
|
| 275 |
// |
|
| 276 |
// return storedData.get(class1); |
|
| 277 |
// } |
|
| 278 |
// |
|
| 279 |
// /** |
|
| 280 |
// * TODO: fix this hack to store Lexicons |
|
| 281 |
// * |
|
| 282 |
// * @param o a lexicon |
|
| 283 |
// */ |
|
| 284 |
// public void storeData(Object o) {
|
|
| 285 |
// if (storedData.containsKey(o.getClass())) {
|
|
| 286 |
// storedData.put(o.getClass(), new HashSet<Object>()); |
|
| 287 |
// } |
|
| 288 |
// |
|
| 289 |
// HashSet<Object> hash = storedData.get(o.getClass()); |
|
| 290 |
// hash.add(o); |
|
| 291 |
// } |
|
| 292 |
|
|
| 144 | 293 |
protected int[] textLimits; |
| 145 | 294 |
|
| 146 |
/** All private infos of the corpus. */ |
|
| 147 |
private String charset = "latin1"; //$NON-NLS-1$ |
|
| 295 |
protected StructuralUnit textStructuralUnit; |
|
| 148 | 296 |
|
| 149 |
/** The language. */ |
|
| 150 |
private String language = "???"; //$NON-NLS-1$ |
|
| 151 |
|
|
| 297 |
protected WordProperty wordProperty = null; |
|
| 298 |
|
|
| 152 | 299 |
/** |
| 153 |
* Gets the locale of the corpus. |
|
| 154 | 300 |
* |
| 155 |
* @return the locale
|
|
| 301 |
* @param corpus
|
|
| 156 | 302 |
*/ |
| 157 |
String lang = null; |
|
| 303 |
public CQPCorpus(CQPCorpus corpus) {
|
|
| 304 |
super(corpus); |
|
| 305 |
} |
|
| 158 | 306 |
|
| 159 |
/** The nocorpus. */ |
|
| 160 |
protected static int nocorpus = 1; |
|
| 307 |
/** |
|
| 308 |
* |
|
| 309 |
* @param partition |
|
| 310 |
*/ |
|
| 311 |
public CQPCorpus(Partition partition) {
|
|
| 312 |
super(partition); |
|
| 313 |
} |
|
| 161 | 314 |
|
| 162 |
/** The prefix r. */ |
|
| 163 |
protected static String prefixR = "Corpus"; //$NON-NLS-1$ |
|
| 315 |
/** |
|
| 316 |
* |
|
| 317 |
* @param project |
|
| 318 |
*/ |
|
| 319 |
protected CQPCorpus(Project project) {
|
|
| 320 |
super(project); |
|
| 321 |
} |
|
| 164 | 322 |
|
| 165 |
/** The symbol. */ |
|
| 166 |
private String symbol; |
|
| 323 |
// /** |
|
| 324 |
// * Drop all the partitions. |
|
| 325 |
// * |
|
| 326 |
// * @throws CqiClientException |
|
| 327 |
// * the cqi client exception |
|
| 328 |
// */ |
|
| 329 |
// public void dropAllPartitions() throws CqiClientException {
|
|
| 330 |
// List<Partition> _partitions = (List<Partition>) getChildren(Partition.class); |
|
| 331 |
// for (Partition partition : _partitions) {
|
|
| 332 |
// this.dropPartition(partition); |
|
| 333 |
// } |
|
| 334 |
// _partitions = null; |
|
| 335 |
// } |
|
| 167 | 336 |
|
| 168 |
protected static String WORD = TXMPreferences.DEFAULT_UNIT_PROPERTY; |
|
| 337 |
/** |
|
| 338 |
* |
|
| 339 |
* @param parametersNodePath |
|
| 340 |
*/ |
|
| 341 |
public CQPCorpus(String parametersNodePath) {
|
|
| 342 |
super(parametersNodePath); |
|
| 343 |
} |
|
| 169 | 344 |
|
| 170 |
protected WordProperty wordProperty = null; |
|
| 345 |
// /** |
|
| 346 |
// * Drops a partition. |
|
| 347 |
// * |
|
| 348 |
// * @param partition |
|
| 349 |
// * the partition |
|
| 350 |
// * |
|
| 351 |
// * @throws CqiClientException |
|
| 352 |
// * the cqi client exception |
|
| 353 |
// */ |
|
| 354 |
// public void dropPartition(Partition partition) throws CqiClientException {
|
|
| 355 |
// Log.finest(SearchEngineCoreMessages.info_deletingPartition + |
|
| 356 |
// partition.getName()); |
|
| 357 |
// for (Part part : partition.getParts()) |
|
| 358 |
// try {
|
|
| 359 |
// CorpusManager.getCorpusManager().getCqiClient().dropSubCorpus(part.getQualifiedCqpId()); |
|
| 360 |
// } catch (Exception e) {
|
|
| 361 |
// throw new CqiClientException(e); |
|
| 362 |
// } |
|
| 363 |
// } |
|
| 171 | 364 |
|
| 172 |
protected static Integer SUBCORPUS_COUNTER = new Integer(0); |
|
| 365 |
/* |
|
| 366 |
* (non-Javadoc) |
|
| 367 |
* |
|
| 368 |
* @see org.txm.objects.TxmObject#load() |
|
| 369 |
*/ |
|
| 370 |
protected boolean _load(Element e) {
|
|
| 371 |
// System.out.println("*** Load corpus: "+name);
|
|
| 372 |
if (e == null) {
|
|
| 373 |
Log.warning(TXMCoreMessages.warningColonCantLoadCorpus + this); |
|
| 374 |
Log.warning(TXMCoreMessages.informationsFromWorkspaceSelfElementNull); |
|
| 375 |
return false; |
|
| 376 |
} |
|
| 173 | 377 |
|
| 174 |
private static Integer QUERY_COUNTER = new Integer(0); |
|
| 378 |
// 1- texts queries then |
|
| 379 |
// 2- get metadatas, pattributes, sattributes, editions, biblios, uis, |
|
| 380 |
super._load(e); |
|
| 381 |
// System.out.println("Load corpus : "+this.name);
|
|
| 382 |
// this.loadMetadata(); // read <prop>s |
|
| 175 | 383 |
|
| 176 |
// /** |
|
| 177 |
// * Creates a new object mapping a CQP corpus. This constructor is not |
|
| 178 |
// * intended to be used directly. Use {@link CorpusManager#getCorpus(String)}
|
|
| 179 |
// * . |
|
| 180 |
// * |
|
| 181 |
// * @param pID |
|
| 182 |
// * the id of the cqp corpus |
|
| 183 |
// * |
|
| 184 |
// * @throws InvalidCqpIdException |
|
| 185 |
// * the invalid cqp id exception |
|
| 186 |
// */ |
|
| 187 |
// protected Corpus(Corpus parentCorpus) throws InvalidCqpIdException {
|
|
| 188 |
// super(parentCorpus); |
|
| 189 |
// if (parentCorpus ins) |
|
| 190 |
//// checkCqpId(pID); |
|
| 191 |
//// this.pID = pID; |
|
| 192 |
//// |
|
| 193 |
//// // FIXME: at this moment, store the CQPID as UUIDD for persistence tests |
|
| 194 |
//// this.uniqueID = this.pID; |
|
| 195 |
// } |
|
| 196 |
// |
|
| 197 |
// /** |
|
| 198 |
// * Creates a new object mapping a CQP corpus. This constructor is not |
|
| 199 |
// * intended to be used directly. Use {@link CorpusManager#getCorpus(String)}
|
|
| 200 |
// * . |
|
| 201 |
// * |
|
| 202 |
// * @param pID |
|
| 203 |
// * the id of the cqp corpus |
|
| 204 |
// * |
|
| 205 |
// * @throws InvalidCqpIdException |
|
| 206 |
// * the invalid cqp id exception |
|
| 207 |
// */ |
|
| 208 |
// protected Corpus(Corpus parentCorpus) throws InvalidCqpIdException {
|
|
| 209 |
// super(null, null, pID); |
|
| 210 |
//// checkCqpId(pID); |
|
| 211 |
//// this.pID = pID; |
|
| 212 |
//// |
|
| 213 |
//// // FIXME: at this moment, store the CQPID as UUIDD for persistence tests |
|
| 214 |
//// this.uniqueID = this.pID; |
|
| 215 |
// } |
|
| 216 |
|
|
| 384 |
// 3- build saved subcorpus and partition |
|
| 385 |
// System.out.println("restore subcorpora: "+selfElement);
|
|
| 386 |
NodeList preBuildElems = e.getElementsByTagName("preBuild"); //$NON-NLS-1$
|
|
| 387 |
if (preBuildElems.getLength() > 0) {
|
|
| 388 |
Element preBuildElem = (Element) preBuildElems.item(0); |
|
| 389 |
NodeList subcorpusElems = preBuildElem.getElementsByTagName("subcorpus"); //$NON-NLS-1$
|
|
| 390 |
for (int i = 0; i < subcorpusElems.getLength(); i++) {
|
|
| 391 |
Element subcorpusElem = (Element) subcorpusElems.item(i); |
|
| 392 |
if (!subcorpusElem.getParentNode().equals(preBuildElem)) |
|
| 393 |
continue; // level 1 elements |
|
| 394 |
// System.out.println("subcorpus "+subcorpusElem.getAttribute("name"));
|
|
| 395 |
// try {
|
|
| 396 |
Subcorpus subcorp = new Subcorpus(this); |
|
| 397 |
subcorp._load(subcorpusElem); |
|
| 398 |
// subcorp.compute(); |
|
| 399 |
// } catch (CqiClientException ex) {
|
|
| 400 |
// Log.warning(this.pID + TXMCoreMessages.failedToRestoreSubcorpus + pID |
|
| 401 |
// + " : " + ex); //$NON-NLS-1$ |
|
| 402 |
// } |
|
| 403 |
} |
|
| 404 |
|
|
| 405 |
NodeList partitionElems = preBuildElem.getElementsByTagName("partition"); //$NON-NLS-1$
|
|
| 406 |
for (int i = 0; i < partitionElems.getLength(); i++) {
|
|
| 407 |
Element partitionElem = (Element) partitionElems.item(i); |
|
| 408 |
if (!partitionElem.getParentNode().equals(preBuildElem)) |
|
| 409 |
continue; // level 1 elements |
|
| 410 |
String name = partitionElem.getAttribute("name"); //$NON-NLS-1$
|
|
| 411 |
List<String> names = new ArrayList<String>(); |
|
| 412 |
List<String> queries = new ArrayList<String>(); |
|
| 413 |
|
|
| 414 |
NodeList partElems = partitionElem.getElementsByTagName("part"); //$NON-NLS-1$
|
|
| 415 |
for (int j = 0; j < partElems.getLength(); j++) {
|
|
| 416 |
Element part = (Element) partElems.item(j); |
|
| 417 |
names.add(part.getAttribute("name")); //$NON-NLS-1$
|
|
| 418 |
queries.add(part.getAttribute("query")); //$NON-NLS-1$
|
|
| 419 |
} |
|
| 420 |
try {
|
|
| 421 |
// System.out.println("Create Partition with corpus "+this+" : "+name+", queries
|
|
| 422 |
// "+queries+", names "+names); |
|
| 423 |
Partition partition = new Partition(this); |
|
| 424 |
partition.setParameters(name, queries, names); |
|
| 425 |
|
|
| 426 |
// partition.setSelfElement(partitionElem); |
|
| 427 |
// partition.load(); |
|
| 428 |
// partition.compute(); |
|
| 429 |
} catch (Exception ex) {
|
|
| 430 |
Log.warning(this.pID + TXMCoreMessages.failedToRestorePartition + name + " : " + ex); //$NON-NLS-1$ |
|
| 431 |
// c.getParentNode().removeChild(c); |
|
| 432 |
} |
|
| 433 |
} |
|
| 434 |
} |
|
| 435 |
|
|
| 436 |
// 4- initialize JPA persistence of annotations |
|
| 437 |
// try {
|
|
| 438 |
// AnnotationManager.getInstance().initTemporaryAnnotationDatabase(this); |
|
| 439 |
// } catch(Exception e) {
|
|
| 440 |
// System.out.println("Fail to load annotation service: "+e);
|
|
| 441 |
// Log.printStackTrace(e); |
|
| 442 |
// } |
|
| 443 |
// |
|
| 444 |
return true; |
|
| 445 |
} |
|
| 446 |
|
|
| 217 | 447 |
/** |
| 218 |
* Creates a subcorpus using workspace definition. |
|
| 219 |
* |
|
| 220 |
* @param elem the XML element |
|
| 221 |
* @return the subcorpus |
|
| 222 |
* @throws CqiClientException the cqi client exception |
|
| 448 |
* Empty the corpus cache |
|
| 223 | 449 |
*/ |
| 224 |
public Subcorpus createSubcorpus(Element elem) throws CqiClientException {
|
|
| 225 |
CQLQuery query = new CQLQuery(elem.getAttribute("query")); //$NON-NLS-1$
|
|
| 226 |
String subcorpusName = elem.getAttribute("name"); //$NON-NLS-1$
|
|
| 450 |
@Override |
|
| 451 |
public void clean() {
|
|
| 452 |
if (cache != null) {
|
|
| 453 |
cache.clear(); |
|
| 454 |
} |
|
| 455 |
|
|
| 456 |
charset = "latin1"; //$NON-NLS-1$ |
|
| 457 |
lang = null; |
|
| 458 |
language = "???"; //$NON-NLS-1$ |
|
| 459 |
lexicalUnitsProperties = null; |
|
| 460 |
size = -1; |
|
| 461 |
structuralUnits = null; |
|
| 462 |
symbol = null; |
|
| 463 |
textIdStructuralUnitProperty = null; |
|
| 464 |
textLimits = null; |
|
| 465 |
textStructuralUnit = null; |
|
| 466 |
wordProperty = null; |
|
| 467 |
} |
|
| 227 | 468 |
|
| 228 |
Subcorpus subcorpus; |
|
| 229 |
String subcorpusCqpId = subcorpusNamePrefix + getNextSubcorpusCounter(); |
|
| 469 |
/** |
|
| 470 |
* recursive method to clone a result |
|
| 471 |
* |
|
| 472 |
* @param newParent |
|
| 473 |
* necessary for cloning children in the right clone parent |
|
| 474 |
* @param all |
|
| 475 |
* @return |
|
| 476 |
*/ |
|
| 477 |
protected TXMResult clone(TXMResult newParent, boolean all) {
|
|
| 478 |
CQPCorpus c = (CQPCorpus) super.clone(newParent, all); |
|
| 479 |
c.pID = "S" + getNextSubcorpusCounter(); |
|
| 480 |
return c; |
|
| 481 |
} |
|
| 230 | 482 |
|
| 231 |
// long start = System.currentTimeMillis(); |
|
| 232 |
try {
|
|
| 233 |
CorpusManager.getCorpusManager().getCqiClient().cqpQuery(this.getQualifiedCqpId(), subcorpusCqpId, |
|
| 234 |
query.getQueryString()); |
|
| 235 |
subcorpus = new Subcorpus(this); |
|
| 236 |
subcorpus.setParameters(subcorpusCqpId, subcorpusName, query); |
|
| 237 |
subcorpus.compute(); |
|
| 238 |
} catch (Exception e) {
|
|
| 239 |
throw new CqiClientException(e); |
|
| 483 |
@Override |
|
| 484 |
public int compareTo(TXMResult o) {
|
|
| 485 |
// Compare node weights |
|
| 486 |
int output = super.compareTo(o); |
|
| 487 |
// Compare simple names if weights are equal |
|
| 488 |
if (this.pID == null) {
|
|
| 489 |
return -1; |
|
| 240 | 490 |
} |
| 241 |
|
|
| 242 |
return subcorpus; |
|
| 491 |
if (o.getSimpleName() == null) |
|
| 492 |
return 1; |
|
| 493 |
if (output == 0) {
|
|
| 494 |
output = this.getSimpleName().compareTo(o.getSimpleName()); |
|
| 495 |
} |
|
| 496 |
return output; |
|
| 243 | 497 |
} |
| 244 | 498 |
|
| 245 | 499 |
/** |
| ... | ... | |
| 255 | 509 |
* @throws CqiClientException |
| 256 | 510 |
* the cqi client exception |
| 257 | 511 |
*/ |
| 258 |
public Subcorpus createSubcorpus(CQLQuery query, String subcorpusName) |
|
| 259 |
throws CqiClientException {
|
|
| 512 |
public Subcorpus createSubcorpus(CQLQuery query, String subcorpusName) throws CqiClientException {
|
|
| 260 | 513 |
Subcorpus sc = createSubcorpus(query, subcorpusName, false); |
| 261 | 514 |
return sc; |
| 262 | 515 |
} |
| ... | ... | |
| 264 | 517 |
/** |
| 265 | 518 |
* Creates a subcorpus and save configuration in the workspace. |
| 266 | 519 |
* |
| 267 |
* @param query the query |
|
| 268 |
* @param subcorpusName the subcorpus name |
|
| 269 |
* @param registered the registered |
|
| 520 |
* @param query |
|
| 521 |
* the query |
|
| 522 |
* @param subcorpusName |
|
| 523 |
* the subcorpus name |
|
| 524 |
* @param registered |
|
| 525 |
* the registered |
|
| 270 | 526 |
* @return the subcorpus |
| 271 |
* @throws CqiClientException the cqi client exception |
|
| 527 |
* @throws CqiClientException |
|
| 528 |
* the cqi client exception |
|
| 272 | 529 |
*/ |
| 273 | 530 |
public Subcorpus createSubcorpus(CQLQuery query, String subcorpusName, boolean registered) throws CqiClientException {
|
| 274 |
|
|
Formats disponibles : Unified diff