Révision 2946

tmp/org.txm.concordance.core/src/org/txm/concordance/core/messages/messages_fr.properties (revision 2946)
4 4

  
5 5
RESULT_TYPE = Concordance
6 6

  
7
wordCorpusOrder = Ordre du corpus
8

  
7 9
compositeColon = Composé : 
8 10

  
9 11
concordanceOfP0InTheP1Corpus = Concordance de {0} dans le corpus {1}...
tmp/org.txm.concordance.core/src/org/txm/concordance/core/messages/ConcordanceCoreMessages.java (revision 2946)
13 13
public class ConcordanceCoreMessages extends NLS {
14 14

  
15 15
	private static final String BUNDLE_NAME = "org.txm.concordance.core.messages.messages"; //$NON-NLS-1$
16

  
16 17
	
18
	
17 19
	public static String RESULT_TYPE;
18 20

  
19
	
21
	public static String wordCorpusOrder;
20 22
	public static String failedToRetrieveTextidPropertyFromLines; 
21 23
	public static String failedToExportConcordanceColonP0; 
22 24
	public static String reference; 
tmp/org.txm.concordance.core/src/org/txm/concordance/core/messages/messages.properties (revision 2946)
3 3
#Tue Dec 18 10:24:08 CET 2018
4 4

  
5 5
RESULT_TYPE = Concordance
6

  
7
wordCorpusOrder = Corpus order
6 8

  
7 9
compositeColon = Composite: 
8 10

  
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/comparators/NullComparator.java (revision 2946)
1
// Copyright © 2010-2020 ENS de Lyon., University of Franche-Comté
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
25
// $LastChangedRevision: 2386 $
26
// $LastChangedBy: mdecorde $ 
27
//
28
package org.txm.concordance.core.functions.comparators;
29

  
30
import org.txm.concordance.core.functions.Line;
31
import org.txm.concordance.core.messages.ConcordanceCoreMessages;
32

  
33
// TODO: Auto-generated Javadoc
34
/**
35
 * return the order of the text.
36
 *
37
 * @author mdecorde
38
 */
39
public class NullComparator extends LocalizedLineComparator {
40

  
41
	/** The Constant NAME. */
42
	private static final String NAME = ConcordanceCoreMessages.none;
43

  
44
	/**
45
	 * Instantiates a new null comparator.
46
	 */
47
	public NullComparator() {
48
		super(NAME);
49
	}
50

  
51
	/* (non-Javadoc)
52
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
53
	 */
54
	@Override
55
	public int compare(Line l1, Line l2) {
56
		return l1.getKeywordPosition() - l2.getKeywordPosition();
57
	}
58
}
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/comparators/WordPositionComparator.java (revision 2946)
1
// Copyright © 2010-2020 ENS de Lyon., University of Franche-Comté
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
25
// $LastChangedRevision: 2386 $
26
// $LastChangedBy: mdecorde $ 
27
//
28
package org.txm.concordance.core.functions.comparators;
29

  
30
import org.txm.concordance.core.functions.Line;
31
import org.txm.concordance.core.messages.ConcordanceCoreMessages;
32

  
33
// TODO: Auto-generated Javadoc
34
/**
35
 * return the order of the text.
36
 *
37
 * @author mdecorde
38
 */
39
public class WordPositionComparator extends LocalizedLineComparator {
40

  
41
	/** The Constant NAME. */
42
	private static final String NAME = ConcordanceCoreMessages.wordCorpusOrder;
43

  
44
	/**
45
	 * Instantiates a new null comparator.
46
	 */
47
	public WordPositionComparator() {
48
		super(NAME);
49
	}
50

  
51
	/* (non-Javadoc)
52
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
53
	 */
54
	@Override
55
	public int compare(Line l1, Line l2) {
56
		return l1.getKeywordPosition() - l2.getKeywordPosition();
57
	}
58
}
0 59

  
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java (revision 2946)
1504 1504
		if (getNLines() == 0) {
1505 1505
			return;
1506 1506
		}
1507
		getLines(0, nLines - 1);
1507
		getLines(0, nLines - 1); // all lines are necessary to sort TODO: if fact only the sort properties are needed
1508 1508
		if (lines.size() > 0) {
1509 1509
			Collections.sort(lines, comparator);
1510 1510
		}
tmp/org.txm.concordance.core/src/org/txm/concordance/core/tests/TestConcordance.java (revision 2946)
11 11
import org.txm.concordance.core.functions.comparators.LexicographicLeftContextComparator;
12 12
import org.txm.concordance.core.functions.comparators.LexicographicRightContextComparator;
13 13
import org.txm.concordance.core.functions.comparators.LineComparator;
14
import org.txm.concordance.core.functions.comparators.NullComparator;
14
import org.txm.concordance.core.functions.comparators.WordPositionComparator;
15 15
import org.txm.concordance.core.functions.comparators.PropertiesReferenceComparator;
16 16
import org.txm.searchengine.cqp.ReferencePattern;
17 17
import org.txm.searchengine.cqp.corpus.CQPCorpus;
......
123 123
			
124 124
			if (sortBy != null) {
125 125
				LineComparator comparator;
126
				if ("null".equals(sortBy)) comparator = new NullComparator(); //$NON-NLS-1$
126
				if ("null".equals(sortBy)) comparator = new WordPositionComparator(); //$NON-NLS-1$
127 127
				else if ("lexicographic".equals(sortBy)) comparator = new LexicographicKeywordComparator(); //$NON-NLS-1$
128 128
				else if ("leftcontext".equals(sortBy)) comparator = new LexicographicLeftContextComparator(); //$NON-NLS-1$
129 129
				else if ("rightcontext".equals(sortBy)) comparator = new LexicographicRightContextComparator(); //$NON-NLS-1$
130 130
				else if ("reference".equals(sortBy)) comparator = new PropertiesReferenceComparator(); //$NON-NLS-1$
131
				else comparator = new NullComparator();
131
				else comparator = new WordPositionComparator();
132 132
				conc.sort(comparator, new TXMProgressMonitor(new LogMonitor()));
133 133
			}
134 134
			conc.toTxt(outfile, "UTF-8", "\t", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/BuildAFMetadataMacro.groovy (revision 2946)
37 37
	HashMap<String, String> columnsToRenameRules = new HashMap<>();
38 38
	HashMap<String, String[]> searchAndReplaceRules = new HashMap<>();
39 39
	
40
	String normalizePattern = "[ \p{P}\p{L}]"
41
	
40 42
	columnsSelection = Arrays.asList(
41 43
	"Identifiant de la notice", "Titre propre", "Notes du titre", "Date de diffusion", "Durée", "Nom fichier segmenté (info)", "antract_video",
42 44
	"antract_debut","antract_fin","antract_duree","antract_tc_type","antract_tc_date");
......
64 66
	HashMap<String, String> columnsToRenameRules = new HashMap<>();
65 67
	HashMap<String, String[]> searchAndReplaceRules = new HashMap<>();
66 68
	
69
	String normalizePattern = "[ \p{P}\p{L}]"
70
	
67 71
	columnsSelection = Arrays.asList(
68 72
		"Identifiant de la notice", "Titre propre", "Notes du titre", "Lien notice principale",
69 73
		"Date de diffusion", "Type de date", "Durée", "Genre", "Langue VO / VE", "Nature de production", "Producteurs (Aff.)", "Thématique",
70 74
		"Nom fichier segmenté (info)", "antract_video", "antract_debut", "antract_fin", "antract_duree", "antract_tc_type", "antract_tc_date",
71 75
		"Résumé", "Séquences", "Descripteurs (Aff. Lig.)", "Générique (Aff. Lig.)");
72 76
	
77
	
78
	
73 79
	lineRules.put("Type de notice", "Notice sujet");
74
	
80

  
81
	searchAndReplaceRules.put("textorder", ["([0-9][0-9])/([0-9][0-9])/([0-9][0-9][0-9][0-9])", '$3$2$1'] as String[]); // not working yet
82
	searchAndReplaceRules.put("annee", ["([0-9][0-9])/([0-9][0-9])/([0-9][0-9][0-9][0-9])", '$3'] as String[]); // not working yet
83
		
75 84
	process(excel, table2File, lineRules, columnsSelection, columnsToCopy, searchAndReplaceRules, columnsToRenameRules)
76 85
}
77 86

  
tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 2946)
26 26
package org.txm.concordance.rcp.editors;
27 27

  
28 28
import java.util.ArrayList;
29
import java.util.Arrays;
29 30
import java.util.List;
30 31
import java.util.Locale;
31 32

  
......
93 94
import org.txm.concordance.core.functions.comparators.LexicographicLeftContextComparator;
94 95
import org.txm.concordance.core.functions.comparators.LexicographicRightContextComparator;
95 96
import org.txm.concordance.core.functions.comparators.LineComparator;
96
import org.txm.concordance.core.functions.comparators.NullComparator;
97
import org.txm.concordance.core.functions.comparators.WordPositionComparator;
97 98
import org.txm.concordance.core.functions.comparators.PropertiesReferenceComparator;
98 99
import org.txm.concordance.core.functions.comparators.ReverseComparator;
99 100
import org.txm.concordance.core.preferences.ConcordancePreferences;
......
168 169
	
