Révision 1094
| tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/handlers/ComputeCooccurrences.java (revision 1094) | ||
|---|---|---|
| 41 | 41 |
import org.txm.rcp.editors.TXMEditor; |
| 42 | 42 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
| 43 | 43 |
import org.txm.rcp.messages.TXMUIMessages; |
| 44 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 44 |
import org.txm.searchengine.cqp.corpus.CQPCorpus;
|
|
| 45 | 45 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
| 46 | 46 |
import org.txm.searchengine.cqp.corpus.WordProperty; |
| 47 | 47 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
| ... | ... | |
| 98 | 98 |
List<WordProperty> properties = null; |
| 99 | 99 |
|
| 100 | 100 |
Concordance conc = (Concordance) selection; |
| 101 |
Corpus corpus = conc.getCorpus(); |
|
| 101 |
CQPCorpus corpus = conc.getCorpus();
|
|
| 102 | 102 |
maxleft = conc.getLeftContextSize(); |
| 103 | 103 |
maxright = conc.getRightContextSize(); |
| 104 | 104 |
properties = new ArrayList<WordProperty>(); |
| ... | ... | |
| 116 | 116 |
|
| 117 | 117 |
} |
| 118 | 118 |
// Creating from Corpus |
| 119 |
else if (selection instanceof Corpus) {
|
|
| 120 |
cooc = new Cooccurrence((Corpus) selection); |
|
| 119 |
else if (selection instanceof CQPCorpus) {
|
|
| 120 |
cooc = new Cooccurrence((CQPCorpus) selection);
|
|
| 121 | 121 |
} |
| 122 | 122 |
// Reopening an existing result |
| 123 | 123 |
else if (selection instanceof Cooccurrence) {
|
| tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/handlers/___CooccurrencesToConcordances.java (revision 1094) | ||
|---|---|---|
| 42 | 42 |
import org.txm.cooccurrence.core.functions.Cooccurrence.CLine; |
| 43 | 43 |
import org.txm.cooccurrence.rcp.editors.CooccurrencesEditor; |
| 44 | 44 |
import org.txm.rcp.editors.TXMResultEditorInput; |
| 45 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 45 |
import org.txm.searchengine.cqp.corpus.CQPCorpus;
|
|
| 46 | 46 |
import org.txm.searchengine.cqp.corpus.WordProperty; |
| 47 | 47 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
| 48 | 48 |
|
| ... | ... | |
| 115 | 115 |
|
| 116 | 116 |
query = "("+cooc.getQuery()+" []* "+query+") | ("+query+" []* "+cooc.getQuery()+") "+maxempanstr; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
| 117 | 117 |
|
| 118 |
Corpus corpus = cooc.getCorpus(); |
|
| 118 |
CQPCorpus corpus = cooc.getCorpus();
|
|
| 119 | 119 |
Concordance concordance = new Concordance(corpus); |
| 120 | 120 |
concordance.setParameters(new CQLQuery(query), null, null, null, null, null, null, null, null, null, null); |
| 121 | 121 |
editorInput = new TXMResultEditorInput(concordance); |
| tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/editors/CooccurrencesEditor.java (revision 1094) | ||
|---|---|---|
| 32 | 32 |
import java.util.List; |
| 33 | 33 |
|
| 34 | 34 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 35 |
import org.eclipse.jface.action.MenuManager; |
|
| 35 | 36 |
import org.eclipse.jface.operation.IRunnableWithProgress; |
| 36 | 37 |
import org.eclipse.jface.viewers.TableViewer; |
| 37 | 38 |
import org.eclipse.osgi.util.NLS; |
| 38 | 39 |
import org.eclipse.swt.SWT; |
| 40 |
import org.eclipse.swt.custom.ScrolledComposite; |
|
| 41 |
import org.eclipse.swt.events.KeyEvent; |
|
| 42 |
import org.eclipse.swt.events.KeyListener; |
|
| 39 | 43 |
import org.eclipse.swt.events.SelectionEvent; |
| 40 | 44 |
import org.eclipse.swt.events.SelectionListener; |
| 41 | 45 |
import org.eclipse.swt.graphics.Font; |
| ... | ... | |
| 49 | 53 |
import org.eclipse.swt.layout.RowLayout; |
| 50 | 54 |
import org.eclipse.swt.widgets.Composite; |
| 51 | 55 |
import org.eclipse.swt.widgets.Display; |
| 56 |
import org.eclipse.swt.widgets.Event; |
|
| 52 | 57 |
import org.eclipse.swt.widgets.Label; |
| 58 |
import org.eclipse.swt.widgets.Listener; |
|
| 59 |
import org.eclipse.swt.widgets.Menu; |
|
| 53 | 60 |
import org.eclipse.swt.widgets.Spinner; |
| 54 | 61 |
import org.eclipse.swt.widgets.TableColumn; |
| 62 |
import org.eclipse.swt.widgets.Text; |
|
| 55 | 63 |
import org.eclipse.ui.IEditorInput; |
| 56 | 64 |
import org.eclipse.ui.IEditorSite; |
| 57 | 65 |
import org.eclipse.ui.PartInitException; |
| 58 | 66 |
import org.eclipse.ui.PlatformUI; |
| 67 |
import org.txm.concordance.core.preferences.ConcordancePreferences; |
|
| 59 | 68 |
import org.txm.cooccurrence.core.functions.Cooccurrence; |
| 60 | 69 |
import org.txm.cooccurrence.core.functions.comparators.CLineComparator; |
| 61 | 70 |
import org.txm.cooccurrence.core.functions.comparators.DistComparator; |
| ... | ... | |
| 74 | 83 |
import org.txm.rcp.editors.TXMResultEditorInput; |
| 75 | 84 |
import org.txm.rcp.editors.TableKeyListener; |
| 76 | 85 |
import org.txm.rcp.editors.listeners.ComputeKeyListener; |
| 86 |
import org.txm.rcp.editors.listeners.ComputeListener; |
|
| 77 | 87 |
import org.txm.rcp.editors.listeners.ComputeSelectionListener; |
| 88 |
import org.txm.rcp.messages.TXMUIMessages; |
|
| 89 |
import org.txm.rcp.preferences.RCPPreferences; |
|
| 78 | 90 |
import org.txm.rcp.swt.widget.AssistedQueryWidget; |
| 79 | 91 |
import org.txm.rcp.swt.widget.FloatSpinner; |
| 80 | 92 |
import org.txm.rcp.swt.widget.PropertiesSelector; |
| 81 | 93 |
import org.txm.rcp.views.QueriesView; |
| 82 | 94 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 83 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 95 |
import org.txm.searchengine.cqp.corpus.CQPCorpus;
|
|
| 84 | 96 |
import org.txm.searchengine.cqp.corpus.Property; |
| 85 | 97 |
import org.txm.searchengine.cqp.corpus.WordProperty; |
| 86 | 98 |
import org.txm.statsengine.r.rcp.views.RVariablesView; |
| ... | ... | |
| 131 | 143 |
|
| 132 | 144 |
// params |
| 133 | 145 |
/** The query widget. */ |
| 134 |
@Parameter(key=TXMPreferences.QUERY)
|
|
| 146 |
@Parameter(key=CooccurrencePreferences.QUERY)
|
|
| 135 | 147 |
AssistedQueryWidget queryWidget; |
| 136 | 148 |
|
| 137 | 149 |
/** The props area. */ |
| ... | ... | |
| 150 | 162 |
@Parameter(key=CooccurrencePreferences.MIN_SCORE) |
| 151 | 163 |
FloatSpinner minScore; |
| 152 | 164 |
|
| 153 |
|
|
| 154 | 165 |
|
| 166 |
|
|
| 155 | 167 |
/** |
| 156 | 168 |
* Initialize the editor with the cooccurrences TXMResult |
| 157 | 169 |
* |
| ... | ... | |
| 335 | 347 |
|
| 336 | 348 |
// empant |
| 337 | 349 |
empantPanel = new EmpantWidget(paramArea, SWT.NONE, this.getCorpus()); |
| 350 |
|
|
| 338 | 351 |
FormData empantLayoutData = new FormData(); |
| 339 | 352 |
empantLayoutData.top = new FormAttachment(filtercontrols, 0); |
| 340 | 353 |
empantLayoutData.bottom = new FormAttachment(100); |
| ... | ... | |
| 582 | 595 |
* |
| 583 | 596 |
* @return the corpus |
| 584 | 597 |
*/ |
| 585 |
public Corpus getCorpus() {
|
|
| 598 |
public CQPCorpus getCorpus() {
|
|
| 586 | 599 |
return cooc.getCorpus(); |
| 587 | 600 |
} |
| 588 | 601 |
|
| tmp/org.txm.cooccurrence.rcp/src/org/txm/cooccurrence/rcp/editors/EmpantWidget.java (revision 1094) | ||
|---|---|---|
| 39 | 39 |
import org.eclipse.swt.widgets.Spinner; |
| 40 | 40 |
import org.txm.rcp.messages.TXMUIMessages; |
| 41 | 41 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 42 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 42 |
import org.txm.searchengine.cqp.corpus.CQPCorpus;
|
|
| 43 | 43 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
| 44 | 44 |
|
| 45 | 45 |
// TODO: Auto-generated Javadoc |
| ... | ... | |
| 82 | 82 |
Label infoLabel; |
| 83 | 83 |
|
| 84 | 84 |
/** The corpus. */ |
| 85 |
Corpus corpus; |
|
| 85 |
CQPCorpus corpus;
|
|
| 86 | 86 |
|
| 87 | 87 |
/** |
| 88 | 88 |
* Instantiates a new empant widget. |
| ... | ... | |
| 91 | 91 |
* @param style the style |
| 92 | 92 |
* @param corpus the corpus |
| 93 | 93 |
*/ |
| 94 |
public EmpantWidget(Composite parent, int style, Corpus corpus) {
|
|
| 94 |
public EmpantWidget(Composite parent, int style, CQPCorpus corpus) {
|
|
| 95 | 95 |
super(parent, style); |
| 96 | 96 |
this.corpus = corpus; |
| 97 | 97 |
GridLayout mainLayout = new GridLayout(1, true); |
| tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/KRAnnotationEngine.java (revision 1094) | ||
|---|---|---|
| 2 | 2 |
|
| 3 | 3 |
import java.io.File; |
| 4 | 4 |
import java.util.ArrayList; |
| 5 |
import java.util.Arrays; |
|
| 5 | 6 |
import java.util.HashMap; |
| 6 | 7 |
import java.util.List; |
| 7 | 8 |
|
| 8 | 9 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 10 |
import org.osgi.service.prefs.BackingStoreException; |
|
| 9 | 11 |
import org.txm.annotation.core.AnnotationEngine; |
| 10 | 12 |
import org.txm.annotation.kr.core.repository.KnowledgeRepository; |
| 11 | 13 |
import org.txm.annotation.kr.core.repository.KnowledgeRepositoryManager; |
| 12 | 14 |
import org.txm.annotation.kr.core.repository.SQLKnowledgeRepository; |
| 13 | 15 |
import org.txm.objects.Project; |
| 14 |
import org.txm.objects.BaseParameters; |
|
| 15 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 16 |
import org.txm.objects.BaseOldParameters;
|
|
| 17 |
import org.txm.searchengine.cqp.corpus.CQPCorpus;
|
|
| 16 | 18 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
| 17 | 19 |
import org.txm.sql.SQLConnection; |
| 18 | 20 |
import org.txm.utils.logger.Log; |
| ... | ... | |
| 33 | 35 |
return getKnowledgeRepositoryNames(corpus).size() > 0; |
| 34 | 36 |
} |
| 35 | 37 |
|
| 36 |
public static AnnotationManager getAnnotationManager(Corpus corpus) throws Exception{
|
|
| 38 |
public static AnnotationManager getAnnotationManager(CQPCorpus corpus) throws Exception{
|
|
| 37 | 39 |
return getAnnotationManager(corpus.getMainCorpus()); |
| 38 | 40 |
} |
| 39 | 41 |
|
| ... | ... | |
| 75 | 77 |
* @param name KnowledgeRepository's name |
| 76 | 78 |
* @return may return null if the KnowledgeRepository does not exist |
| 77 | 79 |
*/ |
| 78 |
public static KnowledgeRepository getKnowledgeRepository(Corpus corpus, String name) {
|
|
| 80 |
public static KnowledgeRepository getKnowledgeRepository(CQPCorpus corpus, String name) {
|
|
| 79 | 81 |
return KnowledgeRepositoryManager.getKnowledgeRepository(name, corpus.getMainCorpus()); |
| 80 | 82 |
} |
| 81 | 83 |
|
| ... | ... | |
| 166 | 168 |
return repConfiguration; |
| 167 | 169 |
} |
| 168 | 170 |
|
| 169 |
public static Element getKnowledgeRepositoryElement(BaseParameters params, String name) {
|
|
| 171 |
public static Element getKnowledgeRepositoryElement(BaseOldParameters params, String name) {
|
|
| 170 | 172 |
Element rElement = getKnowledgeRepositoriesElement(params.getCorpusElement()); |
| 171 | 173 |
NodeList repositoriesList = rElement.getElementsByTagName("repository");
|
| 172 | 174 |
for (int i = 0 ; i < repositoriesList.getLength() ; i++) {
|
| ... | ... | |
| 186 | 188 |
* @param params |
| 187 | 189 |
* @return the repository names |
| 188 | 190 |
*/ |
| 189 |
public static List<String> getKnowledgeRepositoryNames(BaseParameters params) {
|
|
| 191 |
public static List<String> getKnowledgeRepositoryNames(BaseOldParameters params) {
|
|
| 190 | 192 |
ArrayList<String> names = new ArrayList<String>(); |
| 191 | 193 |
Element corpusElement = params.getCorpusElement(); |
| 192 | 194 |
if (corpusElement == null) return names; |
| ... | ... | |
| 208 | 210 |
* @param corpus the corpus |
| 209 | 211 |
* @return the repository names |
| 210 | 212 |
*/ |
| 211 |
public static List<String> getKnowledgeRepositoryNames(Corpus corpus) {
|
|
| 213 |
public static List<String> getKnowledgeRepositoryNames(CQPCorpus corpus) {
|
|
| 212 | 214 |
if (corpus == null) return new ArrayList<String>(); |
| 213 | 215 |
Project base = corpus.getProject(); |
| 214 | 216 |
if (base == null) return new ArrayList<String>(); |
| 215 |
BaseParameters params = base.getProjectParameters(); |
|
| 216 |
return getKnowledgeRepositoryNames(params); |
|
| 217 |
String[] names; |
|
| 218 |
try {
|
|
| 219 |
names = base.getPreferences().getNode("KnowledgeRepository").node("names").keys();
|
|
| 220 |
return Arrays.asList(names); // getKnowledgeRepositoryNames(params); |
|
| 221 |
} catch (BackingStoreException e) {
|
|
| 222 |
e.printStackTrace(); |
|
| 223 |
return new ArrayList<>(); |
|
| 224 |
} |
|
| 217 | 225 |
} |
| 218 | 226 |
|
| 219 | 227 |
/** |
| ... | ... | |
| 237 | 245 |
} |
| 238 | 246 |
} |
| 239 | 247 |
|
| 240 |
public static Element createKnowledgeRepositoryElement(BaseParameters params, String name) {
|
|
| 248 |
public static Element createKnowledgeRepositoryElement(BaseOldParameters params, String name) {
|
|
| 241 | 249 |
Element rElement = getKnowledgeRepositoriesElement(params.getCorpusElement()); |
| 242 | 250 |
Element e = rElement.getOwnerDocument().createElement("repository");
|
| 243 | 251 |
e.setAttribute("name", name);
|
| ... | ... | |
| 266 | 274 |
} |
| 267 | 275 |
|
| 268 | 276 |
@SuppressWarnings("unchecked")
|
| 269 |
public boolean[] mustLoginToKnowledgeRepository(Corpus corpus, String kr_name) {
|
|
| 277 |
public boolean[] mustLoginToKnowledgeRepository(CQPCorpus corpus, String kr_name) {
|
|
| 270 | 278 |
return KnowledgeRepositoryManager.mustLoginToKnowledgeRepository(kr_name, corpus.getMainCorpus()); |
| 271 | 279 |
} |
| 272 | 280 |
|
| tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/repository/KnowledgeRepositoryManager.java (revision 1094) | ||
|---|---|---|
| 12 | 12 |
import org.txm.annotation.kr.core.DatabasePersistenceManager; |
| 13 | 13 |
import org.txm.annotation.kr.core.KRAnnotationEngine; |
| 14 | 14 |
import org.txm.core.preferences.TBXPreferences; |
| 15 |
import org.txm.objects.BaseParameters; |
|
| 15 |
import org.txm.objects.BaseOldParameters;
|
|
| 16 | 16 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
| 17 | 17 |
import org.txm.sql.SQLConnection; |
| 18 | 18 |
import org.txm.utils.logger.Log; |
| ... | ... | |
| 154 | 154 |
} |
| 155 | 155 |
} |
| 156 | 156 |
|
| 157 |
BaseParameters bp = corpus.getProject().getProjectParameters(); |
|
| 157 |
//FIXME read KR configuration from Project preferences |
|
| 158 |
BaseOldParameters bp = null;//corpus.getProject().getProjectParameters(); |
|
| 158 | 159 |
Element krCorpusElement = KRAnnotationEngine.getKnowledgeRepositoryElement(bp, name); |
| 159 | 160 |
if (krCorpusElement == null) krCorpusElement = KRAnnotationEngine.createKnowledgeRepositoryElement(bp, name); |
| 160 | 161 |
String sKRCorpusVersion = krCorpusElement.getAttribute("version");
|
| tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationWriter.java (revision 1094) | ||
|---|---|---|
| 87 | 87 |
*/ |
| 88 | 88 |
public boolean writeAnnotationsInStandoff(File resultZipFile) throws IOException, CqiServerError, CqiClientException, InvalidCqpIdException, XMLStreamException{
|
| 89 | 89 |
|
| 90 |
List<String> textsIds = corpus.getTextsID(); |
|
| 90 |
List<String> textsIds = corpus.getProject().getTextsID();
|
|
| 91 | 91 |
System.out.println("Exporting annotations of "+StringUtils.join(textsIds, ", ")+".");
|
| 92 | 92 |
|
| 93 | 93 |
File resultDirectory = new File(Toolbox.getTxmHomePath(), "results/"+corpus.getName()+"_annotations"); |
| ... | ... | |
| 138 | 138 |
|
| 139 | 139 |
int[] end_limits = corpus.getTextEndLimits(); |
| 140 | 140 |
int[] start_limits = corpus.getTextStartLimits(); |
| 141 |
List<String> textsIds = corpus.getTextsID(); |
|
| 141 |
List<String> textsIds = corpus.getProject().getTextsID();
|
|
| 142 | 142 |
|
| 143 | 143 |
File inputDirectory = corpus.getProjectDirectory(); |
| 144 | 144 |
File txmDirectory = new File(inputDirectory, "txm/"+corpus.getName()); |
| tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationInjector.java (revision 1094) | ||
|---|---|---|
| 13 | 13 |
import javax.xml.stream.XMLInputFactory; |
| 14 | 14 |
import javax.xml.stream.XMLStreamException; |
| 15 | 15 |
|
| 16 |
import org.txm.Toolbox; |
|
| 16 | 17 |
import org.txm.importer.StaxIdentityParser; |
| 17 | 18 |
import org.txm.importer.ValidateXml; |
| 18 |
import org.txm.objects.BaseParameters; |
|
| 19 | 19 |
|
| 20 | 20 |
/** |
| 21 | 21 |
* The Class AnnotationInjection. |
| ... | ... | |
| 465 | 465 |
writer.writeStartElement("txm:" + a.getType());
|
| 466 | 466 |
writer.writeAttribute("author", "" + a.getAnnotator());
|
| 467 | 467 |
writer.writeAttribute("ref", a.getValue());
|
| 468 |
writer.writeAttribute("date", BaseParameters.dateformat.format(new Date()));
|
|
| 468 |
writer.writeAttribute("date", Toolbox.dateformat.format(new Date()));
|
|
| 469 | 469 |
writer.writeAttribute("start", Integer.toString(a.getStart()));
|
| 470 | 470 |
writer.writeAttribute("end", Integer.toString(a.getEnd()));
|
| 471 | 471 |
} catch (XMLStreamException e) {
|
| tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/Annotation.java (revision 1094) | ||
|---|---|---|
| 7 | 7 |
|
| 8 | 8 |
import javax.persistence.*; |
| 9 | 9 |
|
| 10 |
import org.txm.Toolbox; |
|
| 10 | 11 |
import org.txm.annotation.kr.core.repository.KnowledgeRepository; |
| 11 |
import org.txm.objects.BaseParameters; |
|
| 12 | 12 |
|
| 13 | 13 |
@Entity |
| 14 | 14 |
public class Annotation implements Serializable {
|
| ... | ... | |
| 33 | 33 |
public Annotation(String refType, String refVal, int CQPstartpos, int CQPendpos) {
|
| 34 | 34 |
this.PK = new AnnotationPK(CQPstartpos, CQPendpos, refType); |
| 35 | 35 |
this.refVal = refVal; |
| 36 |
this.date = BaseParameters.dateformat.format(new Date());
|
|
| 36 |
this.date = Toolbox.dateformat.format(new Date());
|
|
| 37 | 37 |
|
| 38 | 38 |
String s = System.getProperty(KnowledgeRepository.LOGIN_KEY); |
| 39 | 39 |
if (s != null && s.length() > 0) {
|
| tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/handlers/ComputeTextsBalance.java (revision 1094) | ||
|---|---|---|
| 32 | 32 |
import org.txm.chartsengine.rcp.editors.ChartEditor; |
| 33 | 33 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
| 34 | 34 |
import org.txm.rcp.views.corpora.CorporaView; |
| 35 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 35 |
import org.txm.searchengine.cqp.corpus.CQPCorpus;
|
|
| 36 | 36 |
import org.txm.textsbalance.core.functions.TextsBalance; |
| 37 | 37 |
|
| 38 | 38 |
/** |
| ... | ... | |
| 52 | 52 |
TextsBalance textsBalance = null; |
| 53 | 53 |
|
| 54 | 54 |
// creates new result |
| 55 |
if(selection instanceof Corpus) {
|
|
| 56 |
textsBalance = new TextsBalance((Corpus) selection); |
|
| 55 |
if(selection instanceof CQPCorpus) {
|
|
| 56 |
textsBalance = new TextsBalance((CQPCorpus) selection);
|
|
| 57 | 57 |
} |
| 58 | 58 |
// reopens existing result |
| 59 | 59 |
else if(selection instanceof TextsBalance) {
|
| tmp/org.txm.progression.core/src/org/txm/progression/core/functions/Progression.java (revision 1094) | ||
|---|---|---|
| 48 | 48 |
import org.txm.progression.core.messages.ProgressionCoreMessages; |
| 49 | 49 |
import org.txm.progression.core.preferences.ProgressionPreferences; |
| 50 | 50 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 51 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 51 |
import org.txm.searchengine.cqp.corpus.CQPCorpus;
|
|
| 52 | 52 |
import org.txm.searchengine.cqp.corpus.CorpusManager; |
| 53 | 53 |
import org.txm.searchengine.cqp.corpus.Property; |
| 54 | 54 |
import org.txm.searchengine.cqp.corpus.QueryResult; |
| 55 | 55 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
| 56 | 56 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
| 57 | 57 |
import org.txm.searchengine.cqp.corpus.Subcorpus; |
| 58 |
import org.txm.searchengine.cqp.corpus.query.Match; |
|
| 58 | 59 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
| 59 |
import org.txm.searchengine.cqp.corpus.query.Match; |
|
| 60 | 60 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
| 61 | 61 |
import org.txm.utils.logger.Log; |
| 62 | 62 |
|
| ... | ... | |
| 149 | 149 |
* |
| 150 | 150 |
* @param parent |
| 151 | 151 |
*/ |
| 152 |
public Progression(Corpus parent) {
|
|
| 152 |
public Progression(CQPCorpus parent) {
|
|
| 153 | 153 |
super(parent); |
| 154 | 154 |
} |
| 155 | 155 |
|
| ... | ... | |
| 337 | 337 |
* @param corpus |
| 338 | 338 |
* @return |
| 339 | 339 |
*/ |
| 340 |
public static boolean canRunProgression(Corpus corpus) {
|
|
| 340 |
public static boolean canRunProgression(CQPCorpus corpus) {
|
|
| 341 | 341 |
if (corpus.getMatches().size() == 1) {
|
| 342 | 342 |
return true; |
| 343 | 343 |
} |
| ... | ... | |
| 591 | 591 |
* |
| 592 | 592 |
* @return the corpus |
| 593 | 593 |
*/ |
| 594 |
public Corpus getCorpus() {
|
|
| 595 |
return (Corpus) this.parent; |
|
| 594 |
public CQPCorpus getCorpus() {
|
|
| 595 |
return (CQPCorpus) this.parent;
|
|
| 596 | 596 |
} |
| 597 | 597 |
|
| 598 | 598 |
/** |
| tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesEditor.java (revision 1094) | ||
|---|---|---|
| 46 | 46 |
import org.txm.rcp.editors.TableKeyListener; |
| 47 | 47 |
import org.txm.rcp.swt.GLComposite; |
| 48 | 48 |
import org.txm.rcp.swt.widget.structures.PropertiesComboViewer; |
| 49 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 49 |
import org.txm.searchengine.cqp.corpus.CQPCorpus;
|
|
| 50 | 50 |
import org.txm.specificities.core.functions.Specificities; |
| 51 | 51 |
import org.txm.specificities.core.preferences.SpecificitiesPreferences; |
| 52 | 52 |
import org.txm.specificities.rcp.messages.SpecificitiesUIMessages; |
| ... | ... | |
| 97 | 97 |
public void _createPartControl() {
|
| 98 | 98 |
|
| 99 | 99 |
try {
|
| 100 |
|
|
| 101 | 100 |
// Main parameters |
| 102 | 101 |
GLComposite mainParametersArea = this.getMainParametersComposite(); |
| 103 | 102 |
mainParametersArea.getLayout().numColumns = 2; |
| ... | ... | |
| 105 | 104 |
// unit property |
| 106 | 105 |
new Label(mainParametersArea, SWT.NONE).setText(TXMCoreMessages.common_property); |
| 107 | 106 |
this.unitPropertyComboViewer = new PropertiesComboViewer(mainParametersArea, this, true, |
| 108 |
Corpus.getFirstParentCorpus(this.getResult()).getOrderedProperties(), |
|
| 107 |
CQPCorpus.getFirstParentCorpus(this.getResult()).getOrderedProperties(),
|
|
| 109 | 108 |
this.getResult().getUnitProperty(), false); |
| 110 | 109 |
|
| 111 | 110 |
|
| tmp/org.txm.querycooccurrences.rcp/src/org/txm/links/coocmatrix/toCA.java (revision 1094) | ||
|---|---|---|
| 4 | 4 |
import org.txm.functions.coocmatrix.QueryCooccurrence; |
| 5 | 5 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
| 6 | 6 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 7 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 7 |
import org.txm.searchengine.cqp.corpus.CQPCorpus;
|
|
| 8 | 8 |
import org.txm.searchengine.cqp.corpus.Property; |
| 9 | 9 |
import org.txm.statsengine.core.StatException; |
| 10 | 10 |
|
| ... | ... | |
| 17 | 17 |
* @throws CqiClientException |
| 18 | 18 |
*/ |
| 19 | 19 |
public static CA link(QueryCooccurrence coocs) throws StatException, CqiClientException {
|
| 20 |
Corpus corpus = coocs.getCorpus(); |
|
| 20 |
CQPCorpus corpus = coocs.getCorpus();
|
|
| 21 | 21 |
Property analysisProperty = null; |
| 22 | 22 |
try {
|
| 23 | 23 |
analysisProperty = coocs.getCorpus().getProperty("word"); //$NON-NLS-1$
|
| tmp/org.txm.querycooccurrences.rcp/src/org/txm/rcp/commands/function/ComputeQueryAutoCooccurrence.java (revision 1094) | ||
|---|---|---|
| 64 | 64 |
import org.txm.rcp.views.corpora.CorporaView; |
| 65 | 65 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
| 66 | 66 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 67 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 67 |
import org.txm.searchengine.cqp.corpus.CQPCorpus;
|
|
| 68 | 68 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
| 69 | 69 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
| 70 | 70 |
import org.txm.stat.utils.ConsoleProgressBar; |
| ... | ... | |
| 103 | 103 |
return Status.CANCEL_STATUS; |
| 104 | 104 |
} |
| 105 | 105 |
QueryIndex qi = ((QueryIndex)element); |
| 106 |
Corpus corpus = qi.getCorpus(); |
|
| 106 |
CQPCorpus corpus = qi.getCorpus();
|
|
| 107 | 107 |
|
| 108 | 108 |
final CoocMatrixDialog dialog = new ComputeQueryAutoCooccurrence.CoocMatrixDialog(shell, corpus); |
| 109 | 109 |
syncExec(new Runnable() {
|
| ... | ... | |
| 150 | 150 |
} |
| 151 | 151 |
|
| 152 | 152 |
|
| 153 |
private QueryAutoCooccurrence computeCooc(Shell shell, Corpus corpus, QueryIndex element, CoocMatrixDialog dialog) {
|
|
| 153 |
private QueryAutoCooccurrence computeCooc(Shell shell, CQPCorpus corpus, QueryIndex element, CoocMatrixDialog dialog) {
|
|
| 154 | 154 |
ArrayList<CQLQuery> queries = new ArrayList<CQLQuery>(); |
| 155 | 155 |
ArrayList<String> names = new ArrayList<String>(); |
| 156 | 156 |
|
| ... | ... | |
| 194 | 194 |
} |
| 195 | 195 |
|
| 196 | 196 |
public class CoocMatrixDialog extends Dialog {
|
| 197 |
Corpus corpus; |
|
| 197 |
CQPCorpus corpus;
|
|
| 198 | 198 |
|
| 199 | 199 |
org.eclipse.swt.widgets.List propsCombo; |
| 200 | 200 |
Spinner distSpinner; |
| ... | ... | |
| 209 | 209 |
|
| 210 | 210 |
private Button orientedButton; |
| 211 | 211 |
|
| 212 |
public CoocMatrixDialog(Shell parentShell, Corpus corpus) {
|
|
| 212 |
public CoocMatrixDialog(Shell parentShell, CQPCorpus corpus) {
|
|
| 213 | 213 |
super(parentShell); |
| 214 | 214 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE); |
| 215 | 215 |
this.corpus = corpus; |
| tmp/org.txm.querycooccurrences.rcp/src/org/txm/rcp/commands/function/ComputeQueryCooccurrence.java (revision 1094) | ||
|---|---|---|
| 67 | 67 |
import org.txm.rcp.views.corpora.CorporaView; |
| 68 | 68 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
| 69 | 69 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 70 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 70 |
import org.txm.searchengine.cqp.corpus.CQPCorpus;
|
|
| 71 | 71 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
| 72 | 72 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
| 73 | 73 |
import org.txm.statsengine.r.rcp.views.RVariablesView; |
| ... | ... | |
| 100 | 100 |
try {
|
| 101 | 101 |
JobsTimer.start(); |
| 102 | 102 |
|
| 103 |
if (!(element instanceof Corpus)) {
|
|
| 103 |
if (!(element instanceof CQPCorpus)) {
|
|
| 104 | 104 |
System.out.println(TXMUIMessages.ComputeCooccurrences_1+ element); |
| 105 | 105 |
return Status.CANCEL_STATUS; |
| 106 | 106 |
} |
| 107 |
Corpus corpus = ((Corpus)element);
|
|
| 107 |
CQPCorpus corpus = ((CQPCorpus)element);
|
|
| 108 | 108 |
|
| 109 | 109 |
final CoocMatrixDialog dialog = new ComputeQueryCooccurrence.CoocMatrixDialog(shell, corpus); |
| 110 | 110 |
syncExec(new Runnable() {
|
| ... | ... | |
| 151 | 151 |
} |
| 152 | 152 |
|
| 153 | 153 |
|
| 154 |
private QueryCooccurrence computeCooc(Shell shell, Corpus corpus, CoocMatrixDialog dialog) throws IOException {
|
|
| 154 |
private QueryCooccurrence computeCooc(Shell shell, CQPCorpus corpus, CoocMatrixDialog dialog) throws IOException {
|
|
| 155 | 155 |
ArrayList<CQLQuery> queries1 = new ArrayList<CQLQuery>(); |
| 156 | 156 |
ArrayList<String> names1 = new ArrayList<String>(); |
| 157 | 157 |
ArrayList<CQLQuery> queries2 = new ArrayList<CQLQuery>(); |
| ... | ... | |
| 203 | 203 |
} |
| 204 | 204 |
|
| 205 | 205 |
public class CoocMatrixDialog extends Dialog {
|
| 206 |
Corpus corpus; |
|
| 206 |
CQPCorpus corpus;
|
|
| 207 | 207 |
|
| 208 | 208 |
org.eclipse.swt.widgets.List propsCombo; |
| 209 | 209 |
Spinner distSpinner; |
| ... | ... | |
| 222 | 222 |
|
| 223 | 223 |
|
| 224 | 224 |
|
| 225 |
public CoocMatrixDialog(Shell parentShell, Corpus corpus) {
|
|
| 225 |
public CoocMatrixDialog(Shell parentShell, CQPCorpus corpus) {
|
|
| 226 | 226 |
super(parentShell); |
| 227 | 227 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE); |
| 228 | 228 |
this.corpus = corpus; |
| tmp/org.txm.querycooccurrences.rcp/src/org/txm/functions/coocmatrix/QueryAutoCooccurrence.java (revision 1094) | ||
|---|---|---|
| 15 | 15 |
import org.txm.lexicaltable.core.statsengine.r.data.LexicalTableImpl; |
| 16 | 16 |
import org.txm.rcp.IImageKeys; |
| 17 | 17 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 18 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 18 |
import org.txm.searchengine.cqp.corpus.CQPCorpus;
|
|
| 19 | 19 |
import org.txm.searchengine.cqp.corpus.Partition; |
| 20 | 20 |
import org.txm.searchengine.cqp.corpus.Property; |
| 21 | 21 |
import org.txm.searchengine.cqp.corpus.QueryResult; |
| ... | ... | |
| 27 | 27 |
|
| 28 | 28 |
public class QueryAutoCooccurrence extends TXMResult implements ICAComputable, IAdaptable {
|
| 29 | 29 |
|
| 30 |
protected Corpus corpus; |
|
| 30 |
protected CQPCorpus corpus;
|
|
| 31 | 31 |
protected int[][] coocs; |
| 32 | 32 |
protected ArrayList<CQLQuery> queries; |
| 33 | 33 |
protected ArrayList<String> names; |
| ... | ... | |
| 44 | 44 |
protected int minCooc; |
| 45 | 45 |
protected boolean oriented = false; |
| 46 | 46 |
|
| 47 |
public QueryAutoCooccurrence(Corpus corpus) {
|
|
| 47 |
public QueryAutoCooccurrence(CQPCorpus corpus) {
|
|
| 48 | 48 |
super(corpus); |
| 49 | 49 |
} |
| 50 | 50 |
|
| ... | ... | |
| 109 | 109 |
return corpus.getName()+ " d="+dist+ " min="+minCooc; |
| 110 | 110 |
} |
| 111 | 111 |
|
| 112 |
public Corpus getParent() {
|
|
| 112 |
public CQPCorpus getParent() {
|
|
| 113 | 113 |
return corpus; |
| 114 | 114 |
} |
| 115 | 115 |
|
| ... | ... | |
| 197 | 197 |
return outfile.exists(); |
| 198 | 198 |
} |
| 199 | 199 |
|
| 200 |
public Corpus getCorpus() {
|
|
| 200 |
public CQPCorpus getCorpus() {
|
|
| 201 | 201 |
return corpus; |
| 202 | 202 |
} |
| 203 | 203 |
|
| ... | ... | |
| 243 | 243 |
|
| 244 | 244 |
@Override |
| 245 | 245 |
public CA toCA() throws StatException, CqiClientException {
|
| 246 |
Corpus corpus = this.getCorpus(); |
|
| 246 |
CQPCorpus corpus = this.getCorpus();
|
|
| 247 | 247 |
Property analysisProperty = null; |
| 248 | 248 |
try {
|
| 249 | 249 |
analysisProperty = this.getCorpus().getProperty("word"); //$NON-NLS-1$
|
| ... | ... | |
| 264 | 264 |
return null; |
| 265 | 265 |
} |
| 266 | 266 |
|
| 267 |
@Override |
|
| 268 |
public boolean delete() {
|
|
| 269 |
return corpus.removeResult(this); |
|
| 270 |
} |
|
| 271 |
|
|
| 272 | 267 |
/** The WordCloud adapter. */ |
| 273 | 268 |
private static IWorkbenchAdapter coocMatrixAdapter = new IWorkbenchAdapter() {
|
| 274 | 269 |
|
| tmp/org.txm.querycooccurrences.rcp/src/org/txm/functions/coocmatrix/QueryCooccurrence.java (revision 1094) | ||
|---|---|---|
| 15 | 15 |
import org.txm.lexicaltable.core.statsengine.r.data.LexicalTableImpl; |
| 16 | 16 |
import org.txm.rcp.IImageKeys; |
| 17 | 17 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 18 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 18 |
import org.txm.searchengine.cqp.corpus.CQPCorpus;
|
|
| 19 | 19 |
import org.txm.searchengine.cqp.corpus.Partition; |
| 20 | 20 |
import org.txm.searchengine.cqp.corpus.Property; |
| 21 | 21 |
import org.txm.searchengine.cqp.corpus.QueryResult; |
| ... | ... | |
| 27 | 27 |
|
| 28 | 28 |
public class QueryCooccurrence extends TXMResult implements ICAComputable, IAdaptable {
|
| 29 | 29 |
|
| 30 |
protected Corpus corpus; |
|
| 30 |
protected CQPCorpus corpus;
|
|
| 31 | 31 |
protected int[][] coocs; |
| 32 | 32 |
protected ArrayList<CQLQuery> queries1; |
| 33 | 33 |
protected ArrayList<String> names1; |
| ... | ... | |
| 45 | 45 |
protected int nEdges = 0; |
| 46 | 46 |
protected int minCooc; |
| 47 | 47 |
|
| 48 |
public QueryCooccurrence(Corpus corpus, |
|
| 48 |
public QueryCooccurrence(CQPCorpus corpus,
|
|
| 49 | 49 |
ArrayList<CQLQuery> queries1, ArrayList<String> names1, |
| 50 | 50 |
ArrayList<CQLQuery> queries2, ArrayList<String> names2, |
| 51 | 51 |
int dist, int minCooc, String struct) throws CqiClientException, RWorkspaceException {
|
| ... | ... | |
| 129 | 129 |
rw.eval("colnames("+symbol+") <- cooclabels");
|
| 130 | 130 |
} |
| 131 | 131 |
|
| 132 |
public Corpus getCorpus() {
|
|
| 132 |
public CQPCorpus getCorpus() {
|
|
| 133 | 133 |
return corpus; |
| 134 | 134 |
} |
| 135 | 135 |
|
| ... | ... | |
| 175 | 175 |
|
| 176 | 176 |
@Override |
| 177 | 177 |
public CA toCA() throws StatException, CqiClientException {
|
| 178 |
Corpus corpus = this.getCorpus(); |
|
| 178 |
CQPCorpus corpus = this.getCorpus();
|
|
| 179 | 179 |
Property analysisProperty = null; |
| 180 | 180 |
try {
|
| 181 | 181 |
analysisProperty = this.getCorpus().getProperty("word"); //$NON-NLS-1$
|
| ... | ... | |
| 196 | 196 |
return null; |
| 197 | 197 |
} |
| 198 | 198 |
|
| 199 |
@Override |
|
| 200 |
public boolean delete() {
|
|
| 201 |
return corpus.removeResult(this); |
|
| 202 |
} |
|
| 203 |
|
|
| 204 | 199 |
public String[] getExportTXTExtensions() {
|
| 205 | 200 |
return new String[]{"*.txt"};
|
| 206 | 201 |
} |
| tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/CreteMissingPropertiesFiles.groovy (revision 1094) | ||
|---|---|---|
| 1 |
package org.txm.groovy.core |
|
| 2 |
|
|
| 3 |
File workspace = new File("/home/mdecorde/workspace047")
|
|
| 4 |
def langs = ["fr", "ru"] |
|
| 5 |
for (File project : workspace.listFiles()) {
|
|
| 6 |
if (!project.isDirectory()) continue; |
|
| 7 |
|
|
| 8 |
File osgiinf = new File(project, "OSGI-INF/l10n") |
|
| 9 |
if (!osgiinf.exists()) continue; |
|
| 10 |
|
|
| 11 |
println project.getName() |
|
| 12 |
File defaultFile = new File(osgiinf, "bundle.properties") |
|
| 13 |
|
|
| 14 |
for (def lang : langs) {
|
|
| 15 |
File langFile = new File(osgiinf, "bundle_"+lang+".properties"); |
|
| 16 |
if (!langFile.exists()) {
|
|
| 17 |
langFile.createNewFile() |
|
| 18 |
} |
|
| 19 |
} |
|
| 20 |
} |
|
| tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/InstallGroovyFiles.java (revision 1094) | ||
|---|---|---|
| 2 | 2 |
|
| 3 | 3 |
import java.io.File; |
| 4 | 4 |
import java.io.IOException; |
| 5 |
import java.util.HashMap; |
|
| 6 | 5 |
|
| 7 | 6 |
import org.txm.PostTXMHOMEInstallationStep; |
| 7 |
import org.txm.Toolbox; |
|
| 8 | 8 |
import org.txm.objects.Workspace; |
| 9 | 9 |
import org.txm.utils.BundleUtils; |
| 10 |
import org.txm.utils.DeleteDir; |
|
| 11 | 10 |
import org.txm.utils.io.FileCopy; |
| 12 | 11 |
|
| 12 |
/** |
|
| 13 |
* Copy all Groovy scripts in TXMHome directory |
|
| 14 |
* |
|
| 15 |
* @author mdecorde |
|
| 16 |
* |
|
| 17 |
*/ |
|
| 13 | 18 |
public class InstallGroovyFiles extends PostTXMHOMEInstallationStep {
|
| 14 | 19 |
|
| 15 | 20 |
@Override |
| 16 | 21 |
public boolean install(Workspace workspace) {
|
| 17 |
File txmhomedir = workspace.getLocation();
|
|
| 22 |
File txmhomedir = new File(Toolbox.getTxmHomePath());
|
|
| 18 | 23 |
|
| 19 | 24 |
String createfolders[] = {"scripts/groovy/lib", "scripts/groovy/user", "scripts/groovy/system"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
| 20 | 25 |
|
| ... | ... | |
| 76 | 81 |
e.printStackTrace(); |
| 77 | 82 |
} |
| 78 | 83 |
|
| 84 |
|
|
| 85 |
|
|
| 79 | 86 |
return scriptsDirectory.exists(); |
| 80 | 87 |
} |
| 81 | 88 |
|
| tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/CreateMissingPropertiesFiles.groovy (revision 1094) | ||
|---|---|---|
| 1 |
package org.txm.groovy.core |
|
| 2 |
|
|
| 3 |
File workspace = new File("/home/mdecorde/workspace047")
|
|
| 4 |
def langs = ["fr", "ru"] |
|
| 5 |
for (File project : workspace.listFiles()) {
|
|
| 6 |
if (!project.isDirectory()) continue; |
|
| 7 |
|
|
| 8 |
File osgiinf = new File(project, "OSGI-INF/l10n") |
|
| 9 |
if (!osgiinf.exists()) continue; |
|
| 10 |
|
|
| 11 |
println project.getName() |
|
| 12 |
File defaultFile = new File(osgiinf, "bundle.properties") |
|
| 13 |
|
|
| 14 |
for (def lang : langs) {
|
|
| 15 |
File langFile = new File(osgiinf, "bundle_"+lang+".properties"); |
|
| 16 |
if (!langFile.exists()) {
|
|
| 17 |
langFile.createNewFile() |
|
| 18 |
} |
|
| 19 |
} |
|
| 20 |
} |
|
| tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/GroovyProgressMonitor.java (revision 1094) | ||
|---|---|---|
| 1 |
package org.txm.groovy.core; |
|
| 2 |
|
|
| 3 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 4 |
|
|
| 5 |
/** |
|
| 6 |
* IProgressMonitor wrapper |
|
| 7 |
* |
|
| 8 |
* adds some methods for Groovy scripts |
|
| 9 |
* |
|
| 10 |
* @author mdecorde |
|
| 11 |
* |
|
| 12 |
*/ |
|
| 13 |
public class GroovyProgressMonitor implements IProgressMonitor{
|
|
| 14 |
|
|
| 15 |
private IProgressMonitor monitor; |
|
| 16 |
|
|
| 17 |
public GroovyProgressMonitor(IProgressMonitor monitor) {
|
|
| 18 |
this.monitor = monitor; |
|
| 19 |
} |
|
| 20 |
|
|
| 21 |
@Override |
|
| 22 |
public void beginTask(String name, int totalWork) {
|
|
| 23 |
if (monitor == null) return; |
|
| 24 |
|
|
| 25 |
monitor.beginTask(name, totalWork); |
|
| 26 |
} |
|
| 27 |
|
|
| 28 |
@Override |
|
| 29 |
public void done() {
|
|
| 30 |
if (monitor == null) return; |
|
| 31 |
monitor.done(); |
|
| 32 |
} |
|
| 33 |
|
|
| 34 |
@Override |
|
| 35 |
public void internalWorked(double work) {
|
|
| 36 |
if (monitor == null) return; |
|
| 37 |
monitor.internalWorked(work); |
|
| 38 |
} |
|
| 39 |
|
|
| 40 |
@Override |
|
| 41 |
public boolean isCanceled() {
|
|
| 42 |
if (monitor == null) return false; |
|
| 43 |
|
|
| 44 |
return monitor.isCanceled(); |
|
| 45 |
} |
|
| 46 |
|
|
| 47 |
@Override |
|
| 48 |
public void setCanceled(boolean value) {
|
|
| 49 |
if (monitor == null) return; |
|
| 50 |
|
|
| 51 |
monitor.setCanceled(value); |
|
| 52 |
} |
|
| 53 |
|
|
| 54 |
@Override |
|
| 55 |
public void setTaskName(String name) {
|
|
| 56 |
if (monitor == null) return; |
|
| 57 |
|
|
| 58 |
monitor.setTaskName(name); |
|
| 59 |
} |
|
| 60 |
|
|
| 61 |
@Override |
|
| 62 |
public void subTask(String name) {
|
|
| 63 |
// TODO Auto-generated method stub |
|
| 64 |
|
|
| 65 |
} |
|
| 66 |
|
|
| 67 |
@Override |
|
| 68 |
public void worked(int work) {
|
|
| 69 |
if (monitor == null) return; |
|
| 70 |
monitor.worked(work); |
|
| 71 |
} |
|
| 72 |
|
|
| 73 |
public void worked(int work, String message) {
|
|
| 74 |
if (monitor == null) return; |
|
| 75 |
monitor.worked(work); |
|
| 76 |
monitor.setTaskName(message); |
|
| 77 |
} |
|
| 78 |
} |
|
| 0 | 79 | |
| tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/GroovyScriptedImportEngine.java (revision 1094) | ||
|---|---|---|
| 1 |
package org.txm.groovy.core; |
|
| 2 |
|
|
| 3 |
import java.io.File; |
|
| 4 |
import java.util.logging.Level; |
|
| 5 |
|
|
| 6 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 7 |
import org.eclipse.core.runtime.IStatus; |
|
| 8 |
import org.eclipse.core.runtime.Status; |
|
| 9 |
import org.txm.Toolbox; |
|
| 10 |
import org.txm.annotation.core.AnnotationEngine; |
|
| 11 |
import org.txm.core.engines.Engine; |
|
| 12 |
import org.txm.core.engines.EngineType; |
|
| 13 |
import org.txm.core.engines.ScriptedImportEngine; |
|
| 14 |
import org.txm.objects.Project; |
|
| 15 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
|
| 16 |
import org.txm.tokenizer.TokenizerClasses; |
|
| 17 |
import org.txm.utils.ExecTimer; |
|
| 18 |
import org.txm.utils.logger.Log; |
|
| 19 |
|
|
| 20 |
import groovy.lang.Binding; |
|
| 21 |
|
|
| 22 |
public class GroovyScriptedImportEngine extends ScriptedImportEngine {
|
|
| 23 |
|
|
| 24 |
File importer, compiler, pager, annotate; |
|
| 25 |
|
|
| 26 |
public GroovyScriptedImportEngine(File directory) {
|
|
| 27 |
super(directory.getName(), new File(directory, directory.getName()+"Loader.groovy")); |
|
| 28 |
importer = new File(directory, "importer.groovy"); |
|
| 29 |
compiler = new File(directory, "compiler.groovy"); |
|
| 30 |
pager = new File(directory, "pager.groovy"); |
|
| 31 |
annotate = new File(directory, "annotate.groovy"); |
|
| 32 |
} |
|
| 33 |
|
|
| 34 |
@Override |
|
| 35 |
public IStatus _build(Project project, IProgressMonitor monitor) {
|
|
| 36 |
|
|
| 37 |
try {
|
|
| 38 |
// check if TreeTagger if ready |
|
| 39 |
boolean annotate = project.getAnnotate(); |
|
| 40 |
if (annotate) {
|
|
| 41 |
Engine e = Toolbox.getEngineManager(EngineType.ANNOTATION).getEngine("TreeTagger");
|
|
| 42 |
if (e == null) {
|
|
| 43 |
System.out.println("Error: no TreeTagger annotation engine found to annotate the corpus. Aborting");
|
|
| 44 |
return null; |
|
| 45 |
} |
|
| 46 |
AnnotationEngine engine = (AnnotationEngine) e; |
|
| 47 |
if (!engine.isRunning()) {
|
|
| 48 |
System.out.println("Error: TreeTagger annotation engine is not ready please check TXM > Advance > TAL > TreeTagger preferences. Aborting");
|
|
| 49 |
return null; |
|
| 50 |
} |
|
| 51 |
} |
|
| 52 |
|
|
| 53 |
// the binary directory which is going to be created |
|
| 54 |
|
|
| 55 |
final File basedir = project.getProjectDirectory(); |
|
| 56 |
// final File tempBinDirectory = new File(basedir.getAbsolutePath()+"_temp"); //$NON-NLS-1$ |
|
| 57 |
// final File errorBinDirectory = new File(basedir.getAbsolutePath()+"_error"); //$NON-NLS-1$ |
|
| 58 |
// if (tempBinDirectory.exists()) DeleteDir.deleteDirectory(tempBinDirectory); |
|
| 59 |
// if (errorBinDirectory.exists()) DeleteDir.deleteDirectory(errorBinDirectory); |
|
| 60 |
|
|
| 61 |
//this.setCurrentMonitor(monitor); |
|
| 62 |
monitor.beginTask("Importing sources" + project.getSrcdir(), 100); //$NON-NLS-1$
|
|
| 63 |
|
|
| 64 |
//org.txm.Toolbox.shutdownSearchEngine(); |
|
| 65 |
monitor.worked(5); |
|
| 66 |
|
|
| 67 |
GSERunner gse = GSERunner.buildDefaultGSE(mainScript); |
|
| 68 |
|
|
| 69 |
Binding binding = new Binding(); |
|
| 70 |
binding.setProperty("projectBinding", project); //$NON-NLS-1$
|
|
| 71 |
binding.setProperty("monitor", new GroovyProgressMonitor(monitor)); //$NON-NLS-1$
|
|
| 72 |
|
|
| 73 |
boolean logLevel = Log.getLevel().intValue() < Level.WARNING.intValue(); |
|
| 74 |
binding.setProperty("debug", logLevel); //$NON-NLS-1$
|
|
| 75 |
binding.setProperty("readyToLoad", Boolean.FALSE); //$NON-NLS-1$
|
|
| 76 |
//System.out.println("script="+script);
|
|
| 77 |
|
|
| 78 |
TokenizerClasses.reset(); |
|
| 79 |
if (!TokenizerClasses.loadFromProject(project.getPreferences())) {
|
|
| 80 |
System.out.println("Error: failed to load tokenizer parameters");
|
|
| 81 |
monitor.done(); |
|
| 82 |
// if (basedir.exists()) basedir.renameTo(errorBinDirectory); |
|
| 83 |
// if (tempBinDirectory.exists()) tempBinDirectory.renameTo(basedir); |
|
| 84 |
return Status.CANCEL_STATUS; |
|
| 85 |
} |
|
| 86 |
|
|
| 87 |
ExecTimer.start(); |
|
| 88 |
Log.info("Start of Groovy import script" + mainScript.getAbsolutePath()); //$NON-NLS-1$
|
|
| 89 |
gse.run(mainScript.getAbsolutePath(), binding); // run the groovy import script |
|
| 90 |
System.out.println("\nEnd of Groovy import script: "+ExecTimer.stop()); //$NON-NLS-1$
|
|
| 91 |
monitor.worked(90); |
|
| 92 |
|
|
| 93 |
TokenizerClasses.reset(); |
|
| 94 |
|
|
| 95 |
Object ready = binding.getVariable("readyToLoad"); //$NON-NLS-1$
|
|
| 96 |
if (ready != null && ready instanceof Boolean) {
|
|
| 97 |
Boolean readyToLoad = (Boolean)ready; |
|
| 98 |
//System.out.println("TRY TO LOAD THE BINARY CORPUS CREATED: "+basedir);
|
|
| 99 |
if (readyToLoad) {
|
|
| 100 |
// base = LoadBinaryCorpus.loadBinaryCorpusAsDirectory(basedir); |
|
| 101 |
// if (base == null) {
|
|
| 102 |
// System.out.println(TXMUIMessages.ExecuteScriptImport_8); |
|
| 103 |
// if (basedir.exists()) basedir.renameTo(errorBinDirectory); |
|
| 104 |
// if (tempBinDirectory.exists()) tempBinDirectory.renameTo(basedir); |
|
| 105 |
// return Status.CANCEL_STATUS; |
|
| 106 |
// } |
|
| 107 |
// this.acquireSemaphore(); |
|
| 108 |
// Log.info("Save workspace"); //$NON-NLS-1$
|
|
| 109 |
// Toolbox.workspace.save(); |
|
| 110 |
|
|
| 111 |
Log.info("Restart Toolbox search engine"); //$NON-NLS-1$
|
|
| 112 |
//Toolbox.restartWorkspace(null); |
|
| 113 |
Toolbox.getEngineManager(EngineType.SEARCH).restartEngines(); |
|
| 114 |
|
|
| 115 |
// DeleteDir.deleteDirectory(tempBinDirectory); |
|
| 116 |
|
|
| 117 |
// IWorkspace workspace = ResourcesPlugin.getWorkspace(); |
|
| 118 |
// IProject newProject = workspace.getRoot().getProject(base.getName()); |
|
| 119 |
// newProject.create(monitor); |
|
| 120 |
// newProject.open(monitor); |
|
| 121 |
// IFolder srcFolder = newProject.getFolder("src");
|
|
| 122 |
// IPath path = new Path(params.rootDir); |
|
| 123 |
// srcFolder.createLink(path, IResource.ALLOW_MISSING_LOCAL, monitor); |
|
| 124 |
} else {
|
|
| 125 |
System.out.println("Error: import not correctly ended. See console messages.");
|
|
| 126 |
// if (basedir.exists()) basedir.renameTo(errorBinDirectory); |
|
| 127 |
// if (tempBinDirectory.exists()) tempBinDirectory.renameTo(basedir); |
|
| 128 |
return new Status(Status.ERROR, "org.txm.groovy.core", "Import not correclty ended. See console messages."); |
|
| 129 |
} |
|
| 130 |
} |
|
| 131 |
} catch (ThreadDeath td) {
|
|
| 132 |
return Status.CANCEL_STATUS; |
|
| 133 |
} catch (Exception e) {
|
|
| 134 |
//System.out.println(NLS.bind(TXMUIMessages.RunGroovyScript_8, e)); |
|
| 135 |
Log.printStackTrace(e); |
|
| 136 |
return new Status(Status.ERROR, "org.txm.groovy.core", e.getMessage()); |
|
| 137 |
} finally {
|
|
| 138 |
if (!CQPSearchEngine.isInitialized()) { // the import failed
|
|
| 139 |
monitor.setTaskName("Restarting Toolbox search engine"); //$NON-NLS-1$
|
|
| 140 |
Toolbox.restartWorkspace(monitor); |
|
| 141 |
Toolbox.getEngineManager(EngineType.SEARCH).restartEngines(); |
|
| 142 |
} |
|
| 143 |
} |
|
| 144 |
System.gc(); |
|
| 145 |
return Status.OK_STATUS; |
|
| 146 |
} |
|
| 147 |
} |
|
| 0 | 148 | |
| tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/TXMClassLoader.java (revision 1094) | ||
|---|---|---|
| 1 |
package org.txm.groovy.core; |
|
| 2 |
|
|
| 3 |
import java.util.HashSet; |
|
| 4 |
|
|
| 5 |
public class TXMClassLoader extends ClassLoader {
|
|
| 6 |
private HashSet<ClassLoader> loaders; |
|
| 7 |
|
|
| 8 |
public TXMClassLoader(HashSet<ClassLoader> loaders2) {
|
|
| 9 |
this.loaders = loaders2; |
|
| 10 |
} |
|
| 11 |
|
|
| 12 |
public Class findClass(String name) throws ClassNotFoundException {
|
|
| 13 |
|
|
| 14 |
try { // try with the common one
|
|
| 15 |
return this.getClass().getClassLoader().loadClass(name); |
|
| 16 |
} catch(Exception e) {}
|
|
| 17 |
|
|
| 18 |
for (ClassLoader cl : loaders) {
|
|
| 19 |
try {
|
|
| 20 |
return cl.loadClass(name); |
|
| 21 |
} catch(Exception e) {}
|
|
| 22 |
} |
|
| 23 |
throw new ClassNotFoundException(name); |
|
| 24 |
} |
|
| 25 |
} |
|
| 0 | 26 | |
| tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/GroovyImportEngine.java (revision 1094) | ||
|---|---|---|
| 1 |
package org.txm.groovy.core; |
|
| 2 |
|
|
| 3 |
import java.io.File; |
|
| 4 |
|
|
| 5 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 6 |
import org.eclipse.core.runtime.IStatus; |
|
| 7 |
import org.eclipse.core.runtime.Status; |
|
| 8 |
import org.txm.Toolbox; |
|
| 9 |
import org.txm.core.engines.ImportEngine; |
|
| 10 |
import org.txm.core.engines.ImportEngines; |
|
| 11 |
import org.txm.core.engines.ScriptedImportEngine; |
|
| 12 |
import org.txm.objects.Project; |
|
| 13 |
|
|
| 14 |
public class GroovyImportEngine extends ImportEngine {
|
|
| 15 |
|
|
| 16 |
@Override |
|
| 17 |
public boolean isRunning() {
|
|
| 18 |
return false; |
|
| 19 |
} |
|
| 20 |
|
|
| 21 |
@Override |
|
| 22 |
public boolean initialize() throws Exception {
|
|
| 23 |
|
|
| 24 |
ImportEngines engines = Toolbox.getImportEngines(); |
|
| 25 |
File importsPackageDirectory = new File(Toolbox.getTxmHomePath(), "scripts/groovy/user/org/txm/scripts/importer"); |
|
| 26 |
|
|
| 27 |
if (!importsPackageDirectory.exists()) {
|
|
| 28 |
return false; |
|
| 29 |
} |
|
| 30 |
for (File dir : importsPackageDirectory.listFiles()) {
|
|
| 31 |
if (!dir.isDirectory()) continue; |
|
| 32 |
if (dir.isHidden()) continue; |
|
| 33 |
|
|
| 34 |
String name = dir.getName(); |
|
| 35 |
File loader = new File(dir, name+"Loader.groovy"); |
|
| 36 |
if (loader.exists()) {
|
|
| 37 |
ScriptedImportEngine sengine = new GroovyScriptedImportEngine(dir); |
|
| 38 |
if (engines.getEngine(name) == null) {
|
|
| 39 |
engines.put(name, sengine); |
|
| 40 |
} else {
|
|
| 41 |
System.out.println("Scripted import module in "+dir+" not registered since one with the same name is registered.");
|
|
| 42 |
} |
|
| 43 |
} |
|
| 44 |
} |
|
| 45 |
return true; |
|
| 46 |
} |
|
| 47 |
|
|
| 48 |
@Override |
|
| 49 |
public boolean start(IProgressMonitor monitor) throws Exception {
|
|
| 50 |
// TODO Auto-generated method stub |
|
| 51 |
return true; |
|
| 52 |
} |
|
| 53 |
|
|
| 54 |
@Override |
|
| 55 |
public boolean stop() throws Exception {
|
|
| 56 |
// TODO Auto-generated method stub |
|
| 57 |
return true; |
|
| 58 |
} |
|
| 59 |
|
|
| 60 |
@Override |
|
| 61 |
public String getName() {
|
|
| 62 |
return "groovy scripted imports installers - not meant to be used"; |
|
| 63 |
} |
|
| 64 |
|
|
| 65 |
@Override |
|
| 66 |
public IStatus build(Project project, IProgressMonitor monitor) {
|
|
| 67 |
return Status.CANCEL_STATUS; |
|
| 68 |
} |
|
| 69 |
} |
|
| 0 | 70 | |
| tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/GSERunner.java (revision 1094) | ||
|---|---|---|
| 1 |
package org.txm.groovy.core; |
|
| 2 |
|
|
| 3 |
import java.io.File; |
|
| 4 |
import java.io.FilenameFilter; |
|
| 5 |
import java.io.IOException; |
|
| 6 |
import java.net.MalformedURLException; |
|
| 7 |
import java.net.URL; |
|
| 8 |
import java.util.Comparator; |
|
| 9 |
import java.util.HashMap; |
|
| 10 |
import java.util.HashSet; |
|
| 11 |
import java.util.Map; |
|
| 12 |
|
|
| 13 |
import org.codehaus.groovy.control.CompilerConfiguration; |
|
| 14 |
import org.codehaus.groovy.control.customizers.ImportCustomizer; |
|
| 15 |
import org.eclipse.core.internal.runtime.InternalPlatform; |
|
| 16 |
import org.osgi.framework.Bundle; |
|
| 17 |
import org.osgi.framework.BundleContext; |
|
| 18 |
import org.osgi.framework.wiring.BundleWiring; |
|
| 19 |
import org.txm.Toolbox; |
|
| 20 |
import org.txm.utils.logger.Log; |
|
| 21 |
|
|
| 22 |
import cern.colt.Arrays; |
|
| 23 |
import groovy.lang.Binding; |
|
| 24 |
import groovy.util.GroovyScriptEngine; |
|
| 25 |
import groovy.util.ResourceException; |
|
| 26 |
import groovy.util.ScriptException; |
|
| 27 |
|
|
| 28 |
/** |
|
| 29 |
* GroovyScriptEngine wrapper for TXM scripts and macros |
|
| 30 |
* |
|
| 31 |
* @author mdecorde |
|
| 32 |
* |
|
| 33 |
*/ |
|
| 34 |
public class GSERunner extends GroovyScriptEngine {
|
|
| 35 |
|
|
| 36 |
protected GSERunner(String[] urls) throws IOException {
|
|
| 37 |
super(urls, getTXMClassLoader()); |
|
| 38 |
} |
|
| 39 |
|
|
| 40 |
protected static GSERunner defaultGSE; |
|
| 41 |
protected static String defaultScriptRootDir = ""; |
|
| 42 |
|
|
| 43 |
public static void clearDefaultGSE() {
|
|
| 44 |
defaultGSE = null; |
|
| 45 |
defaultScriptRootDir = ""; |
|
| 46 |
} |
|
| 47 |
|
|
| 48 |
/** |
|
| 49 |
* Build a GSERunner with default paths : user, macro, import and library path |
|
| 50 |
* |
|
| 51 |
* @param scriptRootDir if null uses Toolbox home directory |
|
| 52 |
* @param script |
|
| 53 |
* @return |
|
| 54 |
*/ |
|
| 55 |
public static GSERunner buildDefaultGSE(File script) {
|
|
| 56 |
String scriptRootDir = new File(Toolbox.getTxmHomePath(), "scripts/groovy/").getAbsolutePath(); |
|
| 57 |
// check if script root dir was changed |
|
| 58 |
if (defaultScriptRootDir.equals(scriptRootDir) && defaultGSE != null) {
|
|
| 59 |
try {
|
|
| 60 |
defaultGSE.getGroovyClassLoader().addURL(new URL("file://"+script.getParent()));
|
|
| 61 |
} catch (MalformedURLException e) {
|
|
| 62 |
// TODO Auto-generated catch block |
|
| 63 |
e.printStackTrace(); |
|
| 64 |
} |
|
| 65 |
return defaultGSE; |
|
| 66 |
} |
|
| 67 |
|
|
| 68 |
if (scriptRootDir == null) {
|
|
| 69 |
scriptRootDir = new File(Toolbox.getTxmHomePath(), "scripts/groovy/").getAbsolutePath(); |
|
| 70 |
} |
|
| 71 |
String[] roots = new String[] {
|
|
| 72 |
scriptRootDir+"/user/", //$NON-NLS-1$ |
|
| 73 |
scriptRootDir+"/system/", //$NON-NLS-1$ |
|
| 74 |
}; |
|
| 75 |
|
|
| 76 |
try {
|
|
| 77 |
defaultScriptRootDir = scriptRootDir; |
|
| 78 |
Log.info("GSE roots: "+Arrays.toString(roots));
|
|
| 79 |
defaultGSE = new GSERunner(roots); |
|
| 80 |
} catch (IOException e) {
|
|
| 81 |
e.printStackTrace(); |
|
| 82 |
return null; |
|
| 83 |
} |
|
| 84 |
|
|
| 85 |
ImportCustomizer imports = new ImportCustomizer(); |
|
| 86 |
imports.addStarImports("org.txm.rcp.utils",
|
|
| 87 |
"org.txm.utils", |
|
| 88 |
"org.txm", |
|
| 89 |
"org.kohsuke.args4j", |
|
| 90 |
"org.txm.rcp.swt.widget.parameters"); |
|
| 91 |
imports.addImports("groovy.transform.Field");
|
|
| 92 |
CompilerConfiguration configuration = new CompilerConfiguration(); |
|
| 93 |
configuration.addCompilationCustomizers(imports); |
|
| 94 |
|
|
| 95 |
defaultGSE.setConfig(configuration); |
|
| 96 |
|
|
| 97 |
File jardir = new File(scriptRootDir,"lib"); //$NON-NLS-1$ |
|
| 98 |
if (jardir.exists() && jardir.isDirectory()) {
|
|
| 99 |
for (File f: jardir.listFiles(new FilenameFilter() {
|
|
| 100 |
@Override |
|
| 101 |
public boolean accept(File dir, String name) {
|
|
| 102 |
return name.endsWith(".jar"); //$NON-NLS-1$
|
|
| 103 |
} |
|
| 104 |
})) |
|
| 105 |
{
|
|
| 106 |
try {
|
|
| 107 |
defaultGSE.getGroovyClassLoader().addURL(f.toURI().toURL()); |
|
| 108 |
} catch (MalformedURLException e) {
|
|
| 109 |
// TODO Auto-generated catch block |
|
| 110 |
e.printStackTrace(); |
|
| 111 |
} |
|
| 112 |
} |
|
| 113 |
} |
|
| 114 |
defaultGSE.getGroovyClassLoader().addClasspath(scriptRootDir); // for the .class files if any |
|
| 115 |
|
|
| 116 |
return defaultGSE; |
|
| 117 |
} |
|
| 118 |
|
|
| 119 |
/** |
|
| 120 |
* |
|
| 121 |
* @return a class loader containing all bundles activated in TXM |
|
| 122 |
*/ |
|
| 123 |
protected static ClassLoader getTXMClassLoader() {
|
|
| 124 |
HashSet<ClassLoader> loaders = new HashSet<ClassLoader>(); |
|
| 125 |
BundleContext bundleContext = InternalPlatform.getDefault().getBundleContext(); |
|
| 126 |
Bundle[] bundles = bundleContext.getBundles(); |
|
| 127 |
// java.util.Arrays.sort(bundles, new Comparator<Bundle>() {
|
|
| 128 |
// |
|
| 129 |
// @Override |
|
| 130 |
// public int compare(Bundle o1, Bundle o2) {
|
|
| 131 |
// if (o1.getSymbolicName().startsWith("org.txm")) return 1;
|
|
| 132 |
// return -1; |
|
| 133 |
// } |
|
| 134 |
// }); |
|
| 135 |
for (Bundle b : bundles) {
|
|
| 136 |
if (b == null) continue; |
|
| 137 |
|
|
| 138 |
if (!b.getSymbolicName().startsWith("org.txm")) continue;
|
|
| 139 |
|
|
| 140 |
BundleWiring bundleWiring = b.adapt(BundleWiring.class); |
|
| 141 |
if (bundleWiring == null) {
|
|
| 142 |
//System.out.println("GSERunner.createGSERunner(): NO wiring: " + b.getSymbolicName());
|
|
| 143 |
} else if (bundleWiring.getClassLoader() != null) {
|
|
| 144 |
loaders.add(bundleWiring.getClassLoader()); |
|
| 145 |
|
|
| 146 |
//FIXME: debug |
|
| 147 |
//System.out.println("GSERunner.createGSERunner(): ADD class loader: " + b.getSymbolicName());
|
|
| 148 |
} else {
|
|
| 149 |
//System.out.println("GSERunner.createGSERunner(): NO class loader: " + b.getSymbolicName());
|
|
| 150 |
} |
|
| 151 |
} |
|
| 152 |
|
|
| 153 |
Log.info("Initializing TXMClassLoader with " + loaders.size() + " bundles.");
|
|
| 154 |
return new TXMClassLoader(loaders); |
|
| 155 |
} |
|
| 156 |
|
|
| 157 |
/** |
|
| 158 |
* |
|
| 159 |
* Simplify the call a Groovy script within a Groovy script and allow to send named and typed arguments |
|
| 160 |
* |
|
| 161 |
* @param clazz |
|
| 162 |
* @param args |
|
| 163 |
* @return |
|
| 164 |
* @throws ResourceException |
|
| 165 |
* @throws ScriptException |
|
| 166 |
*/ |
|
| 167 |
@SuppressWarnings("rawtypes")
|
|
| 168 |
public Object run(Class clazz, Map args) throws ResourceException, ScriptException {
|
|
| 169 |
return run(clazz.getCanonicalName().replace(".", "/")+".groovy", new Binding(args));
|
|
| 170 |
} |
|
| 171 |
|
|
| 172 |
/** |
|
| 173 |
* Convenience method exactly the same as calling |
|
| 174 |
* run(clazz, ["args":args]) |
|
| 175 |
* |
|
| 176 |
* @param clazz |
|
| 177 |
* @param args |
|
| 178 |
* @return |
|
| 179 |
* @throws ResourceException |
|
| 180 |
* @throws ScriptException |
|
| 181 |
*/ |
|
| 182 |
@SuppressWarnings("rawtypes")
|
|
| 183 |
public Object runMacro(Class clazz, Map args) throws ResourceException, ScriptException {
|
|
| 184 |
HashMap<String, Object> arrangedMap = new HashMap<String, Object>(); |
|
| 185 |
arrangedMap.put("args", args);
|
|
| 186 |
return run(clazz.getCanonicalName().replace(".", "/")+".groovy", new Binding(arrangedMap));
|
|
| 187 |
} |
|
| 188 |
|
|
| 189 |
/** |
|
| 190 |
* Convenience method exactly the same as calling |
|
| 191 |
* run(clazz, ["args":[:]]) |
|
| 192 |
* |
|
| 193 |
* @param clazz |
|
| 194 |
* @param args |
|
| 195 |
* @return |
|
| 196 |
* @throws ResourceException |
|
| 197 |
* @throws ScriptException |
|
| 198 |
*/ |
|
| 199 |
@SuppressWarnings("rawtypes")
|
|
| 200 |
public Object runMacro(Class clazz) throws ResourceException, ScriptException {
|
|
| 201 |
HashMap<String, Object> arrangedMap = new HashMap<String, Object>(); |
|
| 202 |
arrangedMap.put("args", new HashMap<String, Object>());
|
|
| 203 |
return run(clazz.getCanonicalName().replace(".", "/")+".groovy", new Binding(arrangedMap));
|
|
| 204 |
} |
|
| 205 |
} |
|
| 0 | 206 | |
| tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/txt/txtLoader.groovy (revision 1094) | ||
|---|---|---|
| 33 | 33 |
import org.txm.objects.*; |
| 34 | 34 |
import org.txm.importer.scripts.xmltxm.*; |
| 35 | 35 |
import org.txm.*; |
| 36 |
import org.txm.objects.*; |
|
| 36 | 37 |
import org.txm.core.engines.*; |
| 37 | 38 |
import org.txm.utils.i18n.*; |
| 38 | 39 |
import org.txm.metadatas.*; |
| ... | ... | |
| 44 | 45 |
String userDir = System.getProperty("user.home");
|
| 45 | 46 |
boolean debug = org.txm.utils.logger.Log.isPrintingErrors(); |
| 46 | 47 |
def MONITOR; |
| 47 |
BaseParameters params; |
|
| 48 |
try {params = paramsBinding;MONITOR=monitor} catch (Exception)
|
|
| 49 |
{ println "DEV MODE";//exception means we debug
|
|
| 50 |
debug = true |
|
| 51 |
params = new BaseParameters(new File(userDir, "TXM/clipboard/clipboard2/import.xml")) |
|
| 52 |
params.load() |
|
| 53 |
if (!org.txm.Toolbox.isInitialized()) {
|
|
| 54 |
Toolbox.setParam(Toolbox.INSTALL_DIR,new File("C:/Program Files/TXM"));
|
|
| 55 |
Toolbox.setParam(Toolbox.TREETAGGER_MODELS_PATH, new File("C:/Users/mdecorde/TXM/treetagger"));
|
|
| 56 |
Toolbox.setParam(Toolbox.METADATA_ENCODING, "UTF-8"); |
|
| 57 |
Toolbox.setParam(Toolbox.METADATA_COLSEPARATOR, ","); |
|
| 58 |
Toolbox.setParam(Toolbox.METADATA_TXTSEPARATOR, "\""); |
|
| 59 |
Toolbox.setParam(Toolbox.USER_TXM_HOME, new File(userDir, "TXM")); |
|
| 60 |
} |
|
| 61 |
} |
|
| 62 |
if (params == null) { println "No parameters file. Aborting"; return;}
|
|
| 48 |
Project project; |
|
| 49 |
boolean debug = org.txm.utils.logger.Log.isPrintingErrors(); |
|
| 63 | 50 |
|
| 64 |
String corpusname = params.getCorpusName(); |
|
| 65 |
Element corpusElem = params.corpora.get(corpusname); |
|
| 66 |
String basename = params.name; |
|
| 67 |
String rootDir = params.rootDir; |
|
| 68 |
String lang = corpusElem.getAttribute("lang");
|
|
| 51 |
try {project=projectBinding;MONITOR=monitor} catch (Exception)
|
|
| 52 |
{ }
|
|
| 53 |
if (project == null) { println "no project set. Aborting"; return; }
|
|
| 54 |
|
|
| 55 |
String corpusname = project.getName(); |
|
| 56 |
String basename = corpusname |
|
| 57 |
String rootDir = project.getSrcdir(); |
|
| 58 |
String lang = project.getLang() |
|
| 69 | 59 |
String model = lang |
| 70 |
String encoding = corpusElem.getAttribute("encoding");
|
|
| 71 |
boolean annotate = "true" == corpusElem.getAttribute("annotate");
|
|
| 72 |
String xsl = params.getXsltElement(corpusElem).getAttribute("xsl")
|
|
| 73 |
def xslParams = params.getXsltParams(corpusElem);
|
|
| 74 |
int wordsPerPage = params.getWordsPerPage("default")
|
|
| 75 |
boolean build_edition = params.getDoEdition("default")
|
|
| 60 |
String encoding = project.getEncoding()
|
|
| 61 |
boolean annotate = project.getAnnotate()
|
|
| 62 |
String xsl = project.getFrontXSL();
|
|
| 63 |
def xslParams = project.getXsltParameters();
|
|
| 64 |
int wordsPerPage = project.getEditionDefinition("default").getWordsPerPage()
|
|
| 65 |
boolean build_edition = project.getEditionDefinition("default").getBuildEdition()
|
|
| 76 | 66 |
|
| 77 | 67 |
File srcDir = new File(rootDir); |
| 78 |
File binDir = new File(Toolbox.getTxmHomePath(), "corpora/"+basename); |
|
| 79 |
binDir.deleteDir(); |
|
| 68 |
File binDir = project.getProjectDirectory(); |
|
| 80 | 69 |
binDir.mkdirs(); |
| 81 | 70 |
if (!binDir.exists()) {
|
| 82 | 71 |
println "Could not create binDir "+binDir |
| ... | ... | |
| 186 | 175 |
List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang); |
| 187 | 176 |
List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang); |
| 188 | 177 |
|
| 189 |
Element text = params.addText(params.corpora.get(corpusname), txtname, srcfile); |
|
| 190 |
|
|
| 178 |
Text t = new Text(project); |
|
| 179 |
t.setName(txtname); |
|
| 180 |
t.setSourceFile(srcfile) |
|
| 181 |
t.setTXMFile(srcfile) |
|
| 182 |
|
|
| 191 | 183 |
def ed = new pager(srcfile, outdir, txtname, NoSpaceBefore, NoSpaceAfter, wordsPerPage, basename, null); |
| 192 |
Element edition = params.addEdition(text, "default", outdir.getAbsolutePath(), "html"); |
|
| 193 |
|
|
| 184 |
Edition edition = new Edition(t); |
|
| 185 |
edition.setName("default");
|
|
| 186 |
edition.setIndex(outdir.getAbsolutePath()); |
|
| 194 | 187 |
for (i = 0 ; i < ed.getPageFiles().size();) {
|
| 195 | 188 |
File f = ed.getPageFiles().get(i); |
| 196 | 189 |
String wordid = ed.getIdx().get(i); |
| 197 |
params.addPage(edition, ""+(++i), wordid);
|
|
| 190 |
edition.addPage(""+(++i), wordid);
|
|
| 198 | 191 |
} |
| 199 | 192 |
} |
| 200 | 193 |
} |
| 201 | 194 |
if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); }
|
Formats disponibles : Unified diff