Révision 2650
| tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Union.java (revision 2650) | ||
|---|---|---|
| 104 | 104 |
catch (InterruptedException e2) {
|
| 105 | 105 |
// TODO Auto-generated catch block |
| 106 | 106 |
e2.printStackTrace(); |
| 107 |
return null; |
|
| 107 | 108 |
} |
| 108 | 109 |
// final CQPCorpus corpus2 = (CQPCorpus) secondElement; |
| 109 | 110 |
// corpus2.compute(false); |
| tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ExportCorpus.java (revision 2650) | ||
|---|---|---|
| 76 | 76 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event) |
| 77 | 77 |
.getShell(); |
| 78 | 78 |
|
| 79 |
String txmhome = Toolbox.getTxmHomePath(); |
|
| 80 | 79 |
if (!(selection.getFirstElement() instanceof MainCorpus)) |
| 81 | 80 |
return null; |
| 82 | 81 |
|
| 83 | 82 |
final MainCorpus corpus = (MainCorpus) selection.getFirstElement(); |
| 84 | 83 |
|
| 84 |
try {
|
|
| 85 |
corpus.compute(false); |
|
| 86 |
} |
|
| 87 |
catch (InterruptedException e) {
|
|
| 88 |
// TODO Auto-generated catch block |
|
| 89 |
e.printStackTrace(); |
|
| 90 |
return null; |
|
| 91 |
} |
|
| 92 |
|
|
| 85 | 93 |
if (corpus.isModified()) {
|
| 86 | 94 |
boolean ret = MessageDialog.openConfirm(shell, "Export - " + corpus.getName() + " annotations not saved", |
| 87 | 95 |
"Do you wish to export without the current annotations?\n\n(to include the current annotations in the exported corpus, you need to save them before calling the \"Export\" command)"); |
| tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Substraction.java (revision 2650) | ||
|---|---|---|
| 104 | 104 |
catch (InterruptedException e2) {
|
| 105 | 105 |
// TODO Auto-generated catch block |
| 106 | 106 |
e2.printStackTrace(); |
| 107 |
return null; |
|
| 107 | 108 |
} |
| 108 | 109 |
// final CQPCorpus corpus2 = (CQPCorpus) secondElement; |
| 109 | 110 |
// corpus2.compute(false); |
| tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputeIntersection.java (revision 2650) | ||
|---|---|---|
| 20 | 20 |
import org.txm.searchengine.cqp.corpus.Subcorpus; |
| 21 | 21 |
|
| 22 | 22 |
public class ComputeIntersection extends AbstractHandler {
|
| 23 |
|
|
| 23 |
|
|
| 24 | 24 |
@Override |
| 25 | 25 |
public void addHandlerListener(IHandlerListener handlerListener) {
|
| 26 | 26 |
super.addHandlerListener(handlerListener); |
| 27 | 27 |
} |
| 28 |
|
|
| 28 |
|
|
| 29 | 29 |
@Override |
| 30 | 30 |
public void dispose() {
|
| 31 | 31 |
super.dispose(); |
| 32 | 32 |
} |
| 33 |
|
|
| 34 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 | 35 |
@Override |
| 36 | 36 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
| 37 | 37 |
ISelection isel = HandlerUtil.getCurrentSelection(event); |
| 38 | 38 |
if (!(isel instanceof IStructuredSelection)) return null; |
| 39 | 39 |
IStructuredSelection selection = (IStructuredSelection) isel; |
| 40 | 40 |
List list = selection.toList(); |
| 41 |
ArrayList<Subcorpus> subcorpora = new ArrayList<Subcorpus>(); |
|
| 42 |
for (Object o : list) if (o instanceof Subcorpus) subcorpora.add((Subcorpus) o); |
|
| 43 |
|
|
| 41 |
ArrayList<Subcorpus> subcorpora = new ArrayList<>(); |
|
| 42 |
for (Object o : list) |
|
| 43 |
if (o instanceof Subcorpus) subcorpora.add((Subcorpus) o); |
|
| 44 |
|
|
| 44 | 45 |
if (subcorpora.size() != 2) {
|
| 45 |
System.out.println("Error: selection size != 2 : "+subcorpora.size());
|
|
| 46 |
System.out.println("Error: selection size != 2 : " + subcorpora.size());
|
|
| 46 | 47 |
return null; |
| 47 | 48 |
} |
| 48 |
|
|
| 49 |
HashSet<MainCorpus> set = new HashSet<MainCorpus>(); |
|
| 50 |
for (Subcorpus s : subcorpora) set.add(s.getMainCorpus()); |
|
| 49 |
|
|
| 50 |
HashSet<MainCorpus> set = new HashSet<>(); |
|
| 51 |
for (Subcorpus s : subcorpora) {
|
|
| 52 |
set.add(s.getMainCorpus()); |
|
| 53 |
try {
|
|
| 54 |
s.compute(false); |
|
| 55 |
} |
|
| 56 |
catch (InterruptedException e) {
|
|
| 57 |
e.printStackTrace(); |
|
| 58 |
return null; |
|
| 59 |
} |
|
| 60 |
} |
|
| 51 | 61 |
if (set.size() > 1) {
|
| 52 |
System.out.println("Error: selected subcorpus have different main corpus: "+set);
|
|
| 62 |
System.out.println("Error: selected subcorpus have different main corpus: " + set);
|
|
| 53 | 63 |
return null; |
| 54 | 64 |
} |
| 55 |
|
|
| 65 |
|
|
| 56 | 66 |
MainCorpus ancestor = subcorpora.get(0).getMainCorpus(); |
| 57 | 67 |
String id1 = subcorpora.get(0).getQualifiedCqpId(); |
| 58 | 68 |
String id2 = subcorpora.get(1).getQualifiedCqpId(); |
| 59 | 69 |
String cqpid = CqpObject.subcorpusNamePrefix + CQPCorpus.getNextSubcorpusCounter(); |
| 60 | 70 |
String command = "inter"; |
| 61 | 71 |
AbstractCqiClient CQI = CQPSearchEngine.getCqiClient(); |
| 62 |
|
|
| 63 |
//TODO: finish the command |
|
| 64 | 72 |
|
| 65 |
// String query = cqpid+"="+command+" "+id1+" "+id2+";"; |
|
| 66 |
// try {
|
|
| 67 |
// CQI.query(query) |
|
| 68 |
// } catch (Exception e) {
|
|
| 69 |
// println "Error: "+CQI.getLastError()+". Please restart TXM." |
|
| 70 |
// return; |
|
| 71 |
// } |
|
| 72 |
// |
|
| 73 |
// Subcorpus subcorpus = new Subcorpus(cqpid, name, ancestor, new Query("$command $id1 $id2;"));
|
|
| 74 |
// |
|
| 75 |
// println "$subcorpus stored in $ancestor" |
|
| 76 |
// |
|
| 77 |
// monitor.syncExec(new Runnable() {
|
|
| 78 |
// public void run() {
|
|
| 79 |
// CorporaView.refresh(); |
|
| 80 |
// CorporaView.expand(subcorpus.getParent()); |
|
| 81 |
// } |
|
| 82 |
// }); |
|
| 83 |
|
|
| 73 |
// TODO: finish the command |
|
| 74 |
|
|
| 75 |
// String query = cqpid+"="+command+" "+id1+" "+id2+";"; |
|
| 76 |
// try {
|
|
| 77 |
// CQI.query(query) |
|
| 78 |
// } catch (Exception e) {
|
|
| 79 |
// println "Error: "+CQI.getLastError()+". Please restart TXM." |
|
| 80 |
// return; |
|
| 81 |
// } |
|
| 82 |
// |
|
| 83 |
// Subcorpus subcorpus = new Subcorpus(cqpid, name, ancestor, new Query("$command $id1 $id2;"));
|
|
| 84 |
// |
|
| 85 |
// println "$subcorpus stored in $ancestor" |
|
| 86 |
// |
|
| 87 |
// monitor.syncExec(new Runnable() {
|
|
| 88 |
// public void run() {
|
|
| 89 |
// CorporaView.refresh(); |
|
| 90 |
// CorporaView.expand(subcorpus.getParent()); |
|
| 91 |
// } |
|
| 92 |
// }); |
|
| 93 |
|
|
| 84 | 94 |
return null; |
| 85 | 95 |
} |
| 86 |
|
|
| 96 |
|
|
| 87 | 97 |
@Override |
| 88 | 98 |
public boolean isEnabled() {
|
| 89 | 99 |
return super.isEnabled(); |
| 90 | 100 |
} |
| 91 |
|
|
| 101 |
|
|
| 92 | 102 |
@Override |
| 93 | 103 |
public boolean isHandled() {
|
| 94 | 104 |
return super.isHandled(); |
| 95 | 105 |
} |
| 96 |
|
|
| 106 |
|
|
| 97 | 107 |
@Override |
| 98 | 108 |
public void removeHandlerListener(IHandlerListener handlerListener) {
|
| 99 | 109 |
super.removeHandlerListener(handlerListener); |
| tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/Intersection.java (revision 2650) | ||
|---|---|---|
| 59 | 59 |
* Command which creates a subcorpus from a Corpus @ author mdecorde. |
| 60 | 60 |
*/ |
| 61 | 61 |
public class Intersection extends AbstractHandler {
|
| 62 |
|
|
| 62 |
|
|
| 63 | 63 |
/** The selection. */ |
| 64 | 64 |
private IStructuredSelection selection; |
| 65 |
|
|
| 66 |
/* (non-Javadoc) |
|
| 65 |
|
|
| 66 |
/* |
|
| 67 |
* (non-Javadoc) |
|
| 67 | 68 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
| 68 | 69 |
*/ |
| 69 | 70 |
@Override |
| ... | ... | |
| 71 | 72 |
|
| 72 | 73 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
| 73 | 74 |
if (selection == null) {
|
| 74 |
System.out.println(TXMUIMessages.noSelectionForColon+HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor());
|
|
| 75 |
System.out.println(TXMUIMessages.noSelectionForColon + HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor());
|
|
| 75 | 76 |
return null; |
| 76 | 77 |
} |
| 77 | 78 |
List list = selection.toList(); |
| 78 | 79 |
if (list.size() == 0) {
|
| 79 | 80 |
Log.info("No corpus selected");
|
| 80 | 81 |
return null; |
| 81 |
} else if (list.size() != 1) {
|
|
| 82 |
} |
|
| 83 |
else if (list.size() != 1) {
|
|
| 82 | 84 |
Log.info("Substraction need a selection of 1 corpus");
|
| 83 | 85 |
return null; |
| 84 | 86 |
} |
| 85 | 87 |
Object firstElement = list.get(0); |
| 86 |
// Object secondElement = list.get(1);
|
|
| 88 |
// Object secondElement = list.get(1);
|
|
| 87 | 89 |
|
| 88 | 90 |
if (!(firstElement instanceof CQPCorpus)) {
|
| 89 |
System.out.println(TXMUIMessages.selectionIsNotACorpusColon+firstElement);
|
|
| 91 |
System.out.println(TXMUIMessages.selectionIsNotACorpusColon + firstElement);
|
|
| 90 | 92 |
return null; |
| 91 | 93 |
} |
| 92 | 94 |
|
| 93 |
// if (!(secondElement instanceof CQPCorpus)) {
|
|
| 94 |
// System.out.println(TXMUIMessages.selectionIsNotACorpusColon+secondElement);
|
|
| 95 |
// return null;
|
|
| 96 |
// }
|
|
| 95 |
// if (!(secondElement instanceof CQPCorpus)) {
|
|
| 96 |
// System.out.println(TXMUIMessages.selectionIsNotACorpusColon+secondElement);
|
|
| 97 |
// return null;
|
|
| 98 |
// }
|
|
| 97 | 99 |
|
| 98 | 100 |
final CQPCorpus corpus = (CQPCorpus) firstElement; |
| 99 | 101 |
try {
|
| ... | ... | |
| 102 | 104 |
catch (InterruptedException e2) {
|
| 103 | 105 |
// TODO Auto-generated catch block |
| 104 | 106 |
e2.printStackTrace(); |
| 107 |
return null; |
|
| 105 | 108 |
} |
| 106 |
// final CQPCorpus corpus2 = (CQPCorpus) secondElement;
|
|
| 107 |
// corpus2.compute(false);
|
|
| 109 |
// final CQPCorpus corpus2 = (CQPCorpus) secondElement;
|
|
| 110 |
// corpus2.compute(false);
|
|
| 108 | 111 |
|
| 109 | 112 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); |
| 110 | 113 |
final SetOperationsDialog d = new SetOperationsDialog(shell, "INTER", corpus); |
| ... | ... | |
| 112 | 115 |
if (code == Window.OK) {
|
| 113 | 116 |
JobHandler jobhandler = new JobHandler(NLS.bind( |
| 114 | 117 |
TXMUIMessages.creatingASubcorpusOnP0, corpus.getName())) {
|
| 118 |
|
|
| 115 | 119 |
@Override |
| 116 |
protected IStatus run(IProgressMonitor monitor) {
|
|
| 120 |
protected IStatus run(IProgressMonitor monitor) {
|
|
| 117 | 121 |
this.runInit(monitor); |
| 118 | 122 |
JobsTimer.start(); |
| 119 | 123 |
try {
|
| ... | ... | |
| 123 | 127 |
if (name.length() == 0) {
|
| 124 | 128 |
name = d.getDefaultName(); |
| 125 | 129 |
} |
| 126 |
|
|
| 130 |
|
|
| 127 | 131 |
AbstractCqiClient cqi = CQPSearchEngine.getCqiClient(); |
| 128 | 132 |
|
| 129 |
String cqpid = "S"+Subcorpus.getNextSubcorpusCounter();
|
|
| 133 |
String cqpid = "S" + Subcorpus.getNextSubcorpusCounter();
|
|
| 130 | 134 |
CQPCorpus[] order = d.getCorpusOrder(); |
| 131 | 135 |
order[1].compute(false); |
| 132 |
String query = cqpid+"=intersect "+order[0].getQualifiedCqpId()+" "+order[1].getQualifiedCqpId()+";";
|
|
| 133 |
System.out.println("QUERY="+query);
|
|
| 136 |
String query = cqpid + "=intersect " + order[0].getQualifiedCqpId() + " " + order[1].getQualifiedCqpId() + ";";
|
|
| 137 |
System.out.println("QUERY=" + query);
|
|
| 134 | 138 |
cqi.query(query); |
| 135 |
|
|
| 136 |
System.out.println("END QUERY="+order[0].getMainCorpus()+":"+cqpid);
|
|
| 137 |
if (cqi.subCorpusSize(order[0].getMainCorpus()+":"+cqpid) == 0) {
|
|
| 139 |
|
|
| 140 |
System.out.println("END QUERY=" + order[0].getMainCorpus() + ":" + cqpid);
|
|
| 141 |
if (cqi.subCorpusSize(order[0].getMainCorpus() + ":" + cqpid) == 0) {
|
|
| 138 | 142 |
Log.info("The created subcorpus was empty. Aborting.");
|
| 139 | 143 |
return Status.CANCEL_STATUS; |
| 140 | 144 |
} |
| ... | ... | |
| 148 | 152 |
|
| 149 | 153 |
System.out.println(NLS.bind(TXMUIMessages.doneColonP0Created, subcorpus.getName())); |
| 150 | 154 |
monitor.worked(50); |
| 151 |
|
|
| 155 |
|
|
| 152 | 156 |
monitor.subTask(TXMUIMessages.refreshingCorpora); |
| 153 |
final Subcorpus subcorpus2 = subcorpus;
|
|
| 157 |
final Subcorpus subcorpus2 = subcorpus; |
|
| 154 | 158 |
syncExec(new Runnable() {
|
| 159 |
|
|
| 155 | 160 |
@Override |
| 156 | 161 |
public void run() {
|
| 157 | 162 |
CorporaView.refresh(); |
| 158 | 163 |
CorporaView.expand(subcorpus2.getParent()); |
| 159 | 164 |
} |
| 160 | 165 |
}); |
| 161 |
|
|
| 166 |
|
|
| 162 | 167 |
monitor.worked(100); |
| 163 |
} catch (ThreadDeath td) {
|
|
| 168 |
} |
|
| 169 |
catch (ThreadDeath td) {
|
|
| 164 | 170 |
return Status.CANCEL_STATUS; |
| 165 |
} catch (Exception e) {
|
|
| 171 |
} |
|
| 172 |
catch (Exception e) {
|
|
| 166 | 173 |
org.txm.utils.logger.Log.printStackTrace(e); |
| 167 | 174 |
Log.severe(e.toString()); |
| 168 | 175 |
|
| 169 | 176 |
try {
|
| 170 | 177 |
System.out.println(NLS.bind(CQPSearchEngineCoreMessages.lastCQPErrorColon, CQPSearchEngine.getCqiClient().getLastCQPError())); |
| 171 |
} catch (Exception e1) {
|
|
| 172 |
System.out.println(TXMUIMessages.failedToGetLastCQPErrorColon+e1); |
|
| 178 |
} |
|
| 179 |
catch (Exception e1) {
|
|
| 180 |
System.out.println(TXMUIMessages.failedToGetLastCQPErrorColon + e1); |
|
| 173 | 181 |
org.txm.utils.logger.Log.printStackTrace(e1); |
| 174 | 182 |
} |
| 175 |
} finally {
|
|
| 183 |
} |
|
| 184 |
finally {
|
|
| 176 | 185 |
monitor.done(); |
| 177 | 186 |
JobsTimer.stopAndPrint(); |
| 178 |
}
|
|
| 187 |
} |
|
| 179 | 188 |
return Status.OK_STATUS; |
| 180 | 189 |
} |
| 181 | 190 |
}; |
| ... | ... | |
| 183 | 192 |
} |
| 184 | 193 |
return null; |
| 185 | 194 |
} |
| 186 |
} |
|
| 195 |
} |
|
Formats disponibles : Unified diff