Révision 1137
| tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbMakeAll.java (revision 1137) | ||
|---|---|---|
| 103 | 103 |
*/ |
| 104 | 104 |
public boolean run(String corpusName, |
| 105 | 105 |
String pathToRegistry, boolean monitorOutput) throws ServerNotFoundException, InterruptedException, IOException {
|
| 106 |
|
|
| 106 |
new File(pathToRegistry).mkdirs(); |
|
| 107 | 107 |
File pathToExecutable = new File(CQPLibPreferences.getInstance().getString(CQPLibPreferences.CQI_SERVER_PATH_TO_CQPLIB), |
| 108 | 108 |
"cwb-makeall"+(System.getProperty("os.name").toLowerCase().contains("windows")?".exe":""));
|
| 109 | 109 |
|
| ... | ... | |
| 139 | 139 |
pathToExecutable = "\"" + pathToExecutable + "\""; //$NON-NLS-1$ //$NON-NLS-2$ |
| 140 | 140 |
pathToRegistry = "\"" + pathToRegistry + "\""; //$NON-NLS-1$ //$NON-NLS-2$ |
| 141 | 141 |
} |
| 142 |
|
|
| 143 |
if (!new File(pathToExecutable).exists()) {
|
|
| 144 |
System.out.println("Error: path to cwb-makeall not found: "+pathToExecutable);
|
|
| 145 |
return false; |
|
| 146 |
} |
|
| 147 |
if (!new File(pathToExecutable).canExecute()) {
|
|
| 148 |
System.out.println("Error: path to cwb-makeall not executable: "+pathToExecutable);
|
|
| 149 |
return false; |
|
| 150 |
} |
|
| 151 |
|
|
| 142 | 152 |
ArrayList<String> cmd = new ArrayList<String>(); |
| 143 | 153 |
cmd.addAll(Arrays.asList(pathToExecutable, |
| 144 | 154 |
"-r", pathToRegistry, "-V", corpusName.toUpperCase())); //$NON-NLS-1$ //$NON-NLS-2$ |
| tmp/org.txm.searchengine.cqp.core/src/org/txm/importer/cwb/CwbEncode.java (revision 1137) | ||
|---|---|---|
| 227 | 227 |
if (pathToRegistry.startsWith("\\\\")) pathToRegistry = pathToRegistry.replace("\\\\", "//"); // fix UNC paths for mingw
|
| 228 | 228 |
if (pathToData.startsWith("\\\\")) pathToData = pathToData.replace("\\\\", "//"); // fix UNC paths for mingw
|
| 229 | 229 |
|
| 230 |
|
|
| 231 |
if (!new File(pathToExecutable).exists()) {
|
|
| 232 |
System.out.println("Error: path to cwb-encode not found: "+pathToExecutable);
|
|
| 233 |
return false; |
|
| 234 |
} |
|
| 235 |
if (!new File(pathToExecutable).canExecute()) {
|
|
| 236 |
System.out.println("Error: path to cwb-encode not executable: "+pathToExecutable);
|
|
| 237 |
return false; |
|
| 238 |
} |
|
| 239 |
|
|
| 230 | 240 |
/* |
| 231 | 241 |
* if (System.getProperty("os.name").contains("Win")) { pathToExecutable
|
| 232 | 242 |
* = "\""+pathToExecutable+"\""; pathToData = "\""+pathToData+"\""; |
| tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/WordAnnotationToolbar.java (revision 1137) | ||
|---|---|---|
| 721 | 721 |
|
| 722 | 722 |
@Override |
| 723 | 723 |
public boolean isDirty() {
|
| 724 |
return annotManager.isDirty(); |
|
| 724 |
if (annotManager != null) {
|
|
| 725 |
return annotManager.isDirty(); |
|
| 726 |
} |
|
| 727 |
return false; |
|
| 725 | 728 |
} |
| 726 | 729 |
|
| 727 | 730 |
@Override |
| tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/RecodeCorpus.java (revision 1137) | ||
|---|---|---|
| 23 | 23 |
import org.txm.Toolbox; |
| 24 | 24 |
import org.txm.annotation.kr.core.conversion.CorpusRuledConvertion; |
| 25 | 25 |
import org.txm.core.preferences.TBXPreferences; |
| 26 |
import org.txm.importer.ImportKeys; |
|
| 27 | 26 |
import org.txm.objects.Project; |
| 28 | 27 |
import org.txm.rcp.commands.CloseEditorsUsing; |
| 29 | 28 |
import org.txm.rcp.handlers.scripts.ExecuteImportScript; |
| ... | ... | |
| 114 | 113 |
// String txmhome = Toolbox.getTxmHomePath(); |
| 115 | 114 |
|
| 116 | 115 |
|
| 117 |
project.getPreferencesScope().getNode("import").put(ImportKeys.MULTITHREAD, "false"); //too soon
|
|
| 118 |
project.getPreferencesScope().getNode("import").putBoolean(ImportKeys.DEBUG, Log.getLevel().intValue() < Level.WARNING.intValue()); // need debug for experimental stuff
|
|
| 119 |
project.getPreferencesScope().getNode("import").put(ImportKeys.UPDATECORPUS, "true");
|
|
| 116 |
project.setDoMultiThread(false); //too soon |
|
| 117 |
project.setDoUpdate(true); |
|
| 120 | 118 |
|
| 121 | 119 |
// monitor.setTaskName("Updating corpus");
|
| 122 | 120 |
// File scriptDir = new File(txmhome, "scripts/groovy/user/org/txm/scripts/importer/xtz"); |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZCompiler.groovy (revision 1137) | ||
|---|---|---|
| 7 | 7 |
import org.txm.importer.cwb.* |
| 8 | 8 |
import org.txm.stat.utils.ConsoleProgressBar |
| 9 | 9 |
import org.txm.core.preferences.TXMPreferences |
| 10 |
import org.txm.core.preferences.TBXPreferences |
|
| 10 | 11 |
import org.txm.libs.cqp.CQPLibPreferences |
| 11 | 12 |
|
| 12 | 13 |
import javax.xml.stream.* |
| ... | ... | |
| 34 | 35 |
|
| 35 | 36 |
wtag = module.getProject().getTokenizerParameter("wordelement", "w");
|
| 36 | 37 |
|
| 37 |
doNormalizeAttributeValues = "true".equals(module.getProject().getPreferences().getNode("import").get(ImportKeys.NORMALISEATTRIBUTEVALUES))
|
|
| 38 |
doNormalizeAnaValues = "true".equals(module.getProject().getPreferences().getNode("import").get(ImportKeys.NORMALISEANAVALUES))
|
|
| 38 |
doNormalizeAttributeValues = "true".equals(module.getProject().getPreferencesScope().getNode("import").get(TBXPreferences.NORMALISEATTRIBUTEVALUES, "false"))
|
|
| 39 |
doNormalizeAnaValues = "true".equals(module.getProject().getPreferencesScope().getNode("import").get(TBXPreferences.NORMALISEANAVALUES, "false"))
|
|
| 39 | 40 |
} |
| 40 | 41 |
|
| 41 | 42 |
public void process(ArrayList<File> files) {
|
| ... | ... | |
| 60 | 61 |
corpus.setName(corpusname); |
| 61 | 62 |
corpus.setDescription("Built with the XTZ import module");
|
| 62 | 63 |
|
| 63 |
String cleanDirectories = module.getProject().getPreferences().getNode("import").get(ImportKeys.CLEAN, "true");
|
|
| 64 |
if ("true".equals(cleanDirectories)) {
|
|
| 64 |
if (module.getProject().getCleanAfterBuild()) {
|
|
| 65 | 65 |
new File(module.getBinaryDirectory(), "cqp").deleteDir() |
| 66 | 66 |
} |
| 67 | 67 |
|
| ... | ... | |
| 245 | 245 |
println "Error: The registry file was not created: $regPath. See https://groupes.renater.fr/wiki/txm-users/public/faq" |
| 246 | 246 |
return false; |
| 247 | 247 |
} |
| 248 |
cwbMa.run(corpusname, module.getBinaryDirectory().getAbsolutePath() + "/registry");
|
|
| 248 |
cwbMa.run(corpusname, regPath);
|
|
| 249 | 249 |
|
| 250 | 250 |
// remove milestones from CWB registry and data files |
| 251 | 251 |
FixMilestoneDeclarations fm = new FixMilestoneDeclarations( |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImport.groovy (revision 1137) | ||
|---|---|---|
| 9 | 9 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 10 | 10 |
import org.txm.utils.xml.DomUtils; |
| 11 | 11 |
import org.txm.metadatas.Metadatas |
| 12 |
import org.txm.objects.BaseParameters |
|
| 13 | 12 |
import org.txm.utils.io.FileCopy; |
| 14 | 13 |
import org.txm.* |
| 15 | 14 |
import org.txm.objects.* |
| ... | ... | |
| 120 | 119 |
|
| 121 | 120 |
public static void main(String[] args) {
|
| 122 | 121 |
|
| 123 |
long start = System.currentTimeMillis() |
|
| 124 |
|
|
| 125 |
String userDir = System.getProperty("user.home")
|
|
| 126 |
Toolbox.setParam(Toolbox.INSTALL_DIR,new File("/usr/lib/TXM"));
|
|
| 127 |
//Toolbox.setParam(Toolbox.INSTALL_DIR,new File("C:\\Program Files\\TXM"));//For Windows
|
|
| 128 |
Toolbox.setParam(Toolbox.METADATA_ENCODING, "UTF-8"); |
|
| 129 |
Toolbox.setParam(Toolbox.METADATA_COLSEPARATOR, ","); |
|
| 130 |
Toolbox.setParam(Toolbox.METADATA_TXTSEPARATOR, "\""); |
|
| 131 |
//Toolbox.setParam(Toolbox.TREETAGGER_MODELS_PATH,new File("C:\\Program Files\\treetagger\\models"));//for Windows
|
|
| 132 |
Toolbox.setParam(Toolbox.USER_TXM_HOME, new File(userDir, "TXM")); |
|
| 133 |
|
|
| 134 |
//File importParametersFile = new File("/home/mdecorde/xml/brown-for-xtz/import.xml");
|
|
| 135 |
// File importParametersFile = new File("/home/mdecorde/xml/qgraalc/qgraal_cw/import.xml"); // new import
|
|
| 136 |
//File importParametersFile = new File("/home/mdecorde/TXM/corpora/QGRAALXTZ/import.xml"); // corpus update
|
|
| 137 |
// File importParametersFile = new File("/home/mdecorde/xml/annotation/import.xml"); // new import
|
|
| 138 |
//File importParametersFile = new File("/home/mdecorde/xml/baiptest/import.xml"); // new import
|
|
| 139 |
//File importParametersFile = new File("/home/mdecorde/TXM/corpora/BAIP/import.xml"); // corpus update
|
|
| 140 |
File importParametersFile = new File("/home/mdecorde/xml/xtzsmall/import.xml");
|
|
| 141 |
BaseParameters b = new BaseParameters(importParametersFile); |
|
| 142 |
b.getKeyValueParameters().put(ImportKeys.CLEAN, "false") |
|
| 143 |
b.getKeyValueParameters().put(ImportKeys.MULTITHREAD, "false") |
|
| 144 |
b.getKeyValueParameters().put(ImportKeys.DEBUG, "true") |
|
| 145 |
b.getKeyValueParameters().put(ImportKeys.UPDATECORPUS, "false") |
|
| 146 |
|
|
| 147 |
XTZImport i = new XTZImport(b); |
|
| 148 |
i.start(); |
|
| 149 |
|
|
| 150 |
println "Done: "+i.isSuccessful |
|
| 151 |
|
|
| 152 |
long end = System.currentTimeMillis() |
|
| 153 |
println "TIME: "+(end-start) |
|
| 122 |
// long start = System.currentTimeMillis()
|
|
| 123 |
// |
|
| 124 |
// String userDir = System.getProperty("user.home")
|
|
| 125 |
// Toolbox.setParam(Toolbox.INSTALL_DIR,new File("/usr/lib/TXM"));
|
|
| 126 |
// //Toolbox.setParam(Toolbox.INSTALL_DIR,new File("C:\\Program Files\\TXM"));//For Windows
|
|
| 127 |
// Toolbox.setParam(Toolbox.METADATA_ENCODING, "UTF-8");
|
|
| 128 |
// Toolbox.setParam(Toolbox.METADATA_COLSEPARATOR, ",");
|
|
| 129 |
// Toolbox.setParam(Toolbox.METADATA_TXTSEPARATOR, "\"");
|
|
| 130 |
// //Toolbox.setParam(Toolbox.TREETAGGER_MODELS_PATH,new File("C:\\Program Files\\treetagger\\models"));//for Windows
|
|
| 131 |
// Toolbox.setParam(Toolbox.USER_TXM_HOME, new File(userDir, "TXM"));
|
|
| 132 |
// |
|
| 133 |
// //File importParametersFile = new File("/home/mdecorde/xml/brown-for-xtz/import.xml");
|
|
| 134 |
// // File importParametersFile = new File("/home/mdecorde/xml/qgraalc/qgraal_cw/import.xml"); // new import
|
|
| 135 |
// //File importParametersFile = new File("/home/mdecorde/TXM/corpora/QGRAALXTZ/import.xml"); // corpus update
|
|
| 136 |
// // File importParametersFile = new File("/home/mdecorde/xml/annotation/import.xml"); // new import
|
|
| 137 |
// //File importParametersFile = new File("/home/mdecorde/xml/baiptest/import.xml"); // new import
|
|
| 138 |
// //File importParametersFile = new File("/home/mdecorde/TXM/corpora/BAIP/import.xml"); // corpus update
|
|
| 139 |
// File importParametersFile = new File("/home/mdecorde/xml/xtzsmall/import.xml");
|
|
| 140 |
// BaseParameters b = new BaseParameters(importParametersFile);
|
|
| 141 |
// b.getKeyValueParameters().put(ImportKeys.CLEAN, "false")
|
|
| 142 |
// b.getKeyValueParameters().put(ImportKeys.MULTITHREAD, "false")
|
|
| 143 |
// b.getKeyValueParameters().put(ImportKeys.DEBUG, "true")
|
|
| 144 |
// b.getKeyValueParameters().put(ImportKeys.UPDATECORPUS, "false")
|
|
| 145 |
// |
|
| 146 |
// XTZImport i = new XTZImport(b);
|
|
| 147 |
// i.start();
|
|
| 148 |
// |
|
| 149 |
// println "Done: "+i.isSuccessful
|
|
| 150 |
// |
|
| 151 |
// long end = System.currentTimeMillis()
|
|
| 152 |
// println "TIME: "+(end-start)
|
|
| 154 | 153 |
} |
| 155 | 154 |
} |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/TTAnnotater.groovy (revision 1137) | ||
|---|---|---|
| 6 | 6 |
import org.txm.importer.xtz.* |
| 7 | 7 |
import org.txm.Toolbox |
| 8 | 8 |
import org.txm.core.engines.* |
| 9 |
|
|
| 9 | 10 |
/** |
| 10 | 11 |
* Wraps current Annotate class into the import workflow |
| 11 | 12 |
* |
| ... | ... | |
| 22 | 23 |
public void process() {
|
| 23 | 24 |
|
| 24 | 25 |
//String model = module.getParameters().get(ImportKeys.TTMODEL); |
| 25 |
String cleanDirectories = module.getParameters().getKeyValueParameters().get(ImportKeys.CLEAN);
|
|
| 26 |
boolean cleanDirectories = module.getProject().getCleanAfterBuild();
|
|
| 26 | 27 |
|
| 27 |
String corpusname = module.getParameters().getCorpusName(); |
|
| 28 |
def corpusElem = module.getParameters().getCorpora().get(corpusname); |
|
| 29 |
String lang = corpusElem.getAttribute("lang");
|
|
| 28 |
String corpusname = module.getProject().getName(); |
|
| 29 |
String lang = module.getProject().getLang(); |
|
| 30 | 30 |
|
| 31 | 31 |
def engine = Toolbox.getEngineManager(EngineType.ANNOTATION).getEngine("TreeTagger")
|
| 32 | 32 |
if (module.isMultiThread()) {
|
| ... | ... | |
| 43 | 43 |
} |
| 44 | 44 |
} |
| 45 | 45 |
|
| 46 |
if ("true".equals(cleanDirectories)) {
|
|
| 46 |
if (cleanDirectories) {
|
|
| 47 | 47 |
new File(module.getBinaryDirectory(), "treetagger").deleteDir() |
| 48 | 48 |
new File(module.getBinaryDirectory(), "annotations").deleteDir() |
| 49 | 49 |
} |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZPager.groovy (revision 1137) | ||
|---|---|---|
| 12 | 12 |
import org.txm.utils.i18n.* |
| 13 | 13 |
import org.txm.importer.xtz.* |
| 14 | 14 |
import javax.xml.stream.* |
| 15 |
import org.txm.objects.* |
|
| 15 | 16 |
|
| 16 | 17 |
class XTZPager extends Pager {
|
| 17 | 18 |
|
| 18 |
BaseParameters params;
|
|
| 19 |
Project project;
|
|
| 19 | 20 |
|
| 20 | 21 |
Element corpusElem; |
| 21 | 22 |
String lang; |
| ... | ... | |
| 28 | 29 |
public XTZPager(ImportModule module) {
|
| 29 | 30 |
super(module, "default"); |
| 30 | 31 |
|
| 31 |
params = module.getParameters()
|
|
| 32 |
project = module.getProject()
|
|
| 32 | 33 |
|
| 33 |
corpusElem = params.corpora.get(corpusname); |
|
| 34 |
lang = corpusElem.getAttribute("lang");
|
|
| 35 |
wordsPerPage = params.getWordsPerPage("default")
|
|
| 36 |
page_element = params.getPageElement("default")
|
|
| 37 |
wordTag = module.getParameters().getWordElement().getTextContent() |
|
| 34 |
lang = project.getLang(); |
|
| 35 |
wordsPerPage = project.getEditionDefinition("default").getWordsPerPage()
|
|
| 36 |
page_element = project.getEditionDefinition("default").getPageElement()
|
|
| 37 |
wordTag = project.getTokenizerWordElement() |
|
| 38 | 38 |
|
| 39 | 39 |
cssDirectory = new File(module.getSourceDirectory(), "css") |
| 40 | 40 |
jsDirectory = new File(module.getSourceDirectory(), "js") |
| ... | ... | |
| 59 | 59 |
|
| 60 | 60 |
public boolean doDefaultEditionStep() {
|
| 61 | 61 |
|
| 62 |
boolean build_edition = module.getParameters().getDoEdition("default")
|
|
| 62 |
boolean build_edition = project.getEditionDefinition("default").getBuildEdition()
|
|
| 63 | 63 |
if (!build_edition) {
|
| 64 | 64 |
return true; |
| 65 | 65 |
} |
| ... | ... | |
| 94 | 94 |
List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang); |
| 95 | 95 |
List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang); |
| 96 | 96 |
|
| 97 |
Element texts = params.getTextsElement(corpusElem); |
|
| 98 |
Element text = params.getTextElement(texts, textname); |
|
| 99 |
if (text == null) { // just in case
|
|
| 100 |
text = params.addText(corpusElem, textname, txmFile) |
|
| 97 |
Text t = project.getText(textname); |
|
| 98 |
if (t == null) {
|
|
| 99 |
t = new Text(project); |
|
| 101 | 100 |
} |
| 101 |
t.setName(textname); |
|
| 102 |
t.setSourceFile(txmFile) |
|
| 103 |
t.setTXMFile(txmFile) |
|
| 104 |
|
|
| 102 | 105 |
def ed = new XTZDefaultPagerStep(this, txmFile, textname, NoSpaceBefore, NoSpaceAfter, css); |
| 103 | 106 |
if (!ed.process()) {
|
| 104 | 107 |
println "Fail to build 'default' edition for text: $txmFile" |
| 105 | 108 |
continue; |
| 106 | 109 |
} |
| 107 |
Element edition = params.getEditionElement(text, "default");
|
|
| 110 |
Edition edition = t.getEdition("default")
|
|
| 108 | 111 |
if (edition == null) {
|
| 109 |
edition = params.addEdition(text, "default", outputDirectory.getAbsolutePath(), "html"); |
|
| 110 |
} else { // remove existing pages if any
|
|
| 111 |
def children = edition.getChildNodes(); |
|
| 112 |
while (children.getLength() > 0 ) {
|
|
| 113 |
edition.removeChild(children.item(0)) |
|
| 114 |
} |
|
| 112 |
edition = new Edition(t); |
|
| 115 | 113 |
} |
| 114 |
edition.setName("default");
|
|
| 115 |
edition.setIndex(outputDirectory.getAbsolutePath()); |
|
| 116 | 116 |
|
| 117 | 117 |
for (i = 0 ; i < ed.getPageFiles().size();) {
|
| 118 | 118 |
File f = ed.getPageFiles().get(i); |
| 119 | 119 |
String wordid = ed.getIdx().get(i); |
| 120 |
params.addPage(edition, ""+(++i), wordid);
|
|
| 120 |
edition.addPage(""+(++i), wordid);
|
|
| 121 | 121 |
} |
| 122 | 122 |
} catch(Exception e) {
|
| 123 | 123 |
println "Error: could not create $txmFile 'default' edition: "+e |
| ... | ... | |
| 149 | 149 |
|
| 150 | 150 |
public boolean doFacsEditionStep() {
|
| 151 | 151 |
|
| 152 |
boolean mustBuildFacsEdition = module.getParameters().getDoFacsEdition();
|
|
| 152 |
boolean mustBuildFacsEdition = project.getEditionDefinition("facs").getBuildEdition()
|
|
| 153 | 153 |
if (!mustBuildFacsEdition) return true; |
| 154 | 154 |
|
| 155 |
String imageDirectoryPath = module.getParameters().getFacsEditionImageDirectory().trim();
|
|
| 155 |
String imageDirectoryPath = project.getEditionDefinition("facs").getImagesDirectory().trim();
|
|
| 156 | 156 |
File imageDirectory = new File(imageDirectoryPath); |
| 157 | 157 |
if (!imageDirectoryPath.startsWith("http") && imageDirectoryPath.length()== 0 && !imageDirectory.exists() && !imageDirectory.isDirectory()) {
|
| 158 | 158 |
imageDirectory = null; |
| ... | ... | |
| 164 | 164 |
File newEditionDirectory = new File(htmlDirectory, "facs"); |
| 165 | 165 |
newEditionDirectory.mkdir(); |
| 166 | 166 |
|
| 167 |
// declare the "facs" edition |
|
| 168 |
Element editionDefinitionElement = params.getEditionDefinitionElement(corpusElem, "facs"); |
|
| 169 |
if (editionDefinitionElement == null) {
|
|
| 170 |
editionDefinitionElement = params.addEditionDefinition(corpusElem, "facs", "groovy", "XTZPager.groovy") |
|
| 171 |
} |
|
| 172 |
Element textsElement = params.getTextsElement(corpusElem) |
|
| 173 |
|
|
| 174 | 167 |
ConsoleProgressBar cpb = new ConsoleProgressBar(files.size()) |
| 175 | 168 |
for (File txmFile : files) {
|
| 176 | 169 |
cpb.tick() |
| ... | ... | |
| 184 | 177 |
List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang); |
| 185 | 178 |
List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang); |
| 186 | 179 |
|
| 187 |
// the text should already exists |
|
| 188 |
Element text = params.getTextElement(textsElement, txtname) |
|
| 189 |
if (text == null) { // just in case
|
|
| 190 |
text = params.addText(corpusElem, txtname, txmFile) |
|
| 180 |
Text t = project.getText(txtname); |
|
| 181 |
if (t == null) {
|
|
| 182 |
t = new Text(project); |
|
| 191 | 183 |
} |
| 192 |
Element edition = params.getEditionElement(text, "facs"); |
|
| 184 |
t.setName(txtname); |
|
| 185 |
t.setSourceFile(txmFile) |
|
| 186 |
t.setTXMFile(txmFile) |
|
| 187 |
|
|
| 188 |
Edition edition = t.getEdition("facs")
|
|
| 193 | 189 |
if (edition == null) {
|
| 194 |
edition = params.addEdition(text, "facs", newEditionDirectory.getAbsolutePath(), "html"); |
|
| 195 |
} else {
|
|
| 196 |
def children = edition.getChildNodes(); |
|
| 197 |
while (children.getLength() > 0 ) {
|
|
| 198 |
edition.removeChild(children.item(0)) |
|
| 199 |
} |
|
| 190 |
edition = new Edition(t); |
|
| 200 | 191 |
} |
| 192 |
edition.setName("facs");
|
|
| 193 |
edition.setIndex(outputDirectory.getAbsolutePath()); |
|
| 201 | 194 |
|
| 202 | 195 |
try {
|
| 203 | 196 |
def ed = new XTZFacsPagerStep(txmFile, newEditionDirectory, imageDirectory, txtname, corpusname, "pb", "facs", wordTag, debug); |
| ... | ... | |
| 213 | 206 |
String wordid = pages[i][1] |
| 214 | 207 |
//TODO replace '""+(++i)' with something that fetch/findout the page 'name' |
| 215 | 208 |
// TODO or move the Edition and Page corpus declaration in the XTZDefaultPagerStep |
| 216 |
params.addPage(edition, ""+(++i), wordid);
|
|
| 209 |
edition.addPage(""+(++i), wordid);
|
|
| 217 | 210 |
//println "add facs page: $f $wordid" |
| 218 | 211 |
} |
| 219 | 212 |
} catch (Exception e) {
|
| ... | ... | |
| 252 | 245 |
FileCopy.copyFiles(imagesDirectory, imageshtmlDirectory) |
| 253 | 246 |
} |
| 254 | 247 |
|
| 255 |
Element editionsElement = params.getEditionsElement(corpusElem); |
|
| 256 |
editionsElement.setAttribute("default","default,facs");
|
|
| 248 |
project.setDefaultEditionName("default,facs");
|
|
| 257 | 249 |
|
| 258 | 250 |
println "" |
| 259 | 251 |
return true; |
| ... | ... | |
| 269 | 261 |
if (xslDirectory.exists()) {
|
| 270 | 262 |
|
| 271 | 263 |
// prepare XSL parameters |
| 272 |
def xslParams = module.getParameters().getXsltParams(corpusElem);
|
|
| 273 |
String s = module.getParameters().getWordsPerPage("default");
|
|
| 264 |
def xslParams = module.getProject().getXsltParameters();
|
|
| 265 |
String s = module.getProject().getEditionDefinition("default").getWordsPerPage()
|
|
| 274 | 266 |
if (s != null && s.length() > 0) |
| 275 | 267 |
|
| 276 | 268 |
// shared XSL parameters |
| 277 | 269 |
xslParams["number-words-per-page"] = Integer.parseInt(s); |
| 278 |
xslParams["pagination-element"] = module.getParameters().getPageElement("default")
|
|
| 279 |
xslParams["import-xml-path"] = module.getParameters().paramFile.toURI().toString()
|
|
| 270 |
xslParams["pagination-element"] = module.getProject().getEditionDefinition("default").getPageElement()
|
|
| 271 |
xslParams["import-xml-path"] = module.getProject().getProjectDirectory()
|
|
| 280 | 272 |
//println "XSL PARAMS: "+xslParams |
| 281 | 273 |
|
| 282 | 274 |
def xslFiles = xslDirectory.listFiles() |
| ... | ... | |
| 360 | 352 |
ConsoleProgressBar cpb = new ConsoleProgressBar(editionsCreated.keySet().size()) |
| 361 | 353 |
for (String editionName : editionsCreated.keySet()) {
|
| 362 | 354 |
cpb.tick() |
| 363 |
//ensure edition definition is declared |
|
| 364 |
def editionsElement = params.getEditionsElement(corpusElem) |
|
| 365 |
def e = params.getEditionDefinitionElement(editionsElement, editionName); |
|
| 366 |
if (e == null) {
|
|
| 367 |
params.addEditionDefinition(corpusElem, editionName, "xsl", editionsCreated[editionName].toString()); |
|
| 368 |
} |
|
| 369 | 355 |
|
| 370 | 356 |
File newEditionDirectory = new File(htmlDirectory, editionName); |
| 371 | 357 |
File xslFile = editionsCreated[editionName] |
| ... | ... | |
| 375 | 361 |
int idx4 = textName.indexOf(".")
|
| 376 | 362 |
if (idx4 > 0) textName = textName.substring(0, idx4); |
| 377 | 363 |
|
| 378 |
getFirstWordIDs(textName, editionName, newEditionDirectory, xslFile); |
|
| 364 |
getFirstWordIDs(textName, editionName, newEditionDirectory, xslFile, txmFile);
|
|
| 379 | 365 |
} |
| 380 | 366 |
} |
| 381 | 367 |
println "" |
| ... | ... | |
| 383 | 369 |
return true; |
| 384 | 370 |
} |
| 385 | 371 |
|
| 386 |
private void getFirstWordIDs(String textName, String editionName, File newEditionDirectory, File xslFile) {
|
|
| 372 |
private void getFirstWordIDs(String textName, String editionName, File newEditionDirectory, File xslFile, File txmFile) {
|
|
| 387 | 373 |
// println "call getFirstWordIDs textName=$textName editionName=$editionName dir=$newEditionDirectory xsl=$xslFile" |
| 388 |
Element textsElement = params.getTextsElement(corpusElem) |
|
| 389 |
Element textElement = params.getTextElement(textsElement, textName) |
|
| 390 |
if (textElement == null) { // just in case
|
|
| 391 |
textElement = params.addText(corpusElem, textName, new File(inputDirectory, textName+".xml")) |
|
| 374 |
Text t = project.getText(textName); |
|
| 375 |
if (t == null) {
|
|
| 376 |
t = new Text(project); |
|
| 392 | 377 |
} |
| 378 |
t.setName(textName); |
|
| 379 |
t.setSourceFile(txmFile) |
|
| 380 |
t.setTXMFile(txmFile) |
|
| 393 | 381 |
|
| 394 |
Element editionElement = params.getEditionElement(textElement, editionName); |
|
| 395 |
if (editionElement == null) { // the edition does not exist, declare it
|
|
| 396 |
editionElement = params.addEdition(textElement, editionName, newEditionDirectory.getAbsolutePath(), "html"); |
|
| 397 |
} else { // the edition already exists, remove pages from the existing edition
|
|
| 398 |
def children = editionElement.getChildNodes(); |
|
| 399 |
while (children.getLength() > 0 ) {
|
|
| 400 |
editionElement.removeChild(children.item(0)) |
|
| 401 |
} |
|
| 382 |
Edition edition = t.getEdition(editionName) |
|
| 383 |
if (edition == null) {
|
|
| 384 |
edition = new Edition(t); |
|
| 402 | 385 |
} |
| 403 |
editionElement.setAttribute("mode", "xsl");
|
|
| 404 |
editionElement.setAttribute("script", xslFile.getName());
|
|
| 386 |
edition.setName(editionName);
|
|
| 387 |
edition.setIndex(outputDirectory.getAbsolutePath());
|
|
| 405 | 388 |
|
| 406 | 389 |
LinkedHashMap<File, String> words = new LinkedHashMap<File, String>() |
| 407 | 390 |
def files = [] |
| ... | ... | |
| 420 | 403 |
if (pagename.startsWith(textName+"_")) { // this is a page
|
| 421 | 404 |
String firstWordID = getMetaContent(f); |
| 422 | 405 |
pagename = pagename.substring((textName+"_").length(), pagename.indexOf(".html")) // !!!!
|
| 423 |
params.addPage(editionElement, pagename, firstWordID)
|
|
| 406 |
edition.addPage(pagename, firstWordID)
|
|
| 424 | 407 |
} |
| 425 | 408 |
} |
| 426 | 409 |
} |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZDefaultPagerStep.groovy (revision 1137) | ||
|---|---|---|
| 124 | 124 |
factory = XMLInputFactory.newInstance(); |
| 125 | 125 |
parser = factory.createXMLStreamReader(inputData); |
| 126 | 126 |
|
| 127 |
String notesListString = pager.getImportModule().getParameters().getNoteElement().getTextContent()
|
|
| 127 |
String notesListString = pager.getImportModule().getProject().getTextualPlan("Note")
|
|
| 128 | 128 |
if (notesListString != null) for (def s : notesListString.split(",")) noteElements << s;
|
| 129 | 129 |
|
| 130 |
String elems = pager.getImportModule().getParameters().getOutSideTextTagsAndKeepContentElement().getTextContent()
|
|
| 130 |
String elems = pager.getImportModule().getProject().getTextualPlan("OutSideTextTagsAndKeepContent")
|
|
| 131 | 131 |
if (elems != null) for (def s : elems.split(",")) outOfTextElements << s;
|
| 132 | 132 |
|
| 133 | 133 |
//process(); |
| ... | ... | |
| 228 | 228 |
return true; |
| 229 | 229 |
} catch (Exception e) {
|
| 230 | 230 |
System.out.println(e.getLocalizedMessage()); |
| 231 |
e.printStackTrace() |
|
| 231 | 232 |
return false; |
| 232 | 233 |
} |
| 233 | 234 |
} |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImporter.groovy (revision 1137) | ||
|---|---|---|
| 98 | 98 |
|
| 99 | 99 |
lang = project.getLang(); |
| 100 | 100 |
|
| 101 |
wordTag = project.getTokenizerParameter(name, defaultvalue)
|
|
| 102 |
this.skipDoTokenizeStep = module.getParameters().getSkipTokenization()
|
|
| 101 |
wordTag = project.getTokenizerWordElement()
|
|
| 102 |
this.skipDoTokenizeStep = !project.getDoTokenizerStep()
|
|
| 103 | 103 |
|
| 104 | 104 |
//prepare metadata if any |
| 105 | 105 |
File allMetadataFile = Metadatas.findMetadataFile(inputDirectory); |
| ... | ... | |
| 115 | 115 |
Toolbox.getPreference(TBXPreferences.METADATA_TXTSEPARATOR), 1) |
| 116 | 116 |
} |
| 117 | 117 |
|
| 118 |
String cleanDirectories = module.getParameters().getKeyValueParameters().get(ImportKeys.CLEAN);
|
|
| 118 |
String cleanDirectories = project.getCleanAfterBuild();
|
|
| 119 | 119 |
|
| 120 | 120 |
if (!doFixSurrogates()) return; |
| 121 | 121 |
if (!doSplitMergeXSLStep()) return; |
| ... | ... | |
| 201 | 201 |
|
| 202 | 202 |
public boolean doEncodeMileStonesStep() {
|
| 203 | 203 |
filesToProcess = new File(module.getBinaryDirectory(), "tokenized").listFiles() |
| 204 |
def milestonesString = module.getParameters().getMilestonesElement().getTextContent().trim()
|
|
| 204 |
def milestonesString = module.getProject().getTextualPlan("MileStones")
|
|
| 205 | 205 |
if (milestonesString.length() == 0) return true; |
| 206 | 206 |
|
| 207 | 207 |
def milestones = milestonesString.split(",")
|
| ... | ... | |
| 314 | 314 |
String outSideTextTagsAndKeepContentRegex = ""; |
| 315 | 315 |
String noteRegex = ""; |
| 316 | 316 |
// get the element names to ignore |
| 317 |
Element textualPlanEelement = module.getParameters().getTextualPlans(); |
|
| 318 | 317 |
|
| 319 |
if (textualPlanEelement != null) {
|
|
| 320 |
Element e1 = module.getParameters().getOutSideTextTagsElement() |
|
| 321 |
def split = e1.getTextContent().split(",")
|
|
| 318 |
String e1 = module.getProject().getTextualPlan("OutSideTextTags")
|
|
| 319 |
def split = e1.split(",")
|
|
| 322 | 320 |
for (String s : split) {
|
| 323 | 321 |
outSideTextTagsRegex += "|"+s.trim() |
| 324 | 322 |
} |
| ... | ... | |
| 326 | 324 |
outSideTextTagsRegex = outSideTextTagsRegex.substring(1) // remove the first "|" |
| 327 | 325 |
} |
| 328 | 326 |
|
| 329 |
Element e2 = module.getParameters().getOutSideTextTagsAndKeepContentElement()
|
|
| 330 |
def split2 = e2.getTextContent().split(",")
|
|
| 327 |
String e2 = module.getProject().getTextualPlan("OutSideTextTagsAndKeepContent")
|
|
| 328 |
def split2 = e2.split(",")
|
|
| 331 | 329 |
for (String s : split2) {
|
| 332 | 330 |
outSideTextTagsAndKeepContentRegex += "|"+s.trim() |
| 333 | 331 |
} |
| ... | ... | |
| 335 | 333 |
outSideTextTagsAndKeepContentRegex = outSideTextTagsAndKeepContentRegex.substring(1) // remove the first "|" |
| 336 | 334 |
} |
| 337 | 335 |
|
| 338 |
Element e3 = module.getParameters().getNoteElement()
|
|
| 339 |
def split3 = e3.getTextContent().split(",")
|
|
| 336 |
String e3 = module.getProject().getTextualPlan("Note")
|
|
| 337 |
def split3 = e3.split(",")
|
|
| 340 | 338 |
for (String s : split3) {
|
| 341 | 339 |
noteRegex += "|"+s.trim() |
| 342 | 340 |
} |
| 343 | 341 |
if (noteRegex.trim().length() > 0) {
|
| 344 | 342 |
noteRegex = noteRegex.substring(1) // remove the first "|" |
| 345 | 343 |
} |
| 346 |
} |
|
| 347 | 344 |
|
| 348 | 345 |
//if (wordTag != "w") {
|
| 349 |
if (skipDoTokenizeStep ) {
|
|
| 346 |
if (skipDoTokenizeStep) {
|
|
| 350 | 347 |
println "No tokenization do to." |
| 351 | 348 |
// ConsoleProgressBar cpb = new ConsoleProgressBar(filesToProcess.size()) |
| 352 | 349 |
for (File f : filesToProcess) {
|
| ... | ... | |
| 377 | 374 |
tokenizer.setNote(noteRegex) |
| 378 | 375 |
} |
| 379 | 376 |
|
| 380 |
// tokenize ! \o/
|
|
| 377 |
// tokenize ! |
|
| 381 | 378 |
if (!tokenizer.process()) {
|
| 382 | 379 |
println("Failed to process "+f)
|
| 383 | 380 |
outfile.delete() |
| ... | ... | |
| 454 | 451 |
def resps = new HashMap<String,String[]>(); |
| 455 | 452 |
//lance le traitement |
| 456 | 453 |
def builder = new Xml2Ana(file); |
| 457 |
builder.setWordTag(module.getParameters().getWordElement().getTextContent())
|
|
| 454 |
builder.setWordTag(module.getProject().getTokenizerWordElement())
|
|
| 458 | 455 |
builder.setConvertAllAtrtibutes true; |
| 459 | 456 |
builder.setCorrespondances(correspRef, correspType); |
| 460 | 457 |
builder.setHeaderInfos(respId,resps, applications, taxonomiesUtilisees, itemsURI) |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZCompilerStep.groovy (revision 1137) | ||
|---|---|---|
| 8 | 8 |
import org.txm.utils.io.* |
| 9 | 9 |
import org.txm.importer.xtz.* |
| 10 | 10 |
|
| 11 |
/** |
|
| 12 |
* Compiles the CQP file of ONE text |
|
| 13 |
* |
|
| 14 |
* @author mdecorde |
|
| 15 |
* |
|
| 16 |
*/ |
|
| 11 | 17 |
public class XTZCompilerStep extends Step {
|
| 12 | 18 |
|
| 13 | 19 |
static String FORM = "form"; |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/xtzLoader.groovy (revision 1137) | ||
|---|---|---|
| 41 | 41 |
String userDir = System.getProperty("user.home");
|
| 42 | 42 |
|
| 43 | 43 |
def MONITOR; |
| 44 |
boolean debug = org.txm.utils.logger.Log.isPrintingErrors(); |
|
| 45 |
BaseParameters params; |
|
| 46 |
try {params = paramsBinding;MONITOR=monitor} catch (Exception)
|
|
| 47 |
{ println "DEV MODE";//exception means we debug
|
|
| 48 |
debug = true |
|
| 49 |
params = new BaseParameters(new File(userDir, "xml/srcmfmadridxmltxm/import.xml")) |
|
| 50 |
params.load() |
|
| 51 |
if (!org.txm.Toolbox.isInitialized()) {
|
|
| 44 |
Project project; |
|
| 52 | 45 |
|
| 53 |
TokenizerClasses.loadFromNode(params.getTokenizerElement(params.getCorpusElement())); |
|
| 54 |
Toolbox.setParam(Toolbox.INSTALL_DIR,new File("/usr/lib/TXM"));
|
|
| 55 |
//Toolbox.setParam(Toolbox.INSTALL_DIR,new File("C:\\Program Files\\TXM"));//For Windows
|
|
| 56 |
Toolbox.setParam(Toolbox.METADATA_ENCODING, "UTF-8"); |
|
| 57 |
Toolbox.setParam(Toolbox.METADATA_COLSEPARATOR, ","); |
|
| 58 |
Toolbox.setParam(Toolbox.METADATA_TXTSEPARATOR, "\""); |
|
| 59 |
//Toolbox.setParam(Toolbox.TREETAGGER_MODELS_PATH,new File("C:\\Program Files\\treetagger\\models"));//for Windows
|
|
| 60 |
Toolbox.setParam(Toolbox.USER_TXM_HOME, new File(System.getProperty("user.home"), "TXM"));
|
|
| 61 |
} |
|
| 62 |
} |
|
| 46 |
try {project=projectBinding;MONITOR=monitor} catch (Exception)
|
|
| 47 |
{ }
|
|
| 48 |
if (project == null) { println "no project set. Aborting"; return; }
|
|
| 63 | 49 |
|
| 64 |
if (params == null) { println "no parameters. Aborting"; return; }
|
|
| 65 |
|
|
| 66 |
//params.getKeyValueParameters().put(ImportKeys.CLEAN, "false") |
|
| 67 |
//params.getKeyValueParameters().put(ImportKeys.MULTITHREAD, "false") |
|
| 68 |
//params.getKeyValueParameters().put(ImportKeys.DEBUG, "false") |
|
| 69 |
//params.getKeyValueParameters().put(ImportKeys.UPDATECORPUS, "false") |
|
| 70 |
|
|
| 71 |
XTZImport i = new XTZImport(params); |
|
| 50 |
XTZImport i = new XTZImport(project); |
|
| 72 | 51 |
/* |
| 73 | 52 |
* To customize the XTZ import, replace the importer, compiler, annotater or pager objects before calling process() |
| 74 | 53 |
i.importer = new XTZImporter(i) |
| ... | ... | |
| 77 | 56 |
i.pager = new XTZPager(i) |
| 78 | 57 |
*/ |
| 79 | 58 |
i.process(); |
| 80 |
readyToLoad = i.isSuccessful |
|
| 59 |
readyToLoad = i.isSuccessful && project.save() |
|
| tmp/org.txm.core/src/java/org/txm/core/preferences/TBXPreferences.java (revision 1137) | ||
|---|---|---|
| 109 | 109 |
public static final String REF_PROPERTY = "ref_property"; |
| 110 | 110 |
public static final String SORT_PROPERTY = "sort_property"; |
| 111 | 111 |
public static final String VIEW_PROPERTY = "view_property"; |
| 112 |
|
|
| 113 |
public static final String CLEAN = "clean.directories"; |
|
| 114 |
public static final String TTMODEL = "annotate.model"; |
|
| 115 |
public static final String TTANNOTATE = "annotate.run"; |
|
| 116 |
|
|
| 117 |
public static final String MULTITHREAD = "multithread"; |
|
| 118 |
public static final String DEBUG = "debug"; |
|
| 119 |
public static final String UPDATECORPUS = "corpus.update"; |
|
| 120 |
|
|
| 121 |
public static final String NORMALISEANAVALUES = "normalize.ana.values"; |
|
| 122 |
public static final String NORMALISEATTRIBUTEVALUES = "normalize.attribute.values"; |
|
| 123 |
|
|
| 112 | 124 |
/** |
| 113 | 125 |
* Gets the instance. |
| 114 | 126 |
* @return the instance |
| tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1137) | ||
|---|---|---|
| 1015 | 1015 |
* |
| 1016 | 1016 |
* @return |
| 1017 | 1017 |
*/ |
| 1018 |
synchronized public final boolean delete() {
|
|
| 1018 |
public final boolean delete() {
|
|
| 1019 | 1019 |
|
| 1020 | 1020 |
try {
|
| 1021 | 1021 |
// FIXME: debug |
| ... | ... | |
| 1053 | 1053 |
/** |
| 1054 | 1054 |
* Deletes all non persistent results. |
| 1055 | 1055 |
*/ |
| 1056 |
synchronized public static void deleteAllNonPersistentResults() {
|
|
| 1056 |
public static void deleteAllNonPersistentResults() {
|
|
| 1057 | 1057 |
ArrayList<TXMResult> results = Toolbox.workspace.getDeepChildren(); |
| 1058 | 1058 |
for (int i = 0; i < results.size(); i++) {
|
| 1059 | 1059 |
TXMResult r = results.get(i); |
| ... | ... | |
| 1073 | 1073 |
* @param index |
| 1074 | 1074 |
* @return the child specified by its index if exists otherwise null |
| 1075 | 1075 |
*/ |
| 1076 |
synchronized public TXMResult getChild(int index) {
|
|
| 1076 |
public TXMResult getChild(int index) {
|
|
| 1077 | 1077 |
try {
|
| 1078 | 1078 |
return this.children.get(index); |
| 1079 | 1079 |
} |
| ... | ... | |
| 1089 | 1089 |
* @param child |
| 1090 | 1090 |
* @return true if the child has been added |
| 1091 | 1091 |
*/ |
| 1092 |
synchronized public boolean addChild(TXMResult child) {
|
|
| 1092 |
public boolean addChild(TXMResult child) {
|
|
| 1093 | 1093 |
try {
|
| 1094 | 1094 |
// do nothing if the parent is already this result |
| 1095 | 1095 |
// if(child.getParent() == this) {
|
| ... | ... | |
| 1120 | 1120 |
* @param child |
| 1121 | 1121 |
* @return |
| 1122 | 1122 |
*/ |
| 1123 |
synchronized public boolean addChild(int index, TXMResult child) {
|
|
| 1123 |
public boolean addChild(int index, TXMResult child) {
|
|
| 1124 | 1124 |
try {
|
| 1125 | 1125 |
if (!this.children.contains(child)) {
|
| 1126 | 1126 |
child.setParent(this); |
| ... | ... | |
| 1141 | 1141 |
* @param child |
| 1142 | 1142 |
* @return <code>true if the child has been removed, otherwise <code>false</code> |
| 1143 | 1143 |
*/ |
| 1144 |
synchronized public boolean removeResult(TXMResult child) {
|
|
| 1144 |
public boolean removeResult(TXMResult child) {
|
|
| 1145 | 1145 |
try {
|
| 1146 | 1146 |
child.setParent(null); |
| 1147 | 1147 |
return this.children.remove(child); |
| ... | ... | |
| 1156 | 1156 |
* @param index |
| 1157 | 1157 |
* @return <code>true if the child has been removed, otherwise <code>false</code> |
| 1158 | 1158 |
*/ |
| 1159 |
synchronized public boolean removeChild(int index) {
|
|
| 1159 |
public boolean removeChild(int index) {
|
|
| 1160 | 1160 |
try {
|
| 1161 | 1161 |
return this.removeResult(this.children.get(index)); |
| 1162 | 1162 |
} catch (Exception e) {
|
| ... | ... | |
| 1170 | 1170 |
* |
| 1171 | 1171 |
* @return |
| 1172 | 1172 |
*/ |
| 1173 |
synchronized public boolean removeFromParent() {
|
|
| 1173 |
public boolean removeFromParent() {
|
|
| 1174 | 1174 |
try {
|
| 1175 | 1175 |
return this.parent.removeResult(this); |
| 1176 | 1176 |
} catch (Exception e) {
|
| ... | ... | |
| 1185 | 1185 |
* |
| 1186 | 1186 |
* @return |
| 1187 | 1187 |
*/ |
| 1188 |
synchronized public ArrayList<TXMResult> getChildren() {
|
|
| 1188 |
public ArrayList<TXMResult> getChildren() {
|
|
| 1189 | 1189 |
return this.children; |
| 1190 | 1190 |
} |
| 1191 | 1191 |
|
| ... | ... | |
| 1194 | 1194 |
* |
| 1195 | 1195 |
* @return |
| 1196 | 1196 |
*/ |
| 1197 |
synchronized public ArrayList<TXMResult> getChildren(boolean onlyVisible) {
|
|
| 1197 |
public ArrayList<TXMResult> getChildren(boolean onlyVisible) {
|
|
| 1198 | 1198 |
return this.getChildren(null, onlyVisible); |
| 1199 | 1199 |
} |
| 1200 | 1200 |
|
| ... | ... | |
| 1204 | 1204 |
* @param type |
| 1205 | 1205 |
* @return |
| 1206 | 1206 |
*/ |
| 1207 |
synchronized public ArrayList<? extends TXMResult> getChildren(Class type) {
|
|
| 1207 |
public ArrayList<? extends TXMResult> getChildren(Class type) {
|
|
| 1208 | 1208 |
return TXMResult.getNodes(this.children, type, false); |
| 1209 | 1209 |
} |
| 1210 | 1210 |
|
| ... | ... | |
| 1214 | 1214 |
* @param type |
| 1215 | 1215 |
* @return |
| 1216 | 1216 |
*/ |
| 1217 |
synchronized public ArrayList<TXMResult> getChildren(Class type, boolean onlyVisible) {
|
|
| 1217 |
public ArrayList<TXMResult> getChildren(Class type, boolean onlyVisible) {
|
|
| 1218 | 1218 |
return TXMResult.getNodes(this.children, type, onlyVisible); |
| 1219 | 1219 |
} |
| 1220 | 1220 |
|
| ... | ... | |
| 1223 | 1223 |
* @param type |
| 1224 | 1224 |
* @return the first child if exists otherwise null |
| 1225 | 1225 |
*/ |
| 1226 |
synchronized public TXMResult getFirstChild(Class type) {
|
|
| 1226 |
public TXMResult getFirstChild(Class type) {
|
|
| 1227 | 1227 |
ArrayList<TXMResult> children = this.getChildren(type, false); |
| 1228 | 1228 |
try {
|
| 1229 | 1229 |
return children.get(0); |
| ... | ... | |
| 1239 | 1239 |
* @param classSimpleName |
| 1240 | 1240 |
* @return |
| 1241 | 1241 |
*/ |
| 1242 |
synchronized public TXMResult getFirstChild() {
|
|
| 1242 |
public TXMResult getFirstChild() {
|
|
| 1243 | 1243 |
try {
|
| 1244 | 1244 |
return this.children.get(0); |
| 1245 | 1245 |
} |
| ... | ... | |
| 1254 | 1254 |
* |
| 1255 | 1255 |
* @return |
| 1256 | 1256 |
*/ |
| 1257 |
synchronized protected ArrayList<TXMResult> getDeepChildren(TXMResult parent) {
|
|
| 1257 |
protected ArrayList<TXMResult> getDeepChildren(TXMResult parent) {
|
|
| 1258 | 1258 |
|
| 1259 | 1259 |
ArrayList<TXMResult> results = new ArrayList<TXMResult>(); |
| 1260 | 1260 |
for (int i = 0; i < parent.getChildren().size(); i++) {
|
| ... | ... | |
| 1269 | 1269 |
* |
| 1270 | 1270 |
* @return |
| 1271 | 1271 |
*/ |
| 1272 |
synchronized public ArrayList<TXMResult> getDeepChildren() {
|
|
| 1272 |
public ArrayList<TXMResult> getDeepChildren() {
|
|
| 1273 | 1273 |
return this.getDeepChildren(this); |
| 1274 | 1274 |
} |
| 1275 | 1275 |
|
| ... | ... | |
| 1279 | 1279 |
* @param UUID |
| 1280 | 1280 |
* @return |
| 1281 | 1281 |
*/ |
| 1282 |
synchronized public static TXMResult getResult(TXMResult root, String UUID) {
|
|
| 1282 |
public static TXMResult getResult(TXMResult root, String UUID) {
|
|
| 1283 | 1283 |
TXMResult result = null; |
| 1284 | 1284 |
if(root.getUUID().equals(UUID)) {
|
| 1285 | 1285 |
result = root; |
| ... | ... | |
| 1301 | 1301 |
* @param UUID |
| 1302 | 1302 |
* @return |
| 1303 | 1303 |
*/ |
| 1304 |
synchronized public static TXMResult getResult(String UUID) {
|
|
| 1304 |
public static TXMResult getResult(String UUID) {
|
|
| 1305 | 1305 |
return getResult(Toolbox.workspace, UUID); |
| 1306 | 1306 |
} |
| 1307 | 1307 |
|
| ... | ... | |
| 1311 | 1311 |
* @param type |
| 1312 | 1312 |
* @return |
| 1313 | 1313 |
*/ |
| 1314 |
synchronized protected static ArrayList<TXMResult> getNodes(ArrayList<TXMResult> srcNodes, Class type, boolean onlyVisible) {
|
|
| 1314 |
protected static ArrayList<TXMResult> getNodes(ArrayList<TXMResult> srcNodes, Class type, boolean onlyVisible) {
|
|
| 1315 | 1315 |
ArrayList<TXMResult> nodes = new ArrayList<TXMResult>(); |
| 1316 | 1316 |
for (TXMResult child : srcNodes) {
|
| 1317 | 1317 |
try {
|
| ... | ... | |
| 1337 | 1337 |
* Gets the direct children count. |
| 1338 | 1338 |
* @return the direct children count |
| 1339 | 1339 |
*/ |
| 1340 |
synchronized public int getChildrenCount() {
|
|
| 1340 |
public int getChildrenCount() {
|
|
| 1341 | 1341 |
return this.children.size(); |
| 1342 | 1342 |
} |
| 1343 | 1343 |
|
| ... | ... | |
| 1346 | 1346 |
* Gets the root parent of the branch. |
| 1347 | 1347 |
* @return |
| 1348 | 1348 |
*/ |
| 1349 |
synchronized public TXMResult getRootParent() {
|
|
| 1349 |
public TXMResult getRootParent() {
|
|
| 1350 | 1350 |
TXMResult root; |
| 1351 | 1351 |
TXMResult parent = this; |
| 1352 | 1352 |
do {
|
| ... | ... | |
| 1363 | 1363 |
* @param type |
| 1364 | 1364 |
* @return |
| 1365 | 1365 |
*/ |
| 1366 |
synchronized public TXMResult getFirstParent(Class type) {
|
|
| 1366 |
public TXMResult getFirstParent(Class type) {
|
|
| 1367 | 1367 |
TXMResult node = null; |
| 1368 | 1368 |
TXMResult parent = this.parent; |
| 1369 | 1369 |
do {
|
| ... | ... | |
| 1387 | 1387 |
// * @param type |
| 1388 | 1388 |
// * @return null if the TXMResult is not attached to a BinaryCorpus |
| 1389 | 1389 |
// */ |
| 1390 |
// synchronized public Project getCorpusProject() {
|
|
| 1390 |
// public Project getCorpusProject() {
|
|
| 1391 | 1391 |
// Object o = getFirstParent(Project.class); |
| 1392 | 1392 |
// if (o != null) {
|
| 1393 | 1393 |
// return (Project)o; |
| ... | ... | |
| 1402 | 1402 |
// * @param type |
| 1403 | 1403 |
// * @return null if the TXMResult is not attached to a BinaryCorpus |
| 1404 | 1404 |
// */ |
| 1405 |
// synchronized public CorpusBuild getCorpusBuild() {
|
|
| 1405 |
// public CorpusBuild getCorpusBuild() {
|
|
| 1406 | 1406 |
// Object o = getFirstParent(CorpusBuild.class); |
| 1407 | 1407 |
// if (o != null) {
|
| 1408 | 1408 |
// return (CorpusBuild)o; |
| ... | ... | |
| 1414 | 1414 |
/** |
| 1415 | 1415 |
* Gets the sibling nodes of this node result. |
| 1416 | 1416 |
*/ |
| 1417 |
synchronized public ArrayList<TXMResult> getSiblings() {
|
|
| 1417 |
public ArrayList<TXMResult> getSiblings() {
|
|
| 1418 | 1418 |
ArrayList<TXMResult> sibling = new ArrayList<TXMResult>(); |
| 1419 | 1419 |
if (this.parent != null) {
|
| 1420 | 1420 |
sibling.addAll(this.parent.getChildren()); |
| ... | ... | |
| 1426 | 1426 |
/** |
| 1427 | 1427 |
* Gets the sibling nodes of this node result, specified by their class. |
| 1428 | 1428 |
*/ |
| 1429 |
synchronized public ArrayList<TXMResult> getSiblings(Class type) {
|
|
| 1429 |
public ArrayList<TXMResult> getSiblings(Class type) {
|
|
| 1430 | 1430 |
ArrayList<TXMResult> sibling = new ArrayList<TXMResult>(); |
| 1431 | 1431 |
if (this.parent != null) {
|
| 1432 | 1432 |
sibling.addAll(TXMResult.getNodes(this.parent.getChildren(), type, true)); |
| ... | ... | |
| 1551 | 1551 |
* |
| 1552 | 1552 |
* @return the full path |
| 1553 | 1553 |
*/ |
| 1554 |
synchronized public String getFullPathSimpleName() {
|
|
| 1554 |
public String getFullPathSimpleName() {
|
|
| 1555 | 1555 |
|
| 1556 | 1556 |
// fill the branch |
| 1557 | 1557 |
ArrayList<TXMResult> branch = new ArrayList<TXMResult>(); |
| ... | ... | |
| 1709 | 1709 |
* @throws CqiClientExceptio |
| 1710 | 1710 |
* @throws IOException |
| 1711 | 1711 |
*/ |
| 1712 |
synchronized protected boolean compute(IProgressMonitor monitor, boolean deepComputing, boolean updateLastParameters) throws Exception {
|
|
| 1712 |
protected boolean compute(IProgressMonitor monitor, boolean deepComputing, boolean updateLastParameters) throws Exception {
|
|
| 1713 | 1713 |
|
| 1714 | 1714 |
// FIXME: see if this skipComputing tests is still useful? is it possible to directly return instead? |
| 1715 | 1715 |
// en fait voir ChartResult.compute() if(super.compute(monitor, true, false)), je pense que le prob vient du fait que si on retourne false dans TXMResult.compute() alors renderChart() ne sera pas appelé |
| ... | ... | |
| 1791 | 1791 |
// FIXME: may be better to add a member needFullRecomputing in TXMResult? |
| 1792 | 1792 |
// this.getChild(i).setDirty(); // force recomputing even if some parameters of the result itself have not changed |
| 1793 | 1793 |
//this.getChild(i).setHasBeenComputedOnce(false); // force recomputing even if some parameters of the result itself have not changed |
| 1794 |
if (child.hasBeenComputedOnce()) {
|
|
| 1794 |
//if (child.hasBeenComputedOnce()) {
|
|
| 1795 | 1795 |
child.compute(monitor, deepComputing, updateLastParameters); |
| 1796 |
} |
|
| 1796 |
//}
|
|
| 1797 | 1797 |
} |
| 1798 | 1798 |
} |
| 1799 | 1799 |
} |
| tmp/org.txm.core/src/java/org/txm/objects/Project.java (revision 1137) | ||
|---|---|---|
| 75 | 75 |
*/ |
| 76 | 76 |
public class Project extends TXMResult {
|
| 77 | 77 |
|
| 78 |
|
|
| 79 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 | 80 |
private ArrayList<String> pEditionNames = new ArrayList<String>(); |
| 81 | 81 |
private IProject rcpProject; |
| 82 |
|
|
| 82 |
|
|
| 83 |
@Parameter(key=TBXPreferences.CLEAN) |
|
| 83 | 84 |
private boolean pCleanAfterBuild; |
| 85 |
|
|
| 84 | 86 |
private ProjectScope preferenceScope; |
| 85 | 87 |
|
| 86 |
|
|
| 88 |
|
|
| 87 | 89 |
/** |
| 88 | 90 |
* Name. |
| 89 | 91 |
*/ |
| ... | ... | |
| 138 | 140 |
*/ |
| 139 | 141 |
@Parameter(key=TBXPreferences.AUTHOR) |
| 140 | 142 |
private String pAuthor; |
| 141 |
|
|
| 143 |
|
|
| 142 | 144 |
/** |
| 143 | 145 |
* Font. |
| 144 | 146 |
*/ |
| ... | ... | |
| 150 | 152 |
*/ |
| 151 | 153 |
@Parameter(key=TBXPreferences.DESCRIPTION) |
| 152 | 154 |
private String pDescription; |
| 153 |
|
|
| 155 |
|
|
| 154 | 156 |
/** |
| 155 | 157 |
* |
| 156 | 158 |
*/ |
| ... | ... | |
| 162 | 164 |
*/ |
| 163 | 165 |
@Parameter(key=TBXPreferences.UPDATE_DATE) |
| 164 | 166 |
private Date pLastUpdateDate; |
| 165 |
|
|
| 167 |
|
|
| 166 | 168 |
/** |
| 167 | 169 |
* Creation date. |
| 168 | 170 |
*/ |
| ... | ... | |
| 183 | 185 |
this.dirty = false; |
| 184 | 186 |
this.hasBeenComputedOnce = true; |
| 185 | 187 |
this.setVisible(false); |
| 186 |
|
|
| 188 |
|
|
| 187 | 189 |
initRCPStuffs(); |
| 188 | 190 |
} |
| 189 | 191 |
|
| ... | ... | |
| 195 | 197 |
public Project(String parametersNodePath) throws CoreException {
|
| 196 | 198 |
super(parametersNodePath); |
| 197 | 199 |
initRCPStuffs(); |
| 198 |
|
|
| 200 |
|
|
| 199 | 201 |
this.dirty = false; |
| 200 | 202 |
this.hasBeenComputedOnce = true; |
| 201 | 203 |
this.setVisible(false); |
| ... | ... | |
| 211 | 213 |
// } |
| 212 | 214 |
// |
| 213 | 215 |
// this.scope = new BasePreferenceScope(this); |
| 214 |
|
|
| 215 |
|
|
| 216 |
|
|
| 217 |
|
|
| 216 | 218 |
// reloading existing results |
| 217 | 219 |
this.loadResults(); |
| 218 |
|
|
| 220 |
|
|
| 219 | 221 |
} |
| 220 | 222 |
|
| 221 |
|
|
| 223 |
|
|
| 222 | 224 |
private void initRCPStuffs() throws CoreException {
|
| 223 | 225 |
IWorkspace rcpWorkspace = ResourcesPlugin.getWorkspace(); |
| 224 | 226 |
if (this.rcpProject == null) {
|
| ... | ... | |
| 246 | 248 |
rcpProject.create(monitor); |
| 247 | 249 |
rcpProject.open(monitor); |
| 248 | 250 |
rcpProject.getDescription().setNatureIds(new String[] {"org.txm.core.CorpusNature"});
|
| 249 |
|
|
| 251 |
|
|
| 250 | 252 |
IFolder srcFolder = rcpProject.getFolder("src");
|
| 251 | 253 |
IPath path = new Path(pSrcDirectory.getAbsolutePath()); |
| 252 | 254 |
if (!srcFolder.exists()) {
|
| ... | ... | |
| 260 | 262 |
protected void loadResults() {
|
| 261 | 263 |
// if (TBXPreferences.getInstance().getBoolean(TBXPreferences.AUTO_PERSISTENCE_ENABLED)) {
|
| 262 | 264 |
Log.finest("*** Project.loadResults(): reloading persitent results...");
|
| 263 |
|
|
| 265 |
|
|
| 264 | 266 |
IWorkspace rcpWorkspace = ResourcesPlugin.getWorkspace(); |
| 265 |
// IProject projects[] = rcpWorkspace.getRoot().getProjects(); |
|
| 266 |
|
|
| 267 |
// Log.info("Toolbox.initialize(): " + projects.length + " project(s) found in workspace.");
|
|
| 268 |
|
|
| 269 |
ArrayList<String> resultNodePaths = TXMPreferences.getAllResultsNodePaths(this.getParametersNodeRootPath()); |
|
| 270 |
|
|
| 271 |
Log.info("Project.loadResults(): loading " + resultNodePaths.size() + " result(s) from project " + this.getName() + "...");
|
|
| 267 |
// IProject projects[] = rcpWorkspace.getRoot().getProjects(); |
|
| 272 | 268 |
|
| 273 |
for (String parametersNodePath : resultNodePaths) {
|
|
| 269 |
// Log.info("Toolbox.initialize(): " + projects.length + " project(s) found in workspace.");
|
|
| 274 | 270 |
|
| 275 |
// skip non-TXMResult preference node |
|
| 276 |
// if (TXMPreferences.getString(TXMPreferences.BUNDLE_ID, nodeQualifier).isEmpty()) {
|
|
| 277 |
// continue; |
|
| 278 |
// } |
|
| 271 |
ArrayList<String> resultNodePaths = TXMPreferences.getAllResultsNodePaths(this.getParametersNodeRootPath()); |
|
| 279 | 272 |
|
| 280 |
try {
|
|
| 281 |
|
|
| 282 |
String className = TXMPreferences.preferencesRootNode.node(parametersNodePath).get("class", ""); //$NON-NLS-1$
|
|
| 273 |
Log.info("Project.loadResults(): loading " + resultNodePaths.size() + " result(s) from project " + this.getName() + "...");
|
|
| 283 | 274 |
|
| 284 |
// Skip Project object |
|
| 285 |
if(className.equals(Project.class.getName())) {
|
|
| 286 |
continue; |
|
| 287 |
} |
|
| 275 |
for (String parametersNodePath : resultNodePaths) {
|
|
| 288 | 276 |
|
| 289 |
Log.finest("\nProject.loadResults(): loading from result node qualifier " + parametersNodePath);
|
|
| 290 |
//Log.finest("Toolbox.initialize(): class = " + TXMPreferences.getString("class", nodeQualifier));
|
|
| 291 |
//TXMPreferences.dump(); |
|
| 277 |
// skip non-TXMResult preference node |
|
| 278 |
// if (TXMPreferences.getString(TXMPreferences.BUNDLE_ID, nodeQualifier).isEmpty()) {
|
|
| 279 |
// continue; |
|
| 280 |
// } |
|
| 292 | 281 |
|
| 293 |
|
|
| 294 |
Log.finest("Project.loadResults(): class = " + className); //$NON-NLS-1$
|
|
| 295 |
// Log.finest("Toolbox.initialize(): parent_uuid = " + TXMPreferences.getString(TXMPreferences.PARENT_UUID, nodeQualifier));
|
|
| 296 |
Log.finest("Project.loadResults(): parent_uuid = " + TXMPreferences.preferencesRootNode.node(parametersNodePath).get(TXMPreferences.PARENT_UUID, "")); //$NON-NLS-1$
|
|
| 297 |
String bundleId = TXMPreferences.preferencesRootNode.node(parametersNodePath).get(TXMPreferences.BUNDLE_ID, ""); //$NON-NLS-1$ |
|
| 298 |
Log.finest("Project.loadResults(): bundle_id = " + bundleId); //$NON-NLS-1$
|
|
| 299 |
Bundle bundle = Platform.getBundle(bundleId); |
|
| 300 |
if (bundle == null) {
|
|
| 301 |
Log.finest("Warning: can not restore object with bundle name " + bundleId); //$NON-NLS-1$
|
|
| 302 |
continue; |
|
| 303 |
} |
|
| 304 |
|
|
| 305 |
Class<?> cl = bundle.loadClass(className); |
|
| 306 |
Constructor<?> cons = cl.getConstructor(String.class); |
|
| 307 |
TXMResult result = (TXMResult) cons.newInstance(parametersNodePath); |
|
| 308 |
|
|
| 309 |
// not an internal persistence (eg. corpus or partition) |
|
| 310 |
if (!result.isInternalPersistable()) {
|
|
| 311 |
result.setUserPersistable(true); |
|
| 312 |
} |
|
| 313 |
} catch (Exception e) {
|
|
| 314 |
// TODO Auto-generated catch block |
|
| 315 |
e.printStackTrace(); |
|
| 282 |
try {
|
|
| 283 |
|
|
| 284 |
String className = TXMPreferences.preferencesRootNode.node(parametersNodePath).get("class", ""); //$NON-NLS-1$
|
|
| 285 |
|
|
| 286 |
// Skip Project object |
|
| 287 |
if(className.equals(Project.class.getName())) {
|
|
| 288 |
continue; |
|
| 316 | 289 |
} |
| 290 |
|
|
| 291 |
Log.finest("\nProject.loadResults(): loading from result node qualifier " + parametersNodePath);
|
|
| 292 |
//Log.finest("Toolbox.initialize(): class = " + TXMPreferences.getString("class", nodeQualifier));
|
|
| 293 |
//TXMPreferences.dump(); |
|
| 294 |
|
|
| 295 |
|
|
| 296 |
Log.finest("Project.loadResults(): class = " + className); //$NON-NLS-1$
|
|
| 297 |
// Log.finest("Toolbox.initialize(): parent_uuid = " + TXMPreferences.getString(TXMPreferences.PARENT_UUID, nodeQualifier));
|
|
| 298 |
Log.finest("Project.loadResults(): parent_uuid = " + TXMPreferences.preferencesRootNode.node(parametersNodePath).get(TXMPreferences.PARENT_UUID, "")); //$NON-NLS-1$
|
|
| 299 |
String bundleId = TXMPreferences.preferencesRootNode.node(parametersNodePath).get(TXMPreferences.BUNDLE_ID, ""); //$NON-NLS-1$ |
|
| 300 |
Log.finest("Project.loadResults(): bundle_id = " + bundleId); //$NON-NLS-1$
|
|
| 301 |
Bundle bundle = Platform.getBundle(bundleId); |
|
| 302 |
if (bundle == null) {
|
|
| 303 |
Log.finest("Warning: can not restore object with bundle name " + bundleId); //$NON-NLS-1$
|
|
| 304 |
continue; |
|
| 305 |
} |
|
| 306 |
|
|
| 307 |
Class<?> cl = bundle.loadClass(className); |
|
| 308 |
Constructor<?> cons = cl.getConstructor(String.class); |
|
| 309 |
TXMResult result = (TXMResult) cons.newInstance(parametersNodePath); |
|
| 310 |
|
|
| 311 |
// not an internal persistence (eg. corpus or partition) |
|
| 312 |
if (!result.isInternalPersistable()) {
|
|
| 313 |
result.setUserPersistable(true); |
|
| 314 |
} |
|
| 315 |
} catch (Exception e) {
|
|
| 316 |
// TODO Auto-generated catch block |
|
| 317 |
e.printStackTrace(); |
|
| 317 | 318 |
} |
| 319 |
} |
|
| 318 | 320 |
} |
| 319 |
|
|
| 320 |
|
|
| 321 |
|
|
| 322 | 321 |
|
| 322 |
|
|
| 323 |
|
|
| 324 |
|
|
| 323 | 325 |
// public BasePreferenceScope getPreferenceScope() {
|
| 324 | 326 |
// return scope; |
| 325 | 327 |
// } |
| ... | ... | |
| 685 | 687 |
@Override |
| 686 | 688 |
public boolean saveParameters() throws Exception {
|
| 687 | 689 |
StringBuilder str = new StringBuilder(); |
| 688 |
for (String l : links.keySet()) {
|
|
| 689 |
Alignement a = links.get(l); |
|
| 690 |
str.append("\t"+a.from+"#"+a.to+"#"+a.struct+"#"+a.level);
|
|
| 690 |
if (links != null) {
|
|
| 691 |
for (String l : links.keySet()) {
|
|
| 692 |
Alignement a = links.get(l); |
|
| 693 |
str.append("\t"+a.from+"#"+a.to+"#"+a.struct+"#"+a.level);
|
|
| 694 |
} |
|
| 695 |
if (str.length() > 0) {
|
|
| 696 |
this.setParameter(TBXPreferences.LINKS, str.substring(1)); |
|
| 697 |
} |
|
| 691 | 698 |
} |
| 692 |
if (str.length() > 0) {
|
|
| 693 |
this.setParameter(TBXPreferences.LINKS, str.substring(1)); |
|
| 694 |
} |
|
| 695 | 699 |
|
| 696 | 700 |
if (this.pCreationDate != null) {
|
| 697 | 701 |
this.saveParameter(TBXPreferences.CREATE_DATE, Toolbox.dateformat.format(this.pCreationDate)); |
| ... | ... | |
| 984 | 988 |
IEclipsePreferences params = this.getPreferencesScope().getNode("Tokenizer");
|
| 985 | 989 |
params.put(name, value); |
| 986 | 990 |
} |
| 987 |
|
|
| 991 |
|
|
| 988 | 992 |
public String getTokenizerParameter(String name, String defaultvalue) {
|
| 989 | 993 |
IEclipsePreferences params = this.getPreferencesScope().getNode("Tokenizer");
|
| 990 | 994 |
return params.get(name, defaultvalue); |
| 991 | 995 |
} |
| 992 |
|
|
| 996 |
|
|
| 997 |
public String[] getTextualPlans() {
|
|
| 998 |
try {
|
|
| 999 |
return this.getPreferencesScope().getNode("TextualPlans").childrenNames();
|
|
| 1000 |
} catch (BackingStoreException e) {
|
|
| 1001 |
// TODO Auto-generated catch block |
|
| 1002 |
e.printStackTrace(); |
|
| 1003 |
} |
|
| 1004 |
return new String[0]; |
|
| 1005 |
} |
|
| 1006 |
|
|
| 1007 |
public String getTextualPlan(String name) {
|
|
| 1008 |
return this.getPreferencesScope().getNode("TextualPlans").get(name, "");
|
|
| 1009 |
} |
|
| 1010 |
|
|
| 1011 |
public void setTextualPlan(String name, String elements) {
|
|
| 1012 |
this.getPreferencesScope().getNode("TextualPlans").put(name, elements);
|
|
| 1013 |
} |
|
| 1014 |
|
|
| 993 | 1015 |
public String getTokenizerWordElement() {
|
| 994 | 1016 |
IEclipsePreferences params = this.getPreferencesScope().getNode("Tokenizer");
|
| 995 | 1017 |
return params.get("wordelement", "w");
|
| 996 | 1018 |
} |
| 997 |
|
|
| 1019 |
|
|
| 998 | 1020 |
public boolean getDoTokenizerStep() {
|
| 999 | 1021 |
IEclipsePreferences params = this.getPreferencesScope().getNode("Tokenizer");
|
| 1000 | 1022 |
return params.getBoolean("doTokenizeStep", true);
|
| ... | ... | |
| 1016 | 1038 |
} |
| 1017 | 1039 |
return null; |
| 1018 | 1040 |
} |
| 1019 |
|
|
| 1041 |
|
|
| 1020 | 1042 |
@SuppressWarnings("unchecked")
|
| 1021 | 1043 |
private List<CorpusBuild> getCorpusBuilds() {
|
| 1022 | 1044 |
return (List<CorpusBuild>) getChildren(CorpusBuild.class); |
| ... | ... | |
| 1043 | 1065 |
return false; |
| 1044 | 1066 |
} |
| 1045 | 1067 |
} |
| 1046 |
|
|
| 1068 |
|
|
| 1047 | 1069 |
/** |
| 1048 | 1070 |
* Gets the project parameters root path ("project/[project name]/")
|
| 1049 | 1071 |
* @return |
| ... | ... | |
| 1065 | 1087 |
public boolean getDoUpdate() {
|
| 1066 | 1088 |
return this.getPreferencesScope().getNode("import").getBoolean(ImportKeys.UPDATECORPUS, false);
|
| 1067 | 1089 |
} |
| 1068 |
|
|
| 1090 |
|
|
| 1091 |
public void setDoUpdate(boolean update) {
|
|
| 1092 |
this.getPreferencesScope().getNode("import").putBoolean(ImportKeys.UPDATECORPUS, update);
|
|
| 1093 |
} |
|
| 1094 |
|
|
| 1069 | 1095 |
public boolean getDoMultiThread() {
|
| 1070 | 1096 |
return this.getPreferencesScope().getNode("import").getBoolean(ImportKeys.MULTITHREAD, false);
|
| 1071 | 1097 |
} |
| 1098 |
|
|
| 1099 |
public void setDoMultiThread(boolean multithreaded) {
|
|
| 1100 |
this.getPreferencesScope().getNode("import").putBoolean(ImportKeys.MULTITHREAD, multithreaded);
|
|
| 1101 |
} |
|
| 1072 | 1102 |
} |
| tmp/org.txm.core/src/java/org/txm/importer/ImportKeys.java (revision 1137) | ||
|---|---|---|
| 1 |
package org.txm.importer; |
|
| 2 |
|
|
| 3 |
public class ImportKeys {
|
|
| 4 |
|
|
| 5 |
public static final String CLEAN = "clean.directories"; |
|
| 6 |
public static final String TTMODEL = "annotate.model"; |
|
| 7 |
public static final String TTANNOTATE = "annotate.run"; |
|
| 8 |
public static final String LANG = "lang"; |
|
| 9 |
|
|
| 10 |
public static final String MULTITHREAD = "multithread"; |
|
| 11 |
public static final String DEBUG = "debug"; |
|
| 12 |
public static final String UPDATECORPUS = "corpus.update"; |
|
| 13 |
|
|
| 14 |
public static final String NORMALISEANAVALUES = "normalize.ana.values"; |
|
| 15 |
public static final String NORMALISEATTRIBUTEVALUES = "normalize.attribute.values"; |
|
| 16 |
} |
|
| tmp/org.txm.core/src/java/org/txm/Toolbox.java (revision 1137) | ||
|---|---|---|
| 301 | 301 |
|
| 302 | 302 |
Log.info("Toolbox.initialize(): " + projects.length + " project(s) found in workspace.");
|
| 303 | 303 |
|
| 304 |
for (int i = 0; i < projects.length; i++) {
|
|
| 304 |
for (IProject project : projects) {
|
|
| 305 | 305 |
|
| 306 | 306 |
//IScopeContext projectScope = new ProjectScope(projects[i]); |
| 307 |
IProject project = projects[i]; |
|
| 308 | 307 |
ArrayList<String> resultNodePaths = TXMPreferences.getAllResultsNodePaths("project/" + project.getName() + "/");
|
| 309 | 308 |
|
| 310 |
Log.info("Toolbox.initialize(): loading project " + projects[i].getName() + "...");
|
|
| 311 |
Log.info("Toolbox.initialize(): " + resultNodePaths.size() + " node(s) found in project " + projects[i].getName() + "...");
|
|
| 309 |
Log.info("Toolbox.initialize(): loading project " + project.getName() + "...");
|
|
| 310 |
Log.info("Toolbox.initialize(): " + resultNodePaths.size() + " node(s) found in project " + project.getName() + "...");
|
|
| 312 | 311 |
|
| 313 | 312 |
for (String parametersNodePath : resultNodePaths) {
|
| 314 | 313 |
|
| ... | ... | |
| 346 | 345 |
continue; |
| 347 | 346 |
} |
| 348 | 347 |
|
| 349 |
Log.info("Toolbox.initialize(): creating project " + projects[i].getName() + ".");
|
|
| 348 |
Log.info("Toolbox.initialize(): creating project " + project.getName() + ".");
|
|
| 350 | 349 |
Class<?> cl = bundle.loadClass(className); |
| 351 | 350 |
Constructor<?> cons = cl.getConstructor(String.class); |
| 352 | 351 |
TXMResult result = (TXMResult) cons.newInstance(parametersNodePath); |
| tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/KRAnnotationEngine.java (revision 1137) | ||
|---|---|---|
| 216 | 216 |
if (base == null) return new ArrayList<String>(); |
| 217 | 217 |
String[] names; |
| 218 | 218 |
try {
|
| 219 |
names = base.getPreferencesScope().getNode("KnowledgeRepository").node("names").keys();
|
|
| 219 |
names = base.getPreferencesScope().getNode("KnowledgeRepository").childrenNames();
|
|
| 220 | 220 |
return Arrays.asList(names); // getKnowledgeRepositoryNames(params); |
| 221 | 221 |
} catch (BackingStoreException e) {
|
| 222 | 222 |
e.printStackTrace(); |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteImportScript.java (revision 1137) | ||
|---|---|---|
| 51 | 51 |
import org.txm.core.engines.ImportEngines; |
| 52 | 52 |
import org.txm.core.engines.ScriptedImportEngine; |
| 53 | 53 |
import org.txm.groovy.core.GSERunner; |
| 54 |
import org.txm.importer.ImportKeys; |
|
| 55 | 54 |
import org.txm.objects.BaseOldParameters; |
| 56 | 55 |
import org.txm.objects.Project; |
| 57 | 56 |
import org.txm.rcp.StatusLine; |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/imports/sections/TextualPlansSection.java (revision 1137) | ||
|---|---|---|
| 15 | 15 |
import org.w3c.dom.Element; |
| 16 | 16 |
|
| 17 | 17 |
public class TextualPlansSection extends ImportEditorSection {
|
| 18 |
|
|
| 18 |
|
|
| 19 | 19 |
private static final int SECTION_SIZE = 1; |
| 20 | 20 |
private Text outsideTextElementsText; |
| 21 | 21 |
private Text outsideTextElementsToEditText; |
| 22 | 22 |
private Text noteElementsText; |
| 23 | 23 |
private Text milestoneElementsText; |
| 24 |
|
|
| 24 |
|
|
| 25 | 25 |
public TextualPlansSection(FormToolkit toolkit2, ScrolledForm form2, Composite parent, int style) {
|
| 26 | 26 |
super(toolkit2, form2, parent, style); |
| 27 | 27 |
|
| ... | ... | |
| 35 | 35 |
@Override |
| 36 | 36 |
public void expansionStateChanged(ExpansionEvent e) {form.layout(true);}
|
| 37 | 37 |
}); |
| 38 |
|
|
| 38 |
|
|
| 39 | 39 |
Composite sectionClient = toolkit.createComposite(this.section); |
| 40 | 40 |
TableWrapLayout slayout = new TableWrapLayout(); |
| 41 | 41 |
slayout.makeColumnsEqualWidth = false; |
| 42 | 42 |
slayout.numColumns = 2; |
| 43 | 43 |
sectionClient.setLayout(slayout); |
| 44 | 44 |
this.section.setClient(sectionClient); |
| 45 |
|
|
| 45 |
|
|
| 46 | 46 |
Label tmpLabel = toolkit.createLabel(sectionClient, TXMUIMessages.TextualPlansSection_outsidetext_label); |
| 47 | 47 |
tmpLabel.setToolTipText(TXMUIMessages.TextualPlansSection_outsidetext_tooltip); |
| 48 | 48 |
tmpLabel.setLayoutData(getLabelGridData()); |
| 49 |
|
|
| 49 |
|
|
| 50 | 50 |
outsideTextElementsText = toolkit.createText(sectionClient, "teiHeader", SWT.BORDER); //$NON-NLS-1$ |
| 51 | 51 |
TableWrapData gdata = getTextGridData(); |
| 52 | 52 |
outsideTextElementsText.setLayoutData(gdata); |
| 53 |
|
|
| 53 |
|
|
| 54 | 54 |
Label tmpLabel2 = toolkit.createLabel(sectionClient, TXMUIMessages.TextualPlansSection_outsidetexttoedit_label); |
| 55 | 55 |
tmpLabel2.setToolTipText(TXMUIMessages.TextualPlansSection_outsidetexttoedit_tooltip); |
| 56 | 56 |
tmpLabel2.setLayoutData(getLabelGridData()); |
| ... | ... | |
| 66 | 66 |
noteElementsText = toolkit.createText(sectionClient, "note", SWT.BORDER); //$NON-NLS-1$ |
| 67 | 67 |
gdata = getTextGridData(); |
| 68 | 68 |
noteElementsText.setLayoutData(gdata); |
| 69 |
|
|
| 69 |
|
|
| 70 | 70 |
Label tmpLabel4 = toolkit.createLabel(sectionClient, TXMUIMessages.TextualPlansSection_milestone_label); |
| 71 | 71 |
tmpLabel4.setToolTipText(TXMUIMessages.TextualPlansSection_milestone_tooltip); |
| 72 | 72 |
tmpLabel4.setLayoutData(getLabelGridData()); |
| ... | ... | |
| 78 | 78 |
|
| 79 | 79 |
@Override |
| 80 | 80 |
public void update(Project project) {
|
| 81 |
// Element textualplansElement = params.getTextualPlans(); //$NON-NLS-1$ |
|
| 82 |
// if (textualplansElement != null) {
|
|
| 83 |
// Element outsideTextElement = params.getOutSideTextTagsElement(); |
|
| 84 |
// if (outsideTextElement != null) |
|
| 85 |
// outsideTextElementsText.setText(outsideTextElement.getTextContent()); |
|
| 86 |
// |
|
| 87 |
// Element outsideTextToEditElement = params.getOutSideTextTagsAndKeepContentElement(); |
|
| 88 |
// if (outsideTextToEditElement != null) |
|
| 89 |
// outsideTextElementsToEditText.setText(outsideTextToEditElement.getTextContent()); |
|
| 90 |
// |
|
| 91 |
// Element noteElement = params.getNoteElement(); |
|
| 92 |
// if (noteElement != null) |
|
| 93 |
// noteElementsText.setText(noteElement.getTextContent()); |
|
| 94 |
// |
|
| 95 |
// Element milestonesElement = params.getMilestonesElement(); |
|
| 96 |
// if (milestonesElement != null) |
|
| 97 |
// milestoneElementsText.setText(milestonesElement.getTextContent()); |
|
| 98 |
// } else {
|
|
| 99 |
// System.out.println(TXMUIMessages.TextualPlansSection_update_error); |
|
| 100 |
// } |
|
| 81 |
if (this.section != null && !section.isDisposed()) {
|
|
| 82 |
outsideTextElementsText.setText(project.getTextualPlan("OutSideTextTags"));
|
|
| 83 |
outsideTextElementsToEditText.setText(project.getTextualPlan("OutSideTextTagsAndKeepContent"));
|
|
| 84 |
noteElementsText.setText(project.getTextualPlan("Note"));
|
|
| 85 |
milestoneElementsText.setText(project.getTextualPlan("MileStones"));
|
|
| 86 |
} |
|
| 101 | 87 |
} |
| 102 | 88 |
|
| 103 | 89 |
@Override |
| 104 | 90 |
public boolean save(Project project) {
|
| 105 | 91 |
if (this.section != null && !section.isDisposed()) {
|
| 106 |
// Element textualplansElement = params.getTextualPlans(); |
|
| 107 |
// if (textualplansElement != null) {
|
|
| 108 |
// Element outsideTextElement = params.getOutSideTextTagsElement(); |
|
| 109 |
// outsideTextElement.setAttribute("type", "list"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 110 |
// outsideTextElement.setTextContent(outsideTextElementsText.getText()); |
|
| 111 |
// |
|
| 112 |
// Element outsideTextToEditElement = params.getOutSideTextTagsAndKeepContentElement(); |
|
| 113 |
// outsideTextToEditElement.setAttribute("type", "list"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 114 |
// outsideTextToEditElement.setTextContent(outsideTextElementsToEditText.getText()); |
|
| 115 |
// |
|
| 116 |
// Element noteElement = params.getNoteElement(); |
|
| 117 |
// noteElement.setAttribute("type", "list"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 118 |
// noteElement.setTextContent(noteElementsText.getText()); |
|
| 119 |
// |
|
| 120 |
// Element milestonesElement = params.getMilestonesElement(); |
|
| 121 |
// milestonesElement.setTextContent(milestoneElementsText.getText().trim()); |
|
| 122 |
// } else {
|
|
| 123 |
// System.out.println(TXMUIMessages.TextualPlansSection_save_error); |
|
| 124 |
// return false; |
|
| 125 |
// } |
|
| 92 |
|
|
| 93 |
project.setTextualPlan("OutSideTextTags", outsideTextElementsText.getText().trim());
|
|
| 94 |
|
|
| 95 |
project.setTextualPlan("OutSideTextTagsAndKeepContent", outsideTextElementsToEditText.getText().trim());
|
|
| 96 |
|
|
| 97 |
project.setTextualPlan("Note", noteElementsText.getText());
|
|
| 98 |
|
|
| 99 |
project.setTextualPlan("MileStones", milestoneElementsText.getText().trim());
|
|
| 100 |
|
|
| 126 | 101 |
return true; |
| 127 | 102 |
} |
| 128 | 103 |
|
Formats disponibles : Unified diff