169 170
	/** The standard comparator class name. */
170 171
	private LineComparator[] standardComparatorClassName = {
171
			new NullComparator(), new LexicographicKeywordComparator(),
172
			new WordPositionComparator(), new LexicographicKeywordComparator(),
172 173
			new LexicographicLeftContextComparator(),
173 174
			new LexicographicRightContextComparator(),
174 175
			new PropertiesReferenceComparator() };
......
395 396
			@Override
396 397
			public void widgetSelected(SelectionEvent e) {
397 398
				
399
				
400
				
401
				
398 402
				StatusLine.setMessage(ConcordanceUIMessages.sortingReferenceColumn);
399 403
				LineComparator comparator = new PropertiesReferenceComparator();
404
				comparator.initialize(concordance.getCorpus());
405
				
406
				// add the corpus order key
407
				LineComparator cComparator = new CompositeComparator("current", Arrays.asList(comparator, standardComparatorClassName[0]));
408
				
400 409
				if (viewerLeft.getTable().getSortColumn() != referenceColumn) {
401 410
					viewerLeft.getTable().setSortColumn(null);
402 411
					viewerLeft.getTable().setSortColumn(referenceColumn);
......
404 413
				}
405 414
				else if (viewerLeft.getTable().getSortDirection() == SWT.UP) {
406 415
					viewerLeft.getTable().setSortDirection(SWT.DOWN);
407
					comparator = new ReverseComparator(comparator);
416
					cComparator = new ReverseComparator(cComparator);
408 417
				}
409 418
				else {
410 419
					viewerLeft.getTable().setSortDirection(SWT.UP);
411 420
				}
412
				comparator.initialize(concordance.getCorpus());
413
				currentComparator = comparator;
421
				
422
				currentComparator = cComparator;
423

  
414 424
				complexsorter.setKey(4);// set ref key
415 425
				sort();
416 426
				StatusLine.setMessage(""); //$NON-NLS-1$
......
517 527
				
518 528
				StatusLine.setMessage(ConcordanceUIMessages.sortingLeftContextColumn);
519 529
				LineComparator comparator = new LexicographicLeftContextComparator();
530
				comparator.initialize(concordance.getCorpus());
531
				
532
				// add the corpus order key
533
				LineComparator cComparator = new CompositeComparator("current", Arrays.asList(comparator, standardComparatorClassName[0]));
534
				
520 535
				if (viewerRight.getTable().getSortColumn() != leftContextColumn) {
521 536
					viewerRight.getTable().setSortColumn(leftContextColumn);
522 537
					viewerRight.getTable().setSortDirection(SWT.UP);
523 538
				}
524 539
				else if (viewerRight.getTable().getSortDirection() == SWT.UP) {
525 540
					viewerRight.getTable().setSortDirection(SWT.DOWN);
526
					comparator = new ReverseComparator(comparator);
541
					cComparator = new ReverseComparator(cComparator);
527 542
				}
528
				else
543
				else {
529 544
					viewerRight.getTable().setSortDirection(SWT.UP);
530
				comparator.initialize(concordance.getCorpus());
531
				currentComparator = comparator;
545
				}
546
				
547
				currentComparator = cComparator;
548
				
532 549
				complexsorter.setKey(2);// set ref key
533 550
				sort();
534 551
				StatusLine.setMessage(""); //$NON-NLS-1$
......
560 577
				
561 578
				StatusLine.setMessage(ConcordanceUIMessages.sortingKeywordColumn);
562 579
				LineComparator comparator = new LexicographicKeywordComparator();
580
				comparator.initialize(concordance.getCorpus());
581
				
582
				// add the corpus order key
583
				LineComparator cComparator = new CompositeComparator("current", Arrays.asList(comparator, standardComparatorClassName[0]));
584
				
563 585
				if (viewerRight.getTable().getSortColumn() != keywordColumn) {
564 586
					viewerRight.getTable().setSortColumn(keywordColumn);
565 587
					viewerRight.getTable().setSortDirection(SWT.UP);
566 588
				}
567 589
				else if (viewerRight.getTable().getSortDirection() == SWT.UP) {
568 590
					viewerRight.getTable().setSortDirection(SWT.DOWN);
569
					comparator = new ReverseComparator(comparator);
591
					cComparator = new ReverseComparator(cComparator);
570 592
				}
571 593
				else {
572 594
					viewerRight.getTable().setSortDirection(SWT.UP);
573 595
				}
574
				comparator.initialize(concordance.getCorpus());
575
				currentComparator = comparator;
596
				
597
				currentComparator = cComparator;
598
				
576 599
				complexsorter.setKey(1);// set ref key
577 600
				sort();
578 601
				StatusLine.setMessage(""); //$NON-NLS-1$
......
603 626
				
604 627
				StatusLine.setMessage(ConcordanceUIMessages.sortingRightContextColumn);
605 628
				LineComparator comparator = new LexicographicRightContextComparator();
629
				comparator.initialize(concordance.getCorpus());
606 630
				
631
				// add the corpus order key
632
				LineComparator cComparator = new CompositeComparator("current", Arrays.asList(comparator, standardComparatorClassName[0]));
633
				
607 634
				if (viewerRight.getTable().getSortColumn() != rightContextColumn) {
608 635
					viewerRight.getTable().setSortColumn(rightContextColumn);
609 636
				}
610 637
				else if (viewerRight.getTable().getSortDirection() == SWT.UP) {
611 638
					viewerRight.getTable().setSortDirection(SWT.DOWN);
612
					comparator = new ReverseComparator(comparator);
639
					cComparator = new ReverseComparator(cComparator);
613 640
				}
614 641
				else {
615 642
					viewerRight.getTable().setSortDirection(SWT.UP);
616 643
				}
617
				comparator.initialize(concordance.getCorpus());
618
				currentComparator = comparator;
644
				
645
				currentComparator = cComparator;
646
				
619 647
				complexsorter.setKey(3); // set ref key
620 648
				sort();
621 649
				StatusLine.setMessage(""); //$NON-NLS-1$
......
819 847
						
820 848
						JobsTimer.start();
821 849
						try {
822
							
823 850
							concordance.sort(currentComparator, new TXMProgressMonitor(monitor));
824 851
							concordance.setTopIndex(0);
825 852
							
......
1687 1714
	 *
1688 1715
	 * @param userDefinedComparators the new user defined comparators
1689 1716
	 */
1690
	public void setUserDefinedComparators(
1691
			List<LineComparator> userDefinedComparators) {
1717
	public void setUserDefinedComparators(List<LineComparator> userDefinedComparators) {
1692 1718
		
1693 1719
		this.userDefinedComparators = userDefinedComparators;
1694 1720
	}
......
2162 2188
		// }
2163 2189
	}
2164 2190
	
2191
	public static int MAX_CHARS_LENGTH_TO_SHOW = 75;
2165 2192
	public void resetLeftTableColumnWidths() {
2166 2193
		
2167 2194
		int refMax = referenceColumn.getText().length();
......
2169 2196
			if (refMax < item.getText(0).length()) refMax = item.getText(0).length();
2170 2197
		}
2171 2198
		
2199
		if (refMax > MAX_CHARS_LENGTH_TO_SHOW) {
2200
			refMax = MAX_CHARS_LENGTH_TO_SHOW;
2201
		}
2202
		
2172 2203
		// System.out.println("Size="+queryLabel.getSize().x +" label="+queryLabel.getText()+" l size"+ queryLabel.getText().length());
2173 2204
		float W = 1f + queryLabel.getSize().x / (float) queryLabel.getText().length();
2174 2205
		// System.out.println("W= "+W+" Maxs "+refMax+ " " +leftMax+" " +keywordMax+" "+rightMax);
......
2177 2208
		if (sash.getLayoutData() == null) return; // there was a problem during initialization
2178 2209
		
2179 2210
		((FormData) sash.getLayoutData()).left = new FormAttachment(0, 25 + (int) (refMax * W));
2211
		
2180 2212
		referenceColumn.setWidth(2 * (int) (refMax * W));
2181 2213
		getResultArea().layout(true, true);
2182 2214
	}
......
2202 2234
				if (n++ > 100) break; // stop testing after 100 lines
2203 2235
			}
