Révision 4007
TXM/trunk/bundles/org.txm.core/src/java/org/txm/core/engines/EnginesManager.java (revision 4007) | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.HashMap; |
4 | 4 |
|
5 |
import org.eclipse.core.internal.registry.ConfigurationElementHandle; |
|
6 | 5 |
import org.eclipse.core.runtime.IConfigurationElement; |
7 |
import org.eclipse.core.runtime.IContributor; |
|
6 |
import org.eclipse.core.runtime.IExtension; |
|
7 |
import org.eclipse.core.runtime.IExtensionPoint; |
|
8 | 8 |
import org.eclipse.core.runtime.IProgressMonitor; |
9 | 9 |
import org.eclipse.core.runtime.RegistryFactory; |
10 | 10 |
import org.txm.core.messages.TXMCoreMessages; |
... | ... | |
22 | 22 |
* |
23 | 23 |
*/ |
24 | 24 |
public abstract class EnginesManager<T extends Engine> extends HashMap<String, T> { |
25 |
|
|
25 |
|
|
26 | 26 |
private static final long serialVersionUID = 9186978207738860351L; |
27 |
|
|
27 |
|
|
28 | 28 |
public static final String ENGINES_MANAGER_EXTENSION_POINT_ID = EnginesManager.class.getName(); |
29 |
|
|
29 |
|
|
30 | 30 |
/** |
31 | 31 |
* Current engine. |
32 | 32 |
*/ |
33 | 33 |
protected T currentEngine = null; |
34 |
|
|
35 |
|
|
36 |
|
|
34 |
|
|
37 | 35 |
/** |
38 | 36 |
* Finds out the engines that matches this manager engines extension point. |
39 | 37 |
* |
40 | 38 |
* @return |
41 | 39 |
*/ |
42 | 40 |
public abstract boolean fetchEngines(); |
43 |
|
|
41 |
|
|
44 | 42 |
/** |
45 | 43 |
* Creates and initializes the engines from contributions with the specified extension point id. |
46 | 44 |
* |
... | ... | |
48 | 46 |
* @return true if at least one engine has been created otherwise false |
49 | 47 |
*/ |
50 | 48 |
protected boolean fetchEngines(String engineExtensionPointId) { |
51 |
|
|
49 |
|
|
52 | 50 |
IConfigurationElement[] contributions = RegistryFactory.getRegistry().getConfigurationElementsFor(engineExtensionPointId); |
53 |
|
|
51 |
|
|
54 | 52 |
Log.finest(TXMCoreMessages.bind("Looking for {0} engines contributions with extension point id {1}...", this.getEnginesDescription(), engineExtensionPointId)); //$NON-NLS-1$ |
55 | 53 |
Log.finest(TXMCoreMessages.bind("{0} engine(s) found.", contributions.length)); //$NON-NLS-1$ |
56 |
|
|
54 |
|
|
57 | 55 |
for (int i = 0; i < contributions.length; i++) { |
58 | 56 |
try { |
59 | 57 |
@SuppressWarnings("unchecked") |
60 | 58 |
T engine = (T) contributions[i].createExecutableExtension("class"); //$NON-NLS-1$ |
61 |
|
|
59 |
|
|
62 | 60 |
Log.fine(TXMCoreMessages.bind("Initializing engine: {0}...", engine)); |
63 |
|
|
61 |
|
|
64 | 62 |
if (engine.initialize()) { |
65 | 63 |
this.put(engine.getName(), engine); |
66 | 64 |
} |
... | ... | |
73 | 71 |
e.printStackTrace(); |
74 | 72 |
} |
75 | 73 |
} |
76 |
|
|
74 |
|
|
77 | 75 |
return this.size() > 0; |
78 | 76 |
} |
79 |
|
|
77 |
|
|
80 | 78 |
/** |
81 | 79 |
* Starts the engines. |
82 | 80 |
* |
... | ... | |
85 | 83 |
*/ |
86 | 84 |
public boolean startEngines(IProgressMonitor monitor) { |
87 | 85 |
for (Engine engine : this.values()) { |
88 |
|
|
86 |
|
|
89 | 87 |
String log = "Starting " + this.getEnginesDescription() + " engine: " + engine.getName() + "..."; |
90 | 88 |
Log.fine(log); |
91 |
|
|
89 |
|
|
92 | 90 |
if (monitor != null) { |
93 | 91 |
monitor.subTask(log); |
94 | 92 |
} |
95 |
|
|
93 |
|
|
96 | 94 |
try { |
97 | 95 |
engine.start(monitor); |
98 | 96 |
} |
... | ... | |
101 | 99 |
e.printStackTrace(); |
102 | 100 |
} |
103 | 101 |
} |
104 |
|
|
102 |
|
|
105 | 103 |
if (this.currentEngine == null && this.size() > 0) { |
106 | 104 |
this.setCurrentEngine((T) this.values().toArray()[0]); |
107 | 105 |
} |
108 | 106 |
return true; |
109 | 107 |
} |
110 |
|
|
108 |
|
|
111 | 109 |
@Override |
112 | 110 |
public String toString() { |
113 | 111 |
return getEnginesType() + ": " + super.toString(); |
114 | 112 |
} |
115 |
|
|
113 |
|
|
116 | 114 |
/** |
117 | 115 |
* |
118 | 116 |
* @return true if at least one engine is ready |
... | ... | |
121 | 119 |
if (currentEngine == null) { |
122 | 120 |
return false; |
123 | 121 |
} |
124 |
|
|
122 |
|
|
125 | 123 |
return currentEngine.isRunning(); |
126 | 124 |
} |
127 |
|
|
125 |
|
|
128 | 126 |
/** |
129 | 127 |
* Stops the engines. |
130 | 128 |
* |
... | ... | |
132 | 130 |
*/ |
133 | 131 |
public boolean stopEngines() { |
134 | 132 |
for (Engine engine : this.values()) { |
135 |
|
|
133 |
|
|
136 | 134 |
Log.fine("Stopping " + this.getEnginesDescription() + " engine: " + engine.getName() + "..."); //$NON-NLS-1$ |
137 |
|
|
135 |
|
|
138 | 136 |
try { |
139 | 137 |
engine.stop(); |
140 | 138 |
} |
... | ... | |
145 | 143 |
} |
146 | 144 |
return true; |
147 | 145 |
} |
148 |
|
|
146 |
|
|
149 | 147 |
/** |
150 | 148 |
* Restarts the engines. |
151 | 149 |
* |
152 | 150 |
* @return |
153 | 151 |
*/ |
154 | 152 |
public boolean restartEngines() { |
155 |
|
|
153 |
|
|
156 | 154 |
Log.finest("Restarting " + this.size() + " " + this.getEnginesDescription() + " engine(s)."); //$NON-NLS-1$ |
157 |
|
|
155 |
|
|
158 | 156 |
for (Engine engine : this.values()) { |
159 | 157 |
try { |
160 | 158 |
if (engine.isRunning()) { |
... | ... | |
173 | 171 |
} |
174 | 172 |
return true; |
175 | 173 |
} |
176 |
|
|
174 |
|
|
177 | 175 |
/** |
178 | 176 |
* Gets the engine type that this manager supports. |
179 | 177 |
* |
180 | 178 |
* @return the engine type that this manager supports |
181 | 179 |
*/ |
182 | 180 |
public abstract EngineType getEnginesType(); |
183 |
|
|
184 |
|
|
185 |
|
|
181 |
|
|
182 |
|
|
183 |
|
|
186 | 184 |
/** |
187 | 185 |
* Gets the engine description that this manager supports. |
188 | 186 |
* |
... | ... | |
191 | 189 |
public String getEnginesDescription() { |
192 | 190 |
return this.getEnginesType().getDescription(); |
193 | 191 |
} |
194 |
|
|
192 |
|
|
195 | 193 |
/** |
196 | 194 |
* Gets the available engines. |
197 | 195 |
* |
... | ... | |
200 | 198 |
public HashMap<String, T> getEngines() { |
201 | 199 |
return this; |
202 | 200 |
} |
203 |
|
|
201 |
|
|
204 | 202 |
/** |
205 | 203 |
* Gets an engine specified by its name. |
206 | 204 |
* |
... | ... | |
210 | 208 |
public T getEngine(String name) { |
211 | 209 |
return get(name); |
212 | 210 |
} |
213 |
|
|
211 |
|
|
214 | 212 |
/** |
215 | 213 |
* Returns the current engine. |
216 | 214 |
* |
... | ... | |
219 | 217 |
public T getCurrentEngine() { |
220 | 218 |
return this.currentEngine; |
221 | 219 |
} |
222 |
|
|
220 |
|
|
223 | 221 |
/** |
224 | 222 |
* Sets the current engine. |
225 | 223 |
* |
... | ... | |
229 | 227 |
Log.finest("Setting current " + this.getEnginesDescription() + " engine to " + engine + "."); |
230 | 228 |
this.currentEngine = engine; |
231 | 229 |
} |
232 |
|
|
230 |
|
|
233 | 231 |
/** |
234 | 232 |
* Sets the current engine specified by its name. |
235 | 233 |
* |
... | ... | |
238 | 236 |
public void setCurrentEngine(String name) { |
239 | 237 |
this.setCurrentEngine(this.getEngine(name)); |
240 | 238 |
} |
241 |
|
|
239 |
|
|
242 | 240 |
/** |
243 | 241 |
* Gets an installed engine according to its class type. |
244 | 242 |
* |
TXM/trunk/bundles/org.txm.conllu.core/src/org/txm/conllu/core/preferences/UDPreferences.java (revision 4007) | ||
---|---|---|
33 | 33 |
|
34 | 34 |
public static String IMPORT_BUILD_TIGERSEARCH_INDEXES = "import_build_tiger_indexes"; |
35 | 35 |
|
36 |
public static String IMPORT_PRINT_NEWLINES_AFTER_SENTENCES = "import_print_newlines_in_editions"; |
|
36 | 37 |
/** |
37 | 38 |
* Gets the instance. |
38 | 39 |
* |
... | ... | |
57 | 58 |
preferences.put(CONTRACTIONS_MANAGEMENT, SURFACE); // surface, syntax, all |
58 | 59 |
preferences.putBoolean(IMPORT_USE_NEW_DOC_ID, true); |
59 | 60 |
preferences.putBoolean(IMPORT_BUILD_TIGERSEARCH_INDEXES, true); |
61 |
preferences.putBoolean(IMPORT_PRINT_NEWLINES_AFTER_SENTENCES, true); |
|
60 | 62 |
} |
61 | 63 |
} |
TXM/trunk/bundles/org.txm.conllu.core/groovy/org/txm/scripts/importer/conllu/CoNLLUImporter.groovy (revision 4007) | ||
---|---|---|
260 | 260 |
|
261 | 261 |
def depsPropertiesToProject = UDPreferences.getInstance().getProjectPreferenceValue(project, UDPreferences.IMPORT_DEPS_TO_PROJECT, UDPreferences.getInstance().getString(UDPreferences.IMPORT_DEPS_TO_PROJECT)).split(",") as Set |
262 | 262 |
|
263 |
def printNewLines = "true" == UDPreferences.getInstance().getProjectPreferenceValue(project, UDPreferences.IMPORT_PRINT_NEWLINES_AFTER_SENTENCES, ""+UDPreferences.getInstance().getString(UDPreferences.IMPORT_PRINT_NEWLINES_AFTER_SENTENCES)) |
|
264 |
|
|
263 | 265 |
ConsoleProgressBar cpb_texts = new ConsoleProgressBar(files.size()) |
264 | 266 |
|
265 | 267 |
println "Parsing CoNLL-U files..." |
... | ... | |
428 | 430 |
writer.writeEndElement() // w |
429 | 431 |
writer.writeCharacters(" ") |
430 | 432 |
} |
433 |
|
|
434 |
if (printNewLines) writer.writeEmptyElement("lb") |
|
435 |
|
|
431 | 436 |
writer.writeCharacters("\n") |
432 | 437 |
writer.writeEndElement() // s |
433 | 438 |
} |
TXM/trunk/bundles/org.txm.groovy.core/src/java/org/txm/groovy/core/TXMClassLoader.java (revision 4007) | ||
---|---|---|
30 | 30 |
*/ |
31 | 31 |
private ClassLoader defaultLoader; |
32 | 32 |
|
33 |
|
|
34 | 33 |
/** |
35 | 34 |
* |
36 | 35 |
* @param defaultLoader |
... | ... | |
42 | 41 |
|
43 | 42 |
boolean useFastIndex = GroovyPreferences.getInstance().getBoolean(GroovyPreferences.FAST_PACKAGE_INDEX); |
44 | 43 |
|
45 |
if(useFastIndex) { |
|
44 |
if (useFastIndex) {
|
|
46 | 45 |
Log.finest("Fast package index option is activated."); //$NON-NLS-1$ |
47 | 46 |
this.packageToLoaders = new HashMap<String, HashSet<EquinoxClassLoader>>(); |
48 | 47 |
} |
... | ... | |
79 | 78 |
@Override |
80 | 79 |
public Class<?> findClass(String name) throws ClassNotFoundException { |
81 | 80 |
|
82 |
|
|
83 | 81 |
// try with the System class loader |
84 | 82 |
try { |
85 | 83 |
Class<?> c = defaultLoader.loadClass(name); |
TXM/trunk/bundles/org.txm.conllu.rcp/src/org/txm/conllu/rcp/importsection/CoNLLUSection.java (revision 4007) | ||
---|---|---|
25 | 25 |
|
26 | 26 |
private static final int SECTION_SIZE = 1; |
27 | 27 |
|
28 |
Button printNewLinesInEditionsButton; |
|
28 | 29 |
Button buildTIGERIndexesButton; |
29 | 30 |
Button useNewDocIdButton; |
30 | 31 |
RadioGroup keepWordContractionsButton; |
... | ... | |
73 | 74 |
gdata2.colspan = 4; // one line |
74 | 75 |
useNewDocIdButton.setLayoutData(gdata2); |
75 | 76 |
|
76 |
keepWordContractionsButton = new RadioGroup(sectionClient, SWT.NONE, "Multiwords management", new String[][] {{UDPreferences.MULTIWORDS, "Multiwords"}, {UDPreferences.TOKENS, "Tokens"}, {UDPreferences.ALL, "All"}});//toolkit.create toolkit.createButton(sectionClient, "Keep multiword tokens when importing CoNLL-U files", SWT.CHECK);
|
|
77 |
keepWordContractionsButton.setToolTipText("Multiwords: only the multiwords are indexed, Tokens: Only the multiwords tokens are indexed, All: both are indexed");
|
|
77 |
keepWordContractionsButton = new RadioGroup(sectionClient, SWT.NONE, "Contractions management", new String[][] {{UDPreferences.SURFACE, "Surface"}, {UDPreferences.SYNTAX, "Syntax"}, {UDPreferences.ALL, "All"}});//toolkit.create toolkit.createButton(sectionClient, "Keep multiword tokens when importing CoNLL-U files", SWT.CHECK);
|
|
78 |
keepWordContractionsButton.setToolTipText("Surface: only the surface is indexed, Syntax: Only the multiwords tokens are indexed, All: both are indexed");
|
|
78 | 79 |
gdata2 = getButtonLayoutData(); |
79 | 80 |
gdata2.colspan = 4; // one line |
80 | 81 |
keepWordContractionsButton.setLayoutData(gdata2); |
... | ... | |
106 | 107 |
gdata2 = getTextGridData(); |
107 | 108 |
gdata2.colspan = 3; // one line |
108 | 109 |
depsPropertiesText.setLayoutData(gdata2); |
110 |
|
|
111 |
printNewLinesInEditionsButton = toolkit.createButton(sectionClient, "Print a newline after a sentence in editions", SWT.CHECK); |
|
112 |
gdata2 = getButtonLayoutData(); |
|
113 |
gdata2.colspan = 4; // one line |
|
114 |
printNewLinesInEditionsButton.setLayoutData(gdata2); |
|
109 | 115 |
} |
110 | 116 |
|
111 | 117 |
@Override |
... | ... | |
116 | 122 |
Preferences customNode = project.getPreferencesScope().getNode(UDPreferences.getInstance().getPreferencesNodeQualifier()); |
117 | 123 |
|
118 | 124 |
buildTIGERIndexesButton.setSelection(customNode.getBoolean(UDPreferences.IMPORT_BUILD_TIGERSEARCH_INDEXES, UDPreferences.getInstance().getBoolean(UDPreferences.IMPORT_BUILD_TIGERSEARCH_INDEXES))); //$NON-NLS-1$ |
125 |
buildTIGERIndexesButton.setSelection(customNode.getBoolean(UDPreferences.IMPORT_PRINT_NEWLINES_AFTER_SENTENCES, UDPreferences.getInstance().getBoolean(UDPreferences.IMPORT_PRINT_NEWLINES_AFTER_SENTENCES))); //$NON-NLS-1$ |
|
119 | 126 |
useNewDocIdButton.setSelection(customNode.getBoolean(UDPreferences.IMPORT_USE_NEW_DOC_ID, UDPreferences.getInstance().getBoolean(UDPreferences.IMPORT_USE_NEW_DOC_ID))); //$NON-NLS-1$ |
120 |
keepWordContractionsButton.setSelection(customNode.get(UDPreferences.MULTIWORDS_MANAGEMENT, UDPreferences.getInstance().getString(UDPreferences.MULTIWORDS_MANAGEMENT))); //$NON-NLS-1$
|
|
127 |
keepWordContractionsButton.setSelection(customNode.get(UDPreferences.CONTRACTIONS_MANAGEMENT, UDPreferences.getInstance().getString(UDPreferences.CONTRACTIONS_MANAGEMENT))); //$NON-NLS-1$
|
|
121 | 128 |
udPropertiesPrefixButton.setText(customNode.get(UDPreferences.UDPREFIX, UDPreferences.getInstance().getString(UDPreferences.UDPREFIX))); //$NON-NLS-1$ |
122 | 129 |
headPropertiesText.setText(customNode.get(UDPreferences.IMPORT_HEAD_TO_PROJECT, UDPreferences.getInstance().getString(UDPreferences.IMPORT_HEAD_TO_PROJECT))); //$NON-NLS-1$ |
123 | 130 |
depsPropertiesText.setText(customNode.get(UDPreferences.IMPORT_DEPS_TO_PROJECT, UDPreferences.getInstance().getString(UDPreferences.IMPORT_DEPS_TO_PROJECT))); //$NON-NLS-1$ |
... | ... | |
129 | 136 |
|
130 | 137 |
Preferences customNode = project.getPreferencesScope().getNode(UDPreferences.getInstance().getPreferencesNodeQualifier()); |
131 | 138 |
customNode.putBoolean(UDPreferences.IMPORT_BUILD_TIGERSEARCH_INDEXES, buildTIGERIndexesButton.getSelection()); |
139 |
customNode.putBoolean(UDPreferences.IMPORT_PRINT_NEWLINES_AFTER_SENTENCES, printNewLinesInEditionsButton.getSelection()); |
|
132 | 140 |
customNode.putBoolean(UDPreferences.IMPORT_USE_NEW_DOC_ID, useNewDocIdButton.getSelection()); |
133 |
customNode.put(UDPreferences.MULTIWORDS_MANAGEMENT, keepWordContractionsButton.getSelection());
|
|
141 |
customNode.put(UDPreferences.CONTRACTIONS_MANAGEMENT, keepWordContractionsButton.getSelection());
|
|
134 | 142 |
customNode.put(UDPreferences.UDPREFIX, udPropertiesPrefixButton.getText()); |
135 | 143 |
customNode.put(UDPreferences.IMPORT_HEAD_TO_PROJECT, headPropertiesText.getText()); |
136 | 144 |
customNode.put(UDPreferences.IMPORT_DEPS_TO_PROJECT, depsPropertiesText.getText()); |
TXM/trunk/bundles/org.txm.conllu.rcp/src/org/txm/conllu/rcp/preferences/CoNLLUPreferencePage.java (revision 4007) | ||
---|---|---|
26 | 26 |
this.addField(new BooleanFieldEditor(UDPreferences.IMPORT_USE_NEW_DOC_ID, "Use new odc id when importing CoNLL-U files", this.getFieldEditorParent())); |
27 | 27 |
this.addField(new BooleanFieldEditor(UDPreferences.IMPORT_BUILD_TIGERSEARCH_INDEXES, "Build TIGERSearch indexes as well", this.getFieldEditorParent())); |
28 | 28 |
|
29 |
this.addField(new BooleanFieldEditor(UDPreferences.MULTIWORDS_MANAGEMENT, "Keep multiword tokens when importing CoNLL-U files", this.getFieldEditorParent()));
|
|
29 |
this.addField(new BooleanFieldEditor(UDPreferences.CONTRACTIONS_MANAGEMENT, "Keep multiword tokens when importing CoNLL-U files", this.getFieldEditorParent()));
|
|
30 | 30 |
udPrefixField = new StringFieldEditor(UDPreferences.UDPREFIX, "UD properties prefix", this.getFieldEditorParent()); |
31 | 31 |
this.addField(udPrefixField); |
32 | 32 |
this.addField(new StringFieldEditor(UDPreferences.IMPORT_HEAD_TO_PROJECT, "UD head properties to project (comma separated list)", this.getFieldEditorParent())); |
TXM/trunk/bundles/org.txm.libs.deptreeviz/src/org/txm/libs/deptreeviz/UDDepTreeVizPrintTree.java (revision 4007) | ||
---|---|---|
21 | 21 |
|
22 | 22 |
|
23 | 23 |
|
24 |
// Fixing multiwords 6th position if equals to "_" |
|
25 | 24 |
ArrayList<String> conll2 = new ArrayList<>(); |
26 | 25 |
for (int i = 0 ; i < conll.size() ; i++) { |
27 | 26 |
String l = conll.get(i); |
... | ... | |
35 | 34 |
// } |
36 | 35 |
// } |
37 | 36 |
// |
38 |
if (split[6].equals("_")) { // 6th col is broken and we don't have the tokens of the multiwords
|
|
37 |
if (split[6].equals("_")) { |
|
39 | 38 |
//split[6] = "0"; |
40 | 39 |
continue; |
41 | 40 |
} |
Formats disponibles : Unified diff