Révision 3672
| TXM/trunk/bundles/org.txm.libs.deptreeviz/src/org/txm/libs/deptreeviz/UDPrintTree.java (revision 3672) | ||
|---|---|---|
| 1 |
package org.txm.libs.deptreeviz; |
|
| 2 |
|
|
| 3 |
import java.io.File; |
|
| 4 |
import java.io.IOException; |
|
| 5 |
import java.io.PrintWriter; |
|
| 6 |
import java.lang.reflect.Field; |
|
| 7 |
import java.util.ArrayList; |
|
| 8 |
import java.util.Arrays; |
|
| 9 |
import java.util.List; |
|
| 10 |
|
|
| 11 |
import io.gitlab.nats.deptreeviz.DepTree; |
|
| 12 |
import io.gitlab.nats.deptreeviz.SimpleParse; |
|
| 13 |
import io.gitlab.nats.deptreeviz.SimpleWord; |
|
| 14 |
|
|
| 15 |
public class UDPrintTree {
|
|
| 16 |
|
|
| 17 |
public static File print(File file, List<String> conll, String[] Tvalues, String[] NTvalues) {
|
|
| 18 |
|
|
| 19 |
try {
|
|
| 20 |
PrintWriter pw = new PrintWriter(file); |
|
| 21 |
|
|
| 22 |
SimpleParse p = SimpleParse.fromConll(conll); |
|
| 23 |
List<SimpleWord> words = p.getWords(); |
|
| 24 |
List<String> labels = p.getVerticesLabels().get("SYN");
|
|
| 25 |
if (Tvalues != null && Tvalues.length == words.size()) {
|
|
| 26 |
|
|
| 27 |
for (int i = 0; i < words.size(); i++) {
|
|
| 28 |
SimpleWord w = words.get(i); |
|
| 29 |
|
|
| 30 |
Field fword = SimpleWord.class.getDeclaredField("word");
|
|
| 31 |
fword.setAccessible(true); |
|
| 32 |
fword.set(w, w.getWord() + "/" + Tvalues[i]); |
|
| 33 |
} |
|
| 34 |
} |
|
| 35 |
|
|
| 36 |
if (NTvalues != null && NTvalues.length == words.size()) {
|
|
| 37 |
ArrayList<String> tmp = (ArrayList) labels; |
|
| 38 |
tmp.clear(); |
|
| 39 |
for (int i = 0; i < words.size(); i++) {
|
|
| 40 |
tmp.add(NTvalues[i]); |
|
| 41 |
} |
|
| 42 |
} |
|
| 43 |
DepTree<SimpleParse, SimpleWord> dt = new DepTree<SimpleParse, SimpleWord>(p); |
|
| 44 |
// dt.setShowingReferent(true); |
|
| 45 |
// dt.setShowingCat(true); |
|
| 46 |
dt.writeTree(pw); |
|
| 47 |
// w.close(); |
|
| 48 |
return file; |
|
| 49 |
} |
|
| 50 |
catch (Throwable e) {
|
|
| 51 |
// TODO Auto-generated catch block |
|
| 52 |
e.printStackTrace(); |
|
| 53 |
} |
|
| 54 |
return null; |
|
| 55 |
} |
|
| 56 |
|
|
| 57 |
public static void main(String[] args) throws IOException {
|
|
| 58 |
|
|
| 59 |
File file = File.createTempFile("txm", ".svg", new File("/home/mdecorde"));
|
|
| 60 |
|
|
| 61 |
List<String> conll = Arrays.asList( |
|
| 62 |
"1 Ce ce PRON _ Number=Sing|Person=3|PronType=Dem 2 nsubj _ _", |
|
| 63 |
"2 doit devoir VERB _ Mood=Ind|Number=Sing|Person=3|Tense=Pres|VerbForm=Fin 0 root _ _", |
|
| 64 |
"3 être être AUX _ VerbForm=Inf 5 cop _ _", |
|
| 65 |
"4 un un DET _ Definite=Ind|Gender=Masc|Number=Sing|PronType=Art 5 det _ _", |
|
| 66 |
"5 général général NOUN _ Gender=Masc|Number=Sing 2 xcomp _ _", |
|
| 67 |
"6 étranger étranger ADJ _ Gender=Masc|Number=Sing 5 amod _ _", |
|
| 68 |
"7 . . PUNCT _ _ 2 punct _ _"); |
|
| 69 |
|
|
| 70 |
|
|
| 71 |
System.out.println("FILE: " + print(file, conll, null, null));
|
|
| 72 |
} |
|
| 73 |
|
|
| 74 |
} |
|
| TXM/trunk/bundles/org.txm.libs.deptreeviz/src/org/txm/libs/deptreeviz/UDDepTreeVizPrintTree.java (revision 3672) | ||
|---|---|---|
| 1 |
package org.txm.libs.deptreeviz; |
|
| 2 |
|
|
| 3 |
import java.io.File; |
|
| 4 |
import java.io.IOException; |
|
| 5 |
import java.io.PrintWriter; |
|
| 6 |
import java.lang.reflect.Field; |
|
| 7 |
import java.util.ArrayList; |
|
| 8 |
import java.util.Arrays; |
|
| 9 |
import java.util.List; |
|
| 10 |
|
|
| 11 |
import io.gitlab.nats.deptreeviz.DepTree; |
|
| 12 |
import io.gitlab.nats.deptreeviz.SimpleParse; |
|
| 13 |
import io.gitlab.nats.deptreeviz.SimpleWord; |
|
| 14 |
|
|
| 15 |
public class UDDepTreeVizPrintTree {
|
|
| 16 |
|
|
| 17 |
public static File print(File file, List<String> conll, String[] Tvalues, String[] NTvalues) {
|
|
| 18 |
|
|
| 19 |
try {
|
|
| 20 |
PrintWriter pw = new PrintWriter(file); |
|
| 21 |
|
|
| 22 |
SimpleParse p = SimpleParse.fromConll(conll); |
|
| 23 |
List<SimpleWord> words = p.getWords(); |
|
| 24 |
List<String> labels = p.getVerticesLabels().get("SYN");
|
|
| 25 |
|
|
| 26 |
if (Tvalues != null && Tvalues.length == words.size()) {
|
|
| 27 |
|
|
| 28 |
for (int i = 0; i < words.size(); i++) {
|
|
| 29 |
SimpleWord w = words.get(i); |
|
| 30 |
|
|
| 31 |
Field fword = SimpleWord.class.getDeclaredField("word");
|
|
| 32 |
fword.setAccessible(true); |
|
| 33 |
|
|
| 34 |
if (Tvalues[i] != null) {
|
|
| 35 |
fword.set(w, w.getWord() + " / " + Tvalues[i]); |
|
| 36 |
} else {
|
|
| 37 |
fword.set(w, w.getWord()); |
|
| 38 |
} |
|
| 39 |
} |
|
| 40 |
} |
|
| 41 |
|
|
| 42 |
if (NTvalues != null && NTvalues.length == words.size()) {
|
|
| 43 |
ArrayList<String> tmp = (ArrayList) labels; |
|
| 44 |
for (int i = 0; i < words.size(); i++) {
|
|
| 45 |
if (NTvalues[i] != null) {
|
|
| 46 |
tmp.set(i, tmp.get(i) + " / " + NTvalues[i]); |
|
| 47 |
} |
|
| 48 |
} |
|
| 49 |
p.getVerticesLabels().put("SYN", tmp);
|
|
| 50 |
} |
|
| 51 |
DepTree<SimpleParse, SimpleWord> dt = new DepTree<SimpleParse, SimpleWord>(p); |
|
| 52 |
// dt.setShowingReferent(true); |
|
| 53 |
// dt.setShowingCat(true); |
|
| 54 |
dt.writeTree(pw); |
|
| 55 |
// w.close(); |
|
| 56 |
return file; |
|
| 57 |
} |
|
| 58 |
catch (Throwable e) {
|
|
| 59 |
// TODO Auto-generated catch block |
|
| 60 |
e.printStackTrace(); |
|
| 61 |
} |
|
| 62 |
return null; |
|
| 63 |
} |
|
| 64 |
|
|
| 65 |
public static void main(String[] args) throws IOException {
|
|
| 66 |
|
|
| 67 |
File file = File.createTempFile("txm", ".svg", new File("/home/mdecorde"));
|
|
| 68 |
|
|
| 69 |
List<String> conll = Arrays.asList( |
|
| 70 |
"1 Ce ce PRON _ Number=Sing|Person=3|PronType=Dem 2 nsubj _ _", |
|
| 71 |
"2 doit devoir VERB _ Mood=Ind|Number=Sing|Person=3|Tense=Pres|VerbForm=Fin 0 root _ _", |
|
| 72 |
"3 être être AUX _ VerbForm=Inf 5 cop _ _", |
|
| 73 |
"4 un un DET _ Definite=Ind|Gender=Masc|Number=Sing|PronType=Art 5 det _ _", |
|
| 74 |
"5 général général NOUN _ Gender=Masc|Number=Sing 2 xcomp _ _", |
|
| 75 |
"6 étranger étranger ADJ _ Gender=Masc|Number=Sing 5 amod _ _", |
|
| 76 |
"7 . . PUNCT _ _ 2 punct _ _"); |
|
| 77 |
|
|
| 78 |
|
|
| 79 |
System.out.println("FILE: " + print(file, conll, null, null));
|
|
| 80 |
} |
|
| 81 |
|
|
| 82 |
} |
|
| 0 | 83 | |
| TXM/trunk/bundles/org.txm.treesearch.core/src/org/txm/treesearch/function/TreeSearch.java (revision 3672) | ||
|---|---|---|
| 38 | 38 |
protected List<String> T; |
| 39 | 39 |
|
| 40 | 40 |
@Parameter(key = TreeSearchPreferences.NTFEATURE) |
| 41 |
protected String NT;
|
|
| 41 |
protected List<String> NT;
|
|
| 42 | 42 |
|
| 43 | 43 |
@Parameter(key = TreeSearchPreferences.VISUALISATION) |
| 44 | 44 |
protected String pVisualisation; |
| ... | ... | |
| 96 | 96 |
|
| 97 | 97 |
public abstract int getNSubGraph(int matchNo); |
| 98 | 98 |
|
| 99 |
public final String getNT() {
|
|
| 99 |
public final List<String> getNT() {
|
|
| 100 | 100 |
return NT; |
| 101 | 101 |
} |
| 102 | 102 |
|
| ... | ... | |
| 139 | 139 |
@Override |
| 140 | 140 |
public abstract boolean setParameters(TXMParameters parameters); |
| 141 | 141 |
|
| 142 |
public abstract boolean toSVG(File svgFile, int sent, int sub, List<String> T, String NT);
|
|
| 142 |
public abstract boolean toSVG(File svgFile, int sent, int sub, List<String> T, List<String> nT2);
|
|
| 143 | 143 |
|
| 144 | 144 |
public abstract boolean isReady(); |
| 145 | 145 |
|
| TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/editors/imports/sections/CommandsSection.java (revision 3672) | ||
|---|---|---|
| 38 | 38 |
private Text referencePatternProperties; |
| 39 | 39 |
|
| 40 | 40 |
public CommandsSection(ImportFormEditor editor, FormToolkit toolkit2, ScrolledForm form2, Composite parent, int style) {
|
| 41 |
|
|
| 41 | 42 |
super(editor, toolkit2, form2, parent, style, "commands"); |
| 42 | 43 |
|
| 43 | 44 |
this.section.setText(TXMUIMessages.commands); |
| TXM/trunk/bundles/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 3672) | ||
|---|---|---|
| 11 | 11 |
import java.util.List; |
| 12 | 12 |
import java.util.Set; |
| 13 | 13 |
|
| 14 |
import org.apache.commons.lang.StringUtils; |
|
| 14 | 15 |
import org.eclipse.core.runtime.IConfigurationElement; |
| 15 | 16 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 16 | 17 |
import org.eclipse.core.runtime.ISafeRunnable; |
| ... | ... | |
| 1656 | 1657 |
value = new ArrayList<>(); |
| 1657 | 1658 |
} |
| 1658 | 1659 |
} |
| 1660 |
} |
|
| 1661 |
else if (object instanceof org.eclipse.swt.widgets.List) {
|
|
| 1659 | 1662 |
|
| 1660 |
// else if (value instanceof List) {
|
|
| 1661 |
// if (!s.isEmpty()) {
|
|
| 1662 |
// value = new ArrayList<>(Arrays.asList(s.split(",")));
|
|
| 1663 |
// } |
|
| 1664 |
// } |
|
| 1663 |
org.eclipse.swt.widgets.List l =(org.eclipse.swt.widgets.List)object; |
|
| 1664 |
|
|
| 1665 |
String[] s = l.getSelection(); |
|
| 1666 |
Class<?> clazz = targetField.getType(); |
|
| 1667 |
if (clazz.equals(String.class)) {
|
|
| 1668 |
value = StringUtils.join(s, ", "); |
|
| 1669 |
} else if (clazz.equals(List.class)) {
|
|
| 1670 |
value = new ArrayList<>(Arrays.asList(s)); |
|
| 1671 |
} |
|
| 1672 |
|
|
| 1665 | 1673 |
} |
| 1666 | 1674 |
else {
|
| 1667 | 1675 |
value = object; |
| TXM/trunk/bundles/org.txm.conllu.rcp/src/org/txm/conllu/rcp/importsection/CoNLLUSection.java (revision 3672) | ||
|---|---|---|
| 80 | 80 |
gdata2.colspan = 4; // one line |
| 81 | 81 |
keepWordContractionsButton.setLayoutData(gdata2); |
| 82 | 82 |
|
| 83 |
udPropertiesPrefixButton = toolkit.createText(sectionClient, "UD properties prefix", SWT.CHECK); |
|
| 83 |
Label tmp5Label = toolkit.createLabel(sectionClient, "UD properties prefix"); |
|
| 84 |
tmp5Label.setToolTipText("The prefix of the CQP properties containing the UD properties");
|
|
| 85 |
tmp5Label.setLayoutData(getLabelGridData()); |
|
| 86 |
|
|
| 87 |
udPropertiesPrefixButton = toolkit.createText(sectionClient, "UD properties prefix", SWT.BORDER); |
|
| 84 | 88 |
gdata2 = getButtonLayoutData(); |
| 85 |
gdata2.colspan = 4; // one line
|
|
| 89 |
gdata2.colspan = 3; // one line
|
|
| 86 | 90 |
udPropertiesPrefixButton.setLayoutData(gdata2); |
| 87 | 91 |
|
| 88 | 92 |
Label tmp4Label = toolkit.createLabel(sectionClient, "Head properties to project"); |
| ... | ... | |
| 115 | 119 |
buildTIGERIndexesButton.setSelection(customNode.getBoolean(UDPreferences.IMPORT_BUILD_TIGERSEARCH_INDEXES, UDPreferences.getInstance().getBoolean(UDPreferences.IMPORT_BUILD_TIGERSEARCH_INDEXES))); //$NON-NLS-1$ |
| 116 | 120 |
useNewDocIdButton.setSelection(customNode.getBoolean(UDPreferences.IMPORT_USE_NEW_DOC_ID, UDPreferences.getInstance().getBoolean(UDPreferences.IMPORT_USE_NEW_DOC_ID))); //$NON-NLS-1$ |
| 117 | 121 |
keepWordContractionsButton.setSelection(customNode.getBoolean(UDPreferences.KEEP_CONTRACTIONS, UDPreferences.getInstance().getBoolean(UDPreferences.KEEP_CONTRACTIONS))); //$NON-NLS-1$ |
| 118 |
udPropertiesPrefixButton.setText(customNode.get(UDPreferences.UDPREFIX, "")); //$NON-NLS-1$
|
|
| 122 |
udPropertiesPrefixButton.setText(customNode.get(UDPreferences.UDPREFIX, UDPreferences.getInstance().getString(UDPreferences.UDPREFIX))); //$NON-NLS-1$
|
|
| 119 | 123 |
headPropertiesText.setText(customNode.get(UDPreferences.IMPORT_HEAD_TO_PROJECT, UDPreferences.getInstance().getString(UDPreferences.IMPORT_HEAD_TO_PROJECT))); //$NON-NLS-1$ |
| 120 | 124 |
depsPropertiesText.setText(customNode.get(UDPreferences.IMPORT_DEPS_TO_PROJECT, UDPreferences.getInstance().getString(UDPreferences.IMPORT_DEPS_TO_PROJECT))); //$NON-NLS-1$ |
| 121 | 125 |
} |
| TXM/trunk/bundles/org.txm.tigersearch.rcp/src/org/txm/function/tigersearch/TIGERSearch.java (revision 3672) | ||
|---|---|---|
| 99 | 99 |
return tsresult != null && T != null && NT != null; |
| 100 | 100 |
} |
| 101 | 101 |
|
| 102 |
public boolean toSVG(File svgFile, int sent, int sub, List<String> T, String NT) {
|
|
| 102 |
public boolean toSVG(File svgFile, int sent, int sub, List<String> T, List<String> NT) {
|
|
| 103 | 103 |
|
| 104 | 104 |
if (tsresult == null) return false; // no result |
| 105 |
|
|
| 105 | 106 |
this.T = T; |
| 106 | 107 |
this.NT = NT; |
| 107 | 108 |
|
| 108 | 109 |
if (tsresult.getNumberOfMatch() == 0) return false; |
| 109 | 110 |
|
| 110 |
tsresult.setDisplayProperties(T, NT); |
|
| 111 |
if (NT.size() > 0) {
|
|
| 112 |
tsresult.setDisplayProperties(T, NT.get(0)); |
|
| 113 |
} else {
|
|
| 114 |
tsresult.setDisplayProperties(T, null); |
|
| 115 |
} |
|
| 111 | 116 |
|
| 112 | 117 |
try {
|
| 113 | 118 |
// iterate to the sub th subgraph |
| TXM/trunk/bundles/org.txm.treesearch.rcp/src/org/txm/treesearch/editor/TreeSearchEditor.java (revision 3672) | ||
|---|---|---|
| 1 | 1 |
package org.txm.treesearch.editor; |
| 2 | 2 |
|
| 3 | 3 |
import java.io.File; |
| 4 |
import java.io.IOException; |
|
| 5 | 4 |
import java.util.ArrayList; |
| 6 | 5 |
import java.util.Arrays; |
| 7 | 6 |
import java.util.HashMap; |
| ... | ... | |
| 19 | 18 |
import org.eclipse.swt.widgets.Combo; |
| 20 | 19 |
import org.eclipse.swt.widgets.Composite; |
| 21 | 20 |
import org.eclipse.swt.widgets.Event; |
| 22 |
import org.eclipse.swt.widgets.Group; |
|
| 23 | 21 |
import org.eclipse.swt.widgets.Label; |
| 24 | 22 |
import org.eclipse.swt.widgets.Listener; |
| 25 | 23 |
import org.eclipse.swt.widgets.Spinner; |
| ... | ... | |
| 32 | 30 |
import org.txm.core.results.Parameter; |
| 33 | 31 |
import org.txm.edition.rcp.handlers.OpenEdition; |
| 34 | 32 |
import org.txm.rcp.IImageKeys; |
| 35 |
import org.txm.rcp.editors.ITXMResultEditor; |
|
| 36 | 33 |
import org.txm.rcp.editors.TXMBrowserEditor; |
| 37 | 34 |
import org.txm.rcp.editors.TXMEditor; |
| 38 | 35 |
import org.txm.rcp.editors.TXMResultEditorInput; |
| ... | ... | |
| 85 | 82 |
private Label sentCounterLabel; |
| 86 | 83 |
|
| 87 | 84 |
@Parameter(key = TreeSearchPreferences.NTFEATURE) |
| 88 |
private Combo NTCombo;
|
|
| 85 |
private org.eclipse.swt.widgets.List NTCombo;
|
|
| 89 | 86 |
|
| 90 | 87 |
@Parameter(key = TreeSearchPreferences.TFEATURE) |
| 91 |
private Combo TCombo;
|
|
| 88 |
private org.eclipse.swt.widgets.List TCombo;
|
|
| 92 | 89 |
|
| 93 | 90 |
private Combo representationCombo; |
| 94 | 91 |
|
| ... | ... | |
| 222 | 219 |
l1.setText("T "); //$NON-NLS-1$
|
| 223 | 220 |
l1.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); |
| 224 | 221 |
|
| 225 |
TCombo = new Combo(line2, SWT.READ_ONLY|SWT.MULTI);
|
|
| 222 |
TCombo = new org.eclipse.swt.widgets.List(line2, SWT.READ_ONLY|SWT.MULTI);
|
|
| 226 | 223 |
GridData gdata = new GridData(SWT.FILL, SWT.CENTER, true, true); |
| 227 | 224 |
TCombo.setLayoutData(gdata); |
| 228 | 225 |
TCombo.addSelectionListener(selChangedListener); |
| ... | ... | |
| 231 | 228 |
l2.setText("NT "); //$NON-NLS-1$
|
| 232 | 229 |
l2.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); |
| 233 | 230 |
|
| 234 |
NTCombo = new Combo(line2, SWT.READ_ONLY);
|
|
| 231 |
NTCombo = new org.eclipse.swt.widgets.List(line2, SWT.READ_ONLY|SWT.MULTI);
|
|
| 235 | 232 |
gdata = new GridData(SWT.FILL, SWT.CENTER, true, true); |
| 236 | 233 |
NTCombo.setLayoutData(gdata); |
| 237 | 234 |
NTCombo.addSelectionListener(selChangedListener); |
| 238 | 235 |
|
| 239 |
|
|
| 240 | 236 |
// bottom toolbar |
| 241 | 237 |
|
| 242 | 238 |
GLComposite navigationAreaComposite = getBottomToolbar().installGLComposite(ConcordanceUIMessages.navigation, 12, false); |
| ... | ... | |
| 387 | 383 |
if (tFeatures.length > 0) {
|
| 388 | 384 |
TCombo.setItems(tFeatures); |
| 389 | 385 |
//TCombo.setText(ts.getT()); |
| 386 |
if (ts.getT() != null) {
|
|
| 387 |
TCombo.setSelection(ts.getT().toArray(new String[ts.getT().size()])); |
|
| 388 |
} |
|
| 390 | 389 |
} |
| 391 | 390 |
|
| 392 | 391 |
String[] ntFeatures = ts.getAvailableNTProperties(); |
| 393 | 392 |
if (ntFeatures.length > 0) {
|
| 394 | 393 |
NTCombo.setItems(ntFeatures); |
| 395 |
NTCombo.setText(ts.getNT()); |
|
| 394 |
//NTCombo.setText(ts.getNT()); |
|
| 395 |
//NTCombo.setSelection(Arrays.binarySearch(ntFeatures, ts.getNT())); |
|
| 396 |
if (ts.getNT() != null) {
|
|
| 397 |
NTCombo.setSelection(ts.getNT().toArray(new String[ts.getNT().size()])); |
|
| 398 |
} |
|
| 396 | 399 |
NTCombo.setEnabled(true); |
| 397 | 400 |
} |
| 398 | 401 |
else {
|
| 399 | 402 |
NTCombo.removeAll(); |
| 400 |
NTCombo.setText("");
|
|
| 403 |
//NTCombo.setText("");
|
|
| 401 | 404 |
NTCombo.setEnabled(false); |
| 402 | 405 |
} |
| 403 | 406 |
|
| ... | ... | |
| 443 | 446 |
if (ts.hasSubMatchesStrategy()) subCounterLabel.setText(Messages.NoSubGraph); |
| 444 | 447 |
} |
| 445 | 448 |
|
| 446 |
if (ts.isDrawn()) {
|
|
| 449 |
if (!ts.isDrawn()) {
|
|
| 447 | 450 |
sentSpinner.setSelection(ts.getCurrentMatchIndex() + 1); |
| 448 | 451 |
sentSpinner.setMaximum(ts.getNSentences()); |
| 449 | 452 |
// if (ts.hasSubMatchesStrategy()) {
|
| ... | ... | |
| 550 | 553 |
*/ |
| 551 | 554 |
private boolean reloadGraph() {
|
| 552 | 555 |
|
| 553 |
List<String> T = null; |
|
| 554 |
if (TCombo.getText().isEmpty()) {
|
|
| 555 |
T = new ArrayList<String>(); |
|
| 556 |
} else {
|
|
| 557 |
T = Arrays.asList(TCombo.getText().split(", "));
|
|
| 558 |
} |
|
| 559 |
String NT = NTCombo.getText(); |
|
| 556 |
// List<String> T = null; |
|
| 557 |
// if (TCombo.getSelection().length() == 0) {
|
|
| 558 |
// T = new ArrayList<String>(); |
|
| 559 |
// } else {
|
|
| 560 |
// |
|
| 561 |
// } |
|
| 562 |
List<String> T = Arrays.asList(TCombo.getSelection()); |
|
| 563 |
List<String> NT = Arrays.asList(NTCombo.getSelection()); |
|
| 560 | 564 |
int sent = sentSpinner.getSelection() - 1; |
| 561 | 565 |
int sub = 0; |
| 562 | 566 |
|
| TXM/trunk/bundles/org.txm.conllu.core/src/org/txm/conllu/core/function/UDSearch.java (revision 3672) | ||
|---|---|---|
| 11 | 11 |
import org.txm.conllu.core.preferences.UDPreferences; |
| 12 | 12 |
import org.txm.conllu.core.preferences.UDTreePreferences; |
| 13 | 13 |
import org.txm.core.results.TXMParameters; |
| 14 |
import org.txm.libs.deptreeviz.UDPrintTree; |
|
| 14 |
import org.txm.libs.deptreeviz.UDDepTreeVizPrintTree;
|
|
| 15 | 15 |
import org.txm.searchengine.core.Selection; |
| 16 | 16 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
| 17 | 17 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| ... | ... | |
| 63 | 63 |
} |
| 64 | 64 |
|
| 65 | 65 |
@Override |
| 66 |
public boolean toSVG(File svgFile, int sent, int sub, List<String> T, String NT) {
|
|
| 66 |
public boolean toSVG(File svgFile, int sent, int sub, List<String> T, List<String> NT) {
|
|
| 67 | 67 |
|
| 68 | 68 |
if (!isDrawn()) return false; // no result |
| 69 | 69 |
try {
|
| ... | ... | |
| 91 | 91 |
String prefix = UDPreferences.getInstance().getProjectPreferenceValue(corpus.getProject(), UDPreferences.UDPREFIX, UDPreferences.getInstance().getString(UDPreferences.UDPREFIX)); |
| 92 | 92 |
|
| 93 | 93 |
String[] Tvalues = new String[positions.length]; |
| 94 |
for (int i = 0 ; i < Tvalues.length ; i++) {
|
|
| 95 |
Tvalues[i] += ""; |
|
| 96 |
} |
|
| 97 | 94 |
|
| 95 |
|
|
| 98 | 96 |
if (T != null && T.size() > 0) {
|
| 97 |
for (int i = 0 ; i < Tvalues.length ; i++) {
|
|
| 98 |
Tvalues[i] = ""; |
|
| 99 |
} |
|
| 99 | 100 |
for (int iT = 0 ; iT < T.size() ; iT++) {
|
| 100 | 101 |
String t = T.get(iT); |
| 101 | 102 |
if (corpus.getProperty(t) != null) {
|
| 102 | 103 |
String[] tvalues = corpus.getProperty(t).cpos2Str(positions); |
| 103 | 104 |
for (int i = 0 ; i < tvalues.length ; i++) {
|
| 104 |
if (iT > 0) Tvalues[i] += "/";
|
|
| 105 |
if (iT > 0) Tvalues[i] += " / ";
|
|
| 105 | 106 |
Tvalues[i] += tvalues[i]; |
| 106 | 107 |
} |
| 107 | 108 |
} |
| 108 | 109 |
} |
| 109 | 110 |
} |
| 110 | 111 |
|
| 111 |
String[] NTvalues = null; |
|
| 112 |
if (NT != null && corpus.getProperty(NT) != null) {
|
|
| 113 |
NTvalues = corpus.getProperty(NT).cpos2Str(positions); |
|
| 112 |
String[] NTvalues = new String[positions.length]; |
|
| 113 |
if (NT != null && NT.size() > 0) {
|
|
| 114 |
for (int i = 0 ; i < NTvalues.length ; i++) {
|
|
| 115 |
NTvalues[i] = ""; |
|
| 116 |
} |
|
| 117 |
for (int iNT = 0 ; iNT < NT.size() ; iNT++) {
|
|
| 118 |
String nt = NT.get(iNT); |
|
| 119 |
if (corpus.getProperty(nt) != null) {
|
|
| 120 |
String[] ntvalues = corpus.getProperty(nt).cpos2Str(positions); |
|
| 121 |
for (int i = 0 ; i < ntvalues.length ; i++) {
|
|
| 122 |
if (iNT > 0) NTvalues[i] += " / "; |
|
| 123 |
NTvalues[i] += ntvalues[i]; |
|
| 124 |
} |
|
| 125 |
} |
|
| 126 |
} |
|
| 114 | 127 |
} |
| 128 |
|
|
| 129 |
|
|
| 130 |
// if (NT != null && corpus.getProperty(NT) != null) {
|
|
| 131 |
// NTvalues = corpus.getProperty(NT).cpos2Str(positions); |
|
| 132 |
// } |
|
| 115 | 133 |
HashMap<String, String[]> values = new HashMap<>(); |
| 116 | 134 |
for (String p : ImportCoNLLUAnnotations.UD_PROPERTY_NAMES) {
|
| 117 | 135 |
values.put(prefix+p, corpus.getProperty(prefix+p).cpos2Str(positions)); |
| ... | ... | |
| 139 | 157 |
if (UDTreePreferences.BRAT.equals(pVisualisation)) {
|
| 140 | 158 |
return BratPrintTree.print(svgFile, conll, Tvalues, NTvalues) != null; |
| 141 | 159 |
} else { // if (engine == null || UDTreePreferences.DEPTREEVIZ.equals(engine)) {
|
| 142 |
return UDPrintTree.print(svgFile, conll, Tvalues, NTvalues) != null; |
|
| 160 |
return UDDepTreeVizPrintTree.print(svgFile, conll, Tvalues, NTvalues) != null;
|
|
| 143 | 161 |
} |
| 144 | 162 |
} |
| 145 | 163 |
catch (Throwable e) {
|
| ... | ... | |
| 179 | 197 |
} |
| 180 | 198 |
} |
| 181 | 199 |
|
| 182 |
public String[] getAvailableNTProperties() {
|
|
| 183 |
return new String[0]; |
|
| 200 |
/** |
|
| 201 |
* UD words stores the T and NT values |
|
| 202 |
*/ |
|
| 203 |
public final String[] getAvailableNTProperties() {
|
|
| 204 |
return getAvailableTProperties(); |
|
| 184 | 205 |
} |
| 185 | 206 |
|
| 186 | 207 |
@Override |
Formats disponibles : Unified diff