2204 2236
			
2237
			if (max > MAX_CHARS_LENGTH_TO_SHOW) {
2238
				max = MAX_CHARS_LENGTH_TO_SHOW;
2239
			}
2240
			
2205 2241
			column.setWidth(15 + (int) (max * W));
2206 2242
		}
2207 2243
		
tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/actions/ComplexSort.java (revision 2946)
97 97
	 */
98 98
	@Override
99 99
	public void run() {
100
		SelectComplexSortDialog d = new SelectComplexSortDialog(window
101
				.getShell());
100
		SelectComplexSortDialog d = new SelectComplexSortDialog(window.getShell());
101
		
102 102
		if (d.open() == Window.OK) {
103
			concordanceEditor.setUserDefinedComparators(d
104
					.getUserDefinedComparators());
103
			concordanceEditor.setUserDefinedComparators(d.getUserDefinedComparators());
105 104
			concordanceEditor.setCurrentComparator(d.getSelectedComparator());
106 105
			concordanceEditor.sort();
107 106
		}
108

  
109 107
	}
110 108

  
111 109
	/**
......
243 241
		 */
244 242
		protected CompositeSorterCreationDialog(Shell shell) {
245 243
			super(shell);
246
			this.availableComparators = new ArrayList<LineComparator>(
247
					concordanceEditor.getStandardComparators());
244
			this.availableComparators = new ArrayList<LineComparator>(concordanceEditor.getStandardComparators());
248 245
			this.selectedComparators = new ArrayList<LineComparator>();
249 246
		}
250 247

  
tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/widgets/ComplexSortSelector.java (revision 2946)
175 175
	public void setComparators(ConcordanceEditor editor) {
176 176
		this.editor = editor;
177 177

  
178
		List<LineComparator> standardComparatorslist = editor
179
				.getStandardComparators();
178
		List<LineComparator> standardComparatorslist = editor.getStandardComparators();
179
		
180 180
		comparatorsNames = new ArrayList<String>(standardComparatorslist.size());
181 181
		String[] tcomparatorsNames = new String[standardComparatorslist.size()];
182 182
		for (int i = 0; i < standardComparatorslist.size(); i++) {
......
223 223
		}
224 224

  
225 225
		// no default comparator found -> create one
226
		defaultComparator = new CompositeComparator(
227
				TXMUIMessages._default, standardComparatorslist);
226
		defaultComparator = new CompositeComparator( TXMUIMessages._default, standardComparatorslist);
228 227
		firstKey.select(0);
229 228
		secondKey.select(0);
230 229
		thirdKey.select(0);

Formats disponibles : Unified diff