Révision 3516
TXM/trunk/org.txm.analec.rcp/src/org/txm/annotation/urs/commands/URSToolsMenuContribution.java (revision 3516) | ||
---|---|---|
139 | 139 |
public void widgetSelected(SelectionEvent e) { |
140 | 140 |
IWorkbenchWindow acWindow = TXMWindows.getActiveWindow(); |
141 | 141 |
IWorkbenchPart page = acWindow.getActivePage().getActivePart(); |
142 |
ExecuteGroovyMacro.execute(macro.getAbsolutePath(), page, CorporaView.getInstance().getTreeViewer().getSelection(), "", null, null);
|
|
142 |
ExecuteGroovyMacro.execute(macro.getAbsolutePath(), page, CorporaView.getInstance().getTreeViewer().getSelection(), null, null, null);
|
|
143 | 143 |
} |
144 | 144 |
} |
145 | 145 |
|
TXM/trunk/org.txm.ruby.core/src/org/txm/ruby/core/RubyScriptEngine.java (revision 3516) | ||
---|---|---|
4 | 4 |
import java.io.BufferedReader; |
5 | 5 |
import java.io.File; |
6 | 6 |
import java.io.IOException; |
7 |
import java.util.ArrayList; |
|
7 | 8 |
import java.util.HashMap; |
9 |
import java.util.List; |
|
8 | 10 |
|
9 | 11 |
import javax.script.ScriptEngineManager; |
10 | 12 |
import javax.script.ScriptException; |
... | ... | |
61 | 63 |
} |
62 | 64 |
|
63 | 65 |
@Override |
64 |
public IStatus executeScript(File script, HashMap<String, Object> env, String stringArgs) {
|
|
66 |
public IStatus executeScript(File script, HashMap<String, Object> env, List<String> stringArgs) {
|
|
65 | 67 |
BufferedReader r = null; |
66 | 68 |
try { |
67 | 69 |
SimpleBindings bindings = new SimpleBindings(); |
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyScript.java (revision 3516) | ||
---|---|---|
28 | 28 |
package org.txm.rcp.handlers.scripts; |
29 | 29 |
|
30 | 30 |
import java.io.File; |
31 |
import java.util.Arrays; |
|
31 | 32 |
import java.util.HashMap; |
32 | 33 |
import java.util.Iterator; |
33 | 34 |
import java.util.List; |
... | ... | |
164 | 165 |
String scriptRootDir = Toolbox.getTxmHomePath() + "/scripts"; //$NON-NLS-1$ |
165 | 166 |
File currentRootDir = new File(scriptRootDir, "groovy/user"); //$NON-NLS-1$ |
166 | 167 |
|
167 |
return executeScript(currentRootDir, scriptpath, page, selection, modal, stringArgs, null, null);
|
|
168 |
return executeScript(currentRootDir, scriptpath, page, selection, modal, Arrays.asList(stringArgs.split("\t")), null, null);
|
|
168 | 169 |
} |
169 | 170 |
|
170 | 171 |
/** |
... | ... | |
196 | 197 |
* @param page current active page, might be null |
197 | 198 |
* @param sel current selection, might be null |
198 | 199 |
*/ |
199 |
public static IStatus executeScript(final File currentRootDir, String scriptpath, final IWorkbenchPart page, final ISelection sel, final boolean modal, final String stringArgs, HashMap<String, Object> parameters, HashMap<String, Object> defaultParameters) {
|
|
200 |
public static IStatus executeScript(final File currentRootDir, String scriptpath, final IWorkbenchPart page, final ISelection sel, final boolean modal, final List<String> stringArgs, HashMap<String, Object> parameters, HashMap<String, Object> defaultParameters) {
|
|
200 | 201 |
// check script |
201 | 202 |
final File scriptfile = new File(scriptpath); |
202 | 203 |
if (!scriptfile.exists()) { |
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteLastGroovyScript.java (revision 3516) | ||
---|---|---|
90 | 90 |
return; |
91 | 91 |
} |
92 | 92 |
|
93 |
ExecuteGroovyScript.executeScript(currentRootDir, lastScript.getAbsolutePath(), page, selection, false, "", null, null); //$NON-NLS-1$
|
|
93 |
ExecuteGroovyScript.executeScript(currentRootDir, lastScript.getAbsolutePath(), page, selection, false, null, null, null); //$NON-NLS-1$
|
|
94 | 94 |
} |
95 | 95 |
} |
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteScript.java (revision 3516) | ||
---|---|---|
28 | 28 |
package org.txm.rcp.handlers.scripts; |
29 | 29 |
|
30 | 30 |
import java.io.File; |
31 |
import java.util.ArrayList; |
|
31 | 32 |
import java.util.HashMap; |
32 | 33 |
import java.util.Iterator; |
34 |
import java.util.List; |
|
33 | 35 |
|
34 | 36 |
import org.apache.commons.collections.map.HashedMap; |
35 | 37 |
import org.eclipse.core.commands.AbstractHandler; |
... | ... | |
184 | 186 |
* |
185 | 187 |
* @param scriptpath the scriptfile |
186 | 188 |
*/ |
187 |
public static IStatus executeScript(String scriptpath, final IWorkbenchPart page, final ISelection selection, String stringArgs) {
|
|
189 |
public static IStatus executeScript(String scriptpath, final IWorkbenchPart page, final ISelection selection, List<String> stringArgs) {
|
|
188 | 190 |
if (scriptpath == null) return Status.CANCEL_STATUS; |
189 | 191 |
File script = new File(scriptpath); |
190 | 192 |
if (!script.exists()) return Status.CANCEL_STATUS; |
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteGroovyMacro.java (revision 3516) | ||
---|---|---|
28 | 28 |
package org.txm.rcp.handlers.scripts; |
29 | 29 |
|
30 | 30 |
import java.io.File; |
31 |
import java.util.ArrayList; |
|
32 |
import java.util.Arrays; |
|
31 | 33 |
import java.util.HashMap; |
32 | 34 |
import java.util.Iterator; |
35 |
import java.util.List; |
|
33 | 36 |
|
37 |
import org.apache.commons.lang.StringUtils; |
|
34 | 38 |
import org.eclipse.core.commands.AbstractHandler; |
35 | 39 |
import org.eclipse.core.commands.ExecutionEvent; |
36 | 40 |
import org.eclipse.core.commands.ExecutionException; |
... | ... | |
62 | 66 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
63 | 67 |
|
64 | 68 |
String filenameParameter = event.getParameter("org.txm.rcp.command.parameter.file"); //$NON-NLS-1$ |
65 |
String stringArgs = event.getParameter("args"); //$NON-NLS-1$
|
|
69 |
List<String> stringArgs = Arrays.asList(event.getParameter("args").split("\t")); //$NON-NLS-1$
|
|
66 | 70 |
|
67 | 71 |
// the file to execute |
68 | 72 |
String result = ""; //$NON-NLS-1$ |
... | ... | |
116 | 120 |
return execute(result, page, selection, stringArgs, null, null); |
117 | 121 |
} |
118 | 122 |
|
119 |
public static IStatus execute(String scriptpath, IWorkbenchPart page, ISelection selection, String stringArgs, HashMap<String, Object> parameters, HashMap<String, Object> defaultParameters) {
|
|
123 |
public static IStatus execute(String scriptpath, IWorkbenchPart page, ISelection selection, List<String> args, HashMap<String, Object> parameters, HashMap<String, Object> defaultParameters) {
|
|
120 | 124 |
//IPreferencesService service = Platform.getPreferencesService(); |
121 | 125 |
String scriptRootDir = Toolbox.getTxmHomePath() + "/scripts"; //$NON-NLS-1$ |
122 | 126 |
File currentRootDir = new File(scriptRootDir, "groovy/user"); //$NON-NLS-1$ |
123 | 127 |
|
124 | 128 |
if (scriptpath.endsWith(".groovy")) { //$NON-NLS-1$ |
125 |
return ExecuteGroovyScript.executeScript(currentRootDir, scriptpath, page, selection, false, stringArgs, parameters, defaultParameters);
|
|
129 |
return ExecuteGroovyScript.executeScript(currentRootDir, scriptpath, page, selection, false, args, parameters, defaultParameters);
|
|
126 | 130 |
} else { |
127 |
return ExecuteScript.executeScript(scriptpath, page, selection, stringArgs);
|
|
131 |
return ExecuteScript.executeScript(scriptpath, page, selection, args);
|
|
128 | 132 |
} |
129 | 133 |
} |
130 | 134 |
} |
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/menu/MacrosMenuContribution.java (revision 3516) | ||
---|---|---|
151 | 151 |
public void widgetSelected(SelectionEvent e) { |
152 | 152 |
IWorkbenchWindow acWindow = TXMWindows.getActiveWindow(); |
153 | 153 |
IWorkbenchPart page = acWindow.getActivePage().getActivePart(); |
154 |
ExecuteGroovyMacro.execute(macro.getAbsolutePath(), page, CorporaView.getInstance().getTreeViewer().getSelection(), "", null, null); //$NON-NLS-1$
|
|
154 |
ExecuteGroovyMacro.execute(macro.getAbsolutePath(), page, CorporaView.getInstance().getTreeViewer().getSelection(), null, null, null); //$NON-NLS-1$
|
|
155 | 155 |
} |
156 | 156 |
} |
157 | 157 |
|
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/views/fileexplorer/MacroExplorer.java (revision 3516) | ||
---|---|---|
272 | 272 |
IWorkbenchPart page = acWindow.getActivePage().getActivePart(); |
273 | 273 |
|
274 | 274 |
if (selectedItem.getName().toLowerCase().endsWith(".groovy")) { |
275 |
ExecuteGroovyMacro.execute(selectedItem.getAbsolutePath(), page, selection, "", null, null);
|
|
275 |
ExecuteGroovyMacro.execute(selectedItem.getAbsolutePath(), page, selection, null, null, null);
|
|
276 | 276 |
} |
277 | 277 |
else { |
278 | 278 |
String ext = FileUtils.getExtension(selectedItem); |
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/commands/function/WordPropertiestoTable.java (revision 3516) | ||
---|---|---|
39 | 39 |
defaultParameters.put("properties", "frpos,frlemma"); //$NON-NLS-1$ //$NON-NLS-2$ |
40 | 40 |
defaultParameters.put("tsvFile", corpus.getName()+"_annotations.tsv"); //$NON-NLS-1$ //$NON-NLS-2$ |
41 | 41 |
|
42 |
ExecuteGroovyMacro.execute(script.getAbsolutePath(), part, selection, "", parameters, defaultParameters); //$NON-NLS-1$
|
|
42 |
ExecuteGroovyMacro.execute(script.getAbsolutePath(), part, selection, null, parameters, defaultParameters); //$NON-NLS-1$
|
|
43 | 43 |
return null; |
44 | 44 |
} |
45 | 45 |
} |
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/commands/function/WordPropertiesFromTable.java (revision 3516) | ||
---|---|---|
37 | 37 |
defaultParameters.put("properties", "frpos,frlemma"); //$NON-NLS-1$ //$NON-NLS-2$ |
38 | 38 |
defaultParameters.put("tsvFile", corpus.getName()+"_annotations.tsv"); //$NON-NLS-1$ //$NON-NLS-2$ |
39 | 39 |
|
40 |
ExecuteGroovyMacro.execute(script.getAbsolutePath(), part, selection, "", null, defaultParameters); //$NON-NLS-1$
|
|
40 |
ExecuteGroovyMacro.execute(script.getAbsolutePath(), part, selection, null, null, defaultParameters); //$NON-NLS-1$
|
|
41 | 41 |
return null; |
42 | 42 |
} |
43 | 43 |
|
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 3516) | ||
---|---|---|
992 | 992 |
notifyExtensions("notifyStartOfCompute"); //$NON-NLS-1$ |
993 | 993 |
|
994 | 994 |
if (!TXMEditor.this.getResult().compute(subMonitor.split(50))) { |
995 |
Log.fine("TXMEditor.compute(): " + TXMEditor.this.getClass().getSimpleName() + ": computing failed."); //$NON-NLS-1$ //$NON-NLS-2$
|
|
995 |
Log.info("TXMEditor.compute(): " + TXMEditor.this.getClass().getSimpleName() + ": computing failed."); //$NON-NLS-1$ //$NON-NLS-2$
|
|
996 | 996 |
} |
997 | 997 |
|
998 | 998 |
notifyExtensions("notifyEndOfCompute"); //$NON-NLS-1$ |
TXM/trunk/org.txm.ocaml.core/src/org/txm/ocaml/core/OcamlScriptEngine.java (revision 3516) | ||
---|---|---|
4 | 4 |
import java.io.IOException; |
5 | 5 |
import java.util.ArrayList; |
6 | 6 |
import java.util.HashMap; |
7 |
import java.util.List; |
|
7 | 8 |
|
8 | 9 |
import javax.script.ScriptContext; |
9 | 10 |
import javax.script.ScriptEngineManager; |
... | ... | |
43 | 44 |
} |
44 | 45 |
|
45 | 46 |
@Override |
46 |
public IStatus executeScript(File script, HashMap<String, Object> env, String stringArgs) {
|
|
47 |
public IStatus executeScript(File script, HashMap<String, Object> env, List<String> stringArgs) {
|
|
47 | 48 |
String cmd; |
48 | 49 |
try { |
49 | 50 |
cmd = IOUtils.getText(script, "UTF-8"); |
50 |
if (stringArgs == null) stringArgs = ""; |
|
51 |
return executeText(cmd+stringArgs, env); |
|
51 |
return executeText(cmd, env); |
|
52 | 52 |
} catch (IOException e) { |
53 | 53 |
e.printStackTrace(); |
54 | 54 |
return Status.CANCEL_STATUS; |
TXM/trunk/org.txm.core/src/java/org/txm/core/engines/ScriptEngine.java (revision 3516) | ||
---|---|---|
1 | 1 |
package org.txm.core.engines; |
2 | 2 |
|
3 | 3 |
import java.io.File; |
4 |
import java.util.ArrayList; |
|
5 |
import java.util.Arrays; |
|
4 | 6 |
import java.util.HashMap; |
7 |
import java.util.List; |
|
5 | 8 |
|
6 | 9 |
import org.eclipse.core.runtime.IStatus; |
7 | 10 |
import org.txm.core.results.TXMResult; |
... | ... | |
40 | 43 |
public IStatus executeScript(File script, HashMap<String, Object> env) { |
41 | 44 |
return executeScript(script, env, null); |
42 | 45 |
} |
46 |
|
|
47 |
public abstract IStatus executeScript(File script, HashMap<String, Object> env, List<String> args); |
|
43 | 48 |
|
44 |
public abstract IStatus executeScript(File script, HashMap<String, Object> env, String stringArgs); |
|
45 |
|
|
46 | 49 |
public IStatus executeText(String text) { |
47 | 50 |
return executeText(text); |
48 | 51 |
} |
... | ... | |
66 | 69 |
public String getDetails() { |
67 | 70 |
return this.getClass()+ " "+this.toString(); |
68 | 71 |
} |
72 |
|
|
73 |
public IStatus executeScript(File perlScript, List<String> args) { |
|
74 |
return executeScript(perlScript, null, args); |
|
75 |
} |
|
69 | 76 |
} |
TXM/trunk/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RScriptEngine.java (revision 3516) | ||
---|---|---|
3 | 3 |
import java.io.BufferedReader; |
4 | 4 |
import java.io.File; |
5 | 5 |
import java.io.FileReader; |
6 |
import java.util.ArrayList; |
|
6 | 7 |
import java.util.HashMap; |
8 |
import java.util.List; |
|
7 | 9 |
|
8 | 10 |
import org.eclipse.core.runtime.IProgressMonitor; |
9 | 11 |
import org.eclipse.core.runtime.IStatus; |
... | ... | |
89 | 91 |
* @param scriptfile the scriptfile |
90 | 92 |
*/ |
91 | 93 |
// FIXME: this method should call the method above : executeText(); |
92 |
public IStatus executeScript(File rFile, HashMap<String, Object> env, String stringArgs) {
|
|
94 |
public IStatus executeScript(File rFile, HashMap<String, Object> env, List<String> stringArgs) {
|
|
93 | 95 |
if (!rFile.exists()) { |
94 | 96 |
System.err.println(NLS.bind(RCoreMessages.p0RScriptDoesntExist, rFile)); |
95 | 97 |
return Status.CANCEL_STATUS; |
TXM/trunk/org.txm.connlu.core/groovy/org/txm/scripts/importer/conllu/CallUD2TigerPerlScript.groovy (revision 3516) | ||
---|---|---|
1 |
package org.txm.scripts.importer.conllu |
|
2 |
|
|
3 |
import org.txm.core.engines.ScriptEnginesManager |
|
4 |
import org.txm.utils.* |
|
5 |
|
|
6 |
def convertCoNLLUFiles(def input_directory_path, def output_directory) { |
|
7 |
|
|
8 |
def input_directory = new File(input_directory_path) |
|
9 |
|
|
10 |
if (input_directory_path.length() == 0 && input_directory.canRead()) { |
|
11 |
println "** impossible to access directory $input_directory. Aborting." |
|
12 |
return false |
|
13 |
} |
|
14 |
|
|
15 |
def tigerXMLDirectory = new File(output_directory, "tiger-xml") |
|
16 |
def conversionFile = new File(tigerXMLDirectory, "conversion.log") |
|
17 |
def mainFullFile = new File(tigerXMLDirectory, "main-full.xml") |
|
18 |
def mainFile = new File(tigerXMLDirectory, "main.xml") |
|
19 |
def perlScript = BundleUtils.getFile("org.txm.conllu.core", "groovy", "/org/txm/scripts/importer/conllu/", "conll2tiger-ud.pl") |
|
20 |
|
|
21 |
tigerXMLDirectory.deleteDir() |
|
22 |
//println "clean&mkdir $tigerXMLDirectory" |
|
23 |
tigerXMLDirectory.mkdir() |
|
24 |
|
|
25 |
//println "Converting..." |
|
26 |
|
|
27 |
def subcorpusList = "" |
|
28 |
for (def f : input_directory.listFiles()) { |
|
29 |
|
|
30 |
if (!f.getName().endsWith(".conllu")) { |
|
31 |
continue |
|
32 |
} |
|
33 |
|
|
34 |
try { |
|
35 |
println "$f... "+"perl '$perlScript' -s 10000 -o '$tigerXMLDirectory' '$f'" |
|
36 |
def engine = ScriptEnginesManager.getPerlEngine(); |
|
37 |
if (!engine.canExecute(perlScript)) { |
|
38 |
println "Error: Perl engine not correctly set to run $perlScript" |
|
39 |
return false; |
|
40 |
} |
|
41 |
def cmd = new ArrayList() |
|
42 |
cmd.addAll(["$perlScript", "-s", "10000", "-o", "$tigerXMLDirectory", "$f"]) |
|
43 |
def status = engine.runPerl(cmd, null) |
|
44 |
subcorpusList += mainFile.readLines("UTF-8").findAll() {it.contains("<subcorpus ")}.join("\n") // tiger-xml/main.xml >> tiger-xml/subcorpus-list |
|
45 |
} catch (Throwable t) { println "Error: $t" } |
|
46 |
} |
|
47 |
|
|
48 |
// println "subcorpus-list: "+subcorpusList |
|
49 |
mainFullFile.setText(mainFile.getText().replaceAll("<subcorpus .+</subcorpus>", subcorpusList)) |
|
50 |
|
|
51 |
conversionFile.delete() |
|
52 |
mainFullFile.renameTo(mainFile) |
|
53 |
|
|
54 |
//println "Done." |
|
55 |
return true |
|
56 |
} |
TXM/trunk/org.txm.connlu.core/groovy/org/txm/scripts/importer/conllu/CoNLLUImport.groovy (revision 3516) | ||
---|---|---|
19 | 19 |
import org.txm.scripts.importer.tigersearch.TSImport |
20 | 20 |
import org.txm.utils.* |
21 | 21 |
import org.txm.searchengine.ts.TIGERSearchEngine |
22 |
import org.txm.conllu.core.CallUD2TigerPerlScript |
|
22 | 23 |
|
23 | 24 |
class CoNLLUImport extends XTZImport { |
24 | 25 |
|
... | ... | |
47 | 48 |
// build the TIGER-XML file |
48 | 49 |
new CallUD2TigerPerlScript().convertCoNLLUFiles(this.sourceDirectory.getAbsolutePath(), this.binaryDirectory.getAbsolutePath()) |
49 | 50 |
|
50 |
|
|
51 | 51 |
File tigerXMLDirectory = new File(this.binaryDirectory, "tiger-xml") |
52 | 52 |
|
53 | 53 |
File xslfile1 = BundleUtils.getFile("org.txm.conllu.core", "groovy", "/org/txm/scripts/importer/conllu/", "tigerXml-commentOutLongSentences.xsl") |
TXM/trunk/org.txm.connlu.core/src/org/txm/conllu/core/CallUD2TigerPerlScript.java (revision 3516) | ||
---|---|---|
1 |
package org.txm.conllu.core; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.IOException; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.Arrays; |
|
7 |
|
|
8 |
import org.eclipse.core.runtime.IStatus; |
|
9 |
import org.txm.core.engines.ScriptEngine; |
|
10 |
import org.txm.core.engines.ScriptEnginesManager; |
|
11 |
import org.txm.tigersearch.preferences.TigerSearchPreferences; |
|
12 |
import org.txm.utils.*; |
|
13 |
import org.txm.utils.io.IOUtils; |
|
14 |
|
|
15 |
public class CallUD2TigerPerlScript { |
|
16 |
|
|
17 |
public boolean convertCoNLLUFiles(String input_directory_path, String output_directory) throws IOException { |
|
18 |
|
|
19 |
File input_directory = new File(input_directory_path); |
|
20 |
|
|
21 |
if (input_directory_path.length() == 0 && input_directory.canRead()) { |
|
22 |
System.out.println("** impossible to access directory $input_directory. Aborting."); |
|
23 |
return false; |
|
24 |
} |
|
25 |
|
|
26 |
File tigerXMLDirectory = new File(output_directory, "tiger-xml"); |
|
27 |
File conversionFile = new File(tigerXMLDirectory, "conversion.log"); |
|
28 |
|
|
29 |
String driverFilename = TigerSearchPreferences.getInstance().getString(TigerSearchPreferences.DRIVER_FILENAME); |
|
30 |
File mainFullFile = new File(tigerXMLDirectory, driverFilename); |
|
31 |
|
|
32 |
File mainFile = new File(tigerXMLDirectory, "main.xml"); |
|
33 |
File perlScript = BundleUtils.getFile("org.txm.conllu.core", "groovy", "/org/txm/scripts/importer/conllu/", "conll2tiger-ud.pl"); |
|
34 |
|
|
35 |
DeleteDir.deleteDirectory(tigerXMLDirectory); |
|
36 |
//println "clean&mkdir $tigerXMLDirectory" |
|
37 |
tigerXMLDirectory.mkdir(); |
|
38 |
|
|
39 |
//println "Converting..." |
|
40 |
|
|
41 |
String subcorpusList = ""; |
|
42 |
for (File f : input_directory.listFiles()) { |
|
43 |
|
|
44 |
if (!f.getName().endsWith(".conllu")) { |
|
45 |
continue; |
|
46 |
} |
|
47 |
|
|
48 |
try { |
|
49 |
//System.out.println("$f... "+"perl '$perlScript' -s 10000 -o '$tigerXMLDirectory' '$f'"); |
|
50 |
ScriptEngine engine = ScriptEnginesManager.getPerlEngine(); |
|
51 |
if (!engine.canExecute(perlScript)) { |
|
52 |
System.out.println("Error: Perl engine not correctly set to run $perlScript"); |
|
53 |
return false; |
|
54 |
} |
|
55 |
ArrayList<String> cmd = new ArrayList<String>(); |
|
56 |
cmd.addAll(Arrays.asList("-s", "10000", "-o", tigerXMLDirectory.getAbsolutePath(), f.getAbsolutePath())); |
|
57 |
System.out.println("calling perl with: "+cmd); |
|
58 |
IStatus status = engine.executeScript(perlScript, cmd); |
|
59 |
for (String line : IOUtils.getLines(mainFile, "UTF-8")) { |
|
60 |
if (line.contains("<subcorpus ")) subcorpusList += line+"\n"; |
|
61 |
} |
|
62 |
} catch (Throwable t) { System.out.println("Error: $t"); } |
|
63 |
} |
|
64 |
|
|
65 |
// println "subcorpus-list: "+subcorpusList |
|
66 |
String content = IOUtils.getText(mainFile, "UTF-8"); |
|
67 |
content = content.replaceAll("<subcorpus .+/>", subcorpusList+"\n<body/>"); // get the last main.xml content and patch it with the subcorpus tags |
|
68 |
IOUtils.setText(mainFullFile, content, "UTF-8"); |
|
69 |
//mainFullFile.setText(mainFile.getText().replaceAll("<body/>", subcorpusList+"\n<body/>")); |
|
70 |
|
|
71 |
conversionFile.delete(); |
|
72 |
mainFile.delete(); |
|
73 |
|
|
74 |
//println "Done." |
|
75 |
return true; |
|
76 |
} |
|
77 |
} |
|
0 | 78 |
TXM/trunk/org.txm.python.core/src/org/txm/python/core/PythonScriptEngine.java (revision 3516) | ||
---|---|---|
6 | 6 |
import java.util.ArrayList; |
7 | 7 |
import java.util.Arrays; |
8 | 8 |
import java.util.HashMap; |
9 |
import java.util.List; |
|
9 | 10 |
|
10 | 11 |
import org.eclipse.core.runtime.IProgressMonitor; |
11 | 12 |
import org.eclipse.core.runtime.IStatus; |
... | ... | |
44 | 45 |
} |
45 | 46 |
|
46 | 47 |
@Override |
47 |
public IStatus executeScript(File script, HashMap<String, Object> env, String stringArgs) {
|
|
48 |
public IStatus executeScript(File script, HashMap<String, Object> env, List<String> stringArgs) {
|
|
48 | 49 |
ArrayList<String> cmd = new ArrayList<String>(); |
49 | 50 |
cmd.add(script.getAbsolutePath()); |
50 | 51 |
|
TXM/trunk/org.txm.tigersearch.rcp/src/org/txm/function/tigersearch/TIGERSearch.java (revision 3516) | ||
---|---|---|
250 | 250 |
tsresult = tscorpus.query(pQuery.getQueryString()); |
251 | 251 |
tsresult.getFirst(); |
252 | 252 |
|
253 |
return tsresult.getNumberOfMatch() > 0;
|
|
253 |
return true;
|
|
254 | 254 |
} |
255 | 255 |
|
256 | 256 |
@Override |
TXM/trunk/org.txm.perl.core/src/org/txm/perl/core/PerlScriptEngine.java (revision 3516) | ||
---|---|---|
7 | 7 |
import java.util.ArrayList; |
8 | 8 |
import java.util.Arrays; |
9 | 9 |
import java.util.HashMap; |
10 |
import java.util.List; |
|
10 | 11 |
|
11 | 12 |
import org.eclipse.core.runtime.IProgressMonitor; |
12 | 13 |
import org.eclipse.core.runtime.IStatus; |
13 | 14 |
import org.eclipse.core.runtime.Status; |
14 | 15 |
import org.txm.core.engines.ScriptEngine; |
16 |
import org.txm.utils.logger.Log; |
|
15 | 17 |
/** |
16 | 18 |
* |
17 | 19 |
* @author mdecorde |
... | ... | |
44 | 46 |
} |
45 | 47 |
|
46 | 48 |
@Override |
47 |
public IStatus executeScript(File script, HashMap<String, Object> env, String stringArgs) {
|
|
49 |
public IStatus executeScript(File script, HashMap<String, Object> env, List<String> args) {
|
|
48 | 50 |
ArrayList<String> cmd = new ArrayList<String>(); |
49 | 51 |
cmd.add(script.getAbsolutePath()); |
50 |
|
|
52 |
cmd.addAll(args); |
|
51 | 53 |
System.out.println("Running perl script..."); |
52 | 54 |
return runPerl(cmd, env); |
53 | 55 |
} |
... | ... | |
72 | 74 |
private static IStatus runPerl(ArrayList<String> cmd, HashMap<String, Object> env) { |
73 | 75 |
|
74 | 76 |
try { |
75 |
ArrayList<String> tmp = new ArrayList<String>(); |
|
76 |
tmp.addAll(cmd); |
|
77 |
cmd = tmp; |
|
77 |
cmd = new ArrayList<String>(cmd); |
|
78 | 78 |
|
79 | 79 |
String additionalParametersString = PerlPreferences.getInstance().getString(PerlPreferences.ADDITIONAL_PARAMETERS); |
80 | 80 |
String[] additionalParameters = additionalParametersString.split("\t"); |
... | ... | |
103 | 103 |
} |
104 | 104 |
// } |
105 | 105 |
|
106 |
ProcessBuilder pb = new ProcessBuilder(new ArrayList<String>(cmd));
|
|
106 |
ProcessBuilder pb = new ProcessBuilder(cmd);
|
|
107 | 107 |
pb.redirectErrorStream(true); |
108 | 108 |
|
109 |
// new org.txm.utils.StreamHog(p.getInputStream(), true).setName("perl"); |
|
110 | 109 |
Process process = pb.start(); |
111 | 110 |
if (process != null) { |
112 | 111 |
BufferedReader bfr = new BufferedReader(new InputStreamReader(process.getInputStream())); |
113 | 112 |
String line = ""; |
114 | 113 |
while ((line = bfr.readLine()) != null) { |
115 | 114 |
// display each output line form perl script |
116 |
System.out.println(line);
|
|
115 |
Log.info(line);
|
|
117 | 116 |
} |
118 | 117 |
int e = process.waitFor(); |
119 | 118 |
if (e != 0) { |
TXM/trunk/org.txm.treesearch.rcp/src/org/txm/treesearch/editor/TreeSearchEditor.java (revision 3516) | ||
---|---|---|
291 | 291 |
if (ts.isComputed()) { |
292 | 292 |
queryArea.setText(ts.getQuery()); |
293 | 293 |
sentCounterLabel.setText("/" + ts.getNSentences()); //$NON-NLS-1$ |
294 |
subCounterLabel.setText("/" + ts.getNSubGraph(0)); //$NON-NLS-1$ |
|
294 |
if (ts.getNSentences() > 0) { |
|
295 |
subCounterLabel.setText("/" + ts.getNSubGraph(0)); //$NON-NLS-1$ |
|
296 |
} |
|
295 | 297 |
} |
296 | 298 |
else { |
297 | 299 |
sentCounterLabel.setText(Messages.NoSentence); |
TXM/trunk/org.txm.groovy.core/src/java/org/txm/groovy/core/TXMGroovyScriptEngine.java (revision 3516) | ||
---|---|---|
1 | 1 |
package org.txm.groovy.core; |
2 | 2 |
|
3 | 3 |
import java.io.File; |
4 |
import java.util.ArrayList; |
|
4 | 5 |
import java.util.HashMap; |
6 |
import java.util.List; |
|
5 | 7 |
|
6 | 8 |
import org.eclipse.core.runtime.IProgressMonitor; |
7 | 9 |
import org.eclipse.core.runtime.IStatus; |
... | ... | |
36 | 38 |
} |
37 | 39 |
|
38 | 40 |
@Override |
39 |
public IStatus executeScript(File script, HashMap<String, Object> env, String stringArgs) {
|
|
41 |
public IStatus executeScript(File script, HashMap<String, Object> env, List<String> stringArgs) {
|
|
40 | 42 |
// move Job code in the ExecuteGroovyScript here |
41 | 43 |
return Status.CANCEL_STATUS; |
42 | 44 |
} |
Formats disponibles : Unified diff