Révision 2962

tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ReferencePattern.java (revision 2962)
29 29

  
30 30
import java.util.ArrayList;
31 31
import java.util.Collection;
32
import java.util.HashMap;
32 33
import java.util.Iterator;
33 34
import java.util.List;
34 35

  
......
41 42
import org.txm.searchengine.cqp.corpus.VirtualProperty;
42 43
import org.txm.utils.logger.Log;
43 44

  
45
import com.google.gson.Gson;
46

  
44 47
/**
45 48
 * References configuration : a list of properties and optionally a sprintf like pattern
46 49
 *
......
59 62
	 * @param v
60 63
	 * @return a list of word and structure properties read from a String
61 64
	 */
65
	@SuppressWarnings("unlikely-arg-type")
62 66
	public static ReferencePattern stringToReferencePattern(CQPCorpus corpus, String v) {
63 67
		try {
64
			
68
			Gson gson = new Gson();
69

  
70
			HashMap<?, ?> values = gson.fromJson(v, HashMap.class);
71
			Object oProperties = values.get("properties");
72
			Object oFormat = values.get("format");
65 73
			String pattern = null;
66
			if (v.contains("\t\t")) {
67
				pattern = v.substring(v.indexOf("\t\t") + 2);
68
				v = v.substring(0, v.indexOf("\t\t"));
74
			if (oFormat != null) {
75
				pattern = oFormat.toString();
69 76
			}
70 77
			
71 78
			ReferencePattern props = new ReferencePattern(pattern);
72
			if (v == null) return props;
73
			if (v.length() == 0) return props;
74 79
			
75
			String[] split = v.split("\t");
76
			for (String s : split) {
77
				if (s.contains("_")) {
78
					String[] split2 = s.split("_", 2);
79
					StructuralUnit su = corpus.getStructuralUnit(split2[0]);
80
					if (su != null) {
81
						Property prop = su.getProperty(split2[1]);
80
			if (oProperties != null && oProperties instanceof List) {
81
				List<?> propertyNames = (List<?>) oProperties;
82
				for (Object o : propertyNames) {
83
					if (o == null) continue;
84
					String s = o.toString();
85
					if (s.contains("_")) {
86
						String[] split2 = s.split("_", 2);
87
						StructuralUnit su = corpus.getStructuralUnit(split2[0]);
88
						if (su != null) {
89
							Property prop = su.getProperty(split2[1]);
90
							if (prop != null) {
91
								props.addProperty(prop);
92
							}
93
						}
94
					}
95
					else {
96
						Property prop = corpus.getProperty(s);
82 97
						if (prop != null) {
83 98
							props.addProperty(prop);
84 99
						}
85 100
					}
86 101
				}
87
				else {
88
					Property prop = corpus.getProperty(s);
89
					if (prop != null) {
90
						props.addProperty(prop);
91
					}
92
				}
93 102
			}
94 103
			
95
			
96
			
97 104
			return props;
98 105
		}
99 106
		catch (Exception e) {
......
246 253
		return title;
247 254
	}
248 255
	
249
	public static String referenceToString(ReferencePattern pViewRefPattern) {
256
	public static String referenceToString(ReferencePattern pattern) {
250 257
		ArrayList<String> names = new ArrayList<>();
251
		for (Property p : pViewRefPattern.getProperties()) {
258
		for (Property p : pattern.getProperties()) {
252 259
			names.add(p.getFullName());
253 260
		}
254
		return StringUtils.join(names, "\t"); //$NON-NLS-1$
261
		
262
		Gson gson = new Gson();
263
		HashMap<String, Object> values = new HashMap<String, Object>();
264
		values.put("properties", names);
265
		values.put("format", pattern.getPattern());
266
		return gson.toJson(values);
255 267
	}
256 268
	
257 269
	public CQPCorpus getCorpus() {
......
261 273
		return properties.get(0).getCorpus();
262 274
	}
263 275
	
264
	public static List<Property> getPossibleValues(CQPCorpus corpus) {
276
	public static List<Property> getAvailableProperties(CQPCorpus corpus) {
265 277
		List<Property> availableReferenceItems = new ArrayList<>();
266 278
		try {
267 279
			// add word properties
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/PrepareAFVOIXOFFCorpusMacro.groovy (revision 2962)
63 63
backtomedia/sync_mode=Structure
64 64
concordance/context_limits=text
65 65
concordance/context_limits_type=list
66
concordance/view_pattern=div_datedediffusion\ttext_id\tu_time\t\t%s, %s, %s
66
concordance/view_reference_pattern=text_date-de-diffusion-tri\tu_time\tdiv_identifiant-de-la-notice
67
concordance/view_reference_pattern_format=%s, %s, %s
68
concordance/sort_reference_pattern=text_date-de-diffusion-tri\tu_time\tdiv_identifiant-de-la-notice
67 69
concordance/name=concordance
68 70
eclipse.preferences.version=1"""
69 71

  
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/projects/antract/BuildAFMetadataMacro.groovy (revision 2962)
55 55
	columnsToCopy.put("Titre propre", ["title"] as String[]); 
56 56
	columnsToCopy.put("Date de diffusion", ["text-order"] as String[]);
57 57
	
58
	searchAndReplaceRules.put("text-order", ["([0-9][0-9])/([0-9][0-9])/([0-9][0-9][0-9][0-9])", '$3$2$1'] as String[]); // not working yet
58
	searchAndReplaceRules.put("text-order", ["([0-9][0-9])/([0-9][0-9])/([0-9][0-9][0-9][0-9])", '$3$2$1'] as String[]);
59 59
	
60
	
61
	
62 60
	process(excel, table2File, lineRules, columnsSelection, columnsToCopy, searchAndReplaceRules, columnsToRenameRules, normalizeSearchAndReplacePattern, dateColumnsSelection, datePattern)
63 61
}
64 62

  
......
84 82
	
85 83
	dateColumnsSelection.add("Date de diffusion");
86 84
	datePattern = "dd/MM/yyyy"
87

  
85
	
86
	searchAndReplaceRules.put("Descripteurs (Aff. Lig.)", ["(.+[^ ])- (.+)", '$1 - $2'] as String[]);
87
	searchAndReplaceRules.put("Résumé", ["(.+[^ ])- (.+)", '$1 - $2'] as String[]);
88
	searchAndReplaceRules.put("Séquences", ["(.+[^ ])- (.+)", '$1 - $2'] as String[]);
89
	searchAndReplaceRules.put("Titre propre", ["(.+[^ ])- (.+)", '$1 - $2'] as String[]);
90
	
88 91
	process(excel, table2File, lineRules, columnsSelection, columnsToCopy, searchAndReplaceRules, columnsToRenameRules, normalizeSearchAndReplacePattern, dateColumnsSelection, datePattern)
89 92
}
90 93

  
......
110 113
		System.out.println(" Copying columns: " + columnsToCopy);
111 114
		excel2.copyColumns(columnsToCopy);
112 115
	}
113
		
116
	
114 117
	if (dateColumnsSelection.size() > 0) {
115 118
		System.out.println(" Format Date columns: " + dateColumnsSelection);
116 119
		excel2.formatDateColumns(dateColumnsSelection, datePattern);
tmp/org.txm.libs.msoffice/src/org/txm/libs/msoffice/ReadExcel.java (revision 2962)
256 256
						Cell newCell = null;
257 257
						if (rowIndex == 0) { // header line
258 258
							newCell = row.createCell(colMax + icol++);
259
							newCell.setCellValue(column+"-joursemaine"); // first row must be renamed
259
							newCell.setCellValue(column+"-jour-semaine"); // first row must be renamed
260 260
							newCell = row.createCell(colMax + icol++);
261 261
							newCell.setCellValue(column+"-jour"); // first row must be renamed
262 262
							newCell = row.createCell(colMax + icol++);
263
							newCell.setCellValue(column+"-moi"); // first row must be renamed
263
							newCell.setCellValue(column+"-mois"); // first row must be renamed
264 264
							newCell = row.createCell(colMax + icol++);
265 265
							newCell.setCellValue(column+"-annee"); // first row must be renamed
266 266
							newCell = row.createCell(colMax + icol++);
tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 2962)
292 292
	@Parameter(key = ConcordancePreferences.LEFT_ANALYSIS_PROPERTIES)
293 293
	private PropertiesSelector<WordProperty> leftSortProperties;
294 294
	
295
	@Parameter(key = ConcordancePreferences.ANALYSIS_REFERENCE_PATTERN)
295
	@Parameter(key = ConcordancePreferences.SORT_REFERENCE_PATTERN)
296 296
	private PropertiesSelector<Property> refSortProperties;
297 297
	
298 298
	@Parameter(key = ConcordancePreferences.KEYWORD_ANALYSIS_PROPERTIES)
......
1097 1097
			refViewProperties.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));
1098 1098
			refViewProperties.setTitle(ConcordanceUIMessages.editor_21);
1099 1099
			refViewProperties.setButtonText(ConcordanceUIMessages.editor_19);
1100
			refViewProperties.setProperties(ReferencePattern.getPossibleValues(getCorpus()));
1100
			refViewProperties.setProperties(ReferencePattern.getAvailableProperties(getCorpus()));
1101 1101
			refViewProperties.setPattern(null);
1102 1102
			refViewProperties.addSelectionListener(new ComputeSelectionListener(this) {
1103 1103
				
......
1173 1173
			refSortProperties.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false));
1174 1174
			refSortProperties.setTitle(ConcordanceUIMessages.editor_21);
1175 1175
			refSortProperties.setButtonText(ConcordanceUIMessages.editor_19);
1176
			refSortProperties.setProperties(ReferencePattern.getPossibleValues(getCorpus()));
1176
			refSortProperties.setProperties(ReferencePattern.getAvailableProperties(getCorpus()));
1177 1177
			refSortProperties.addSelectionListener(new ComputeSelectionListener(this) {
1178 1178
				
1179 1179
				@Override
tmp/org.txm.rcp/src/main/java/org/txm/rcp/corpuswizard/ImportWizard.java (revision 2962)
78 78
				}
79 79
				boolean newProject = (project == null);
80 80
				if (newProject) { // it's a new project configuration
81
					File settingsDirectory = new File(path, ".settings");
81
					File settingsDirectory = new File(path, "parameters");
82 82
					if (settingsDirectory.exists()) {
83 83
						File settingsCopy = new File(Toolbox.workspace.getLocation(), name + "/.settings");
84 84
						settingsCopy.getParentFile().mkdirs();
tmp/org.txm.utils/META-INF/MANIFEST.MF (revision 2962)
90 90
 org.txm.libs.itext;bundle-version="2.1.5";visibility:=reexport,
91 91
 org.txm.libs.msoffice;bundle-version="1.0.0";visibility:=reexport,
92 92
 org.txm.libs.office;bundle-version="0.8.2";visibility:=reexport,
93
 com.ibm.icu
93
 com.ibm.icu;visibility:=reexport,
94
 org.txm.libs.gson;bundle-version="2.8.6";visibility:=reexport
94 95
Bundle-ManifestVersion: 2
95 96
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
96 97
Bundle-Vendor: Textometrie.org
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java (revision 2962)
130 130
	protected List<WordProperty> pAnalysisLeftProperties;
131 131
	
132 132
	/** The ReferncePattern sort properties */
133
	@Parameter(key = ConcordancePreferences.ANALYSIS_REFERENCE_PATTERN)
133
	@Parameter(key = ConcordancePreferences.SORT_REFERENCE_PATTERN)
134 134
	protected ReferencePattern pAnalysisRefPattern;
135 135
	
136 136
	/** The right c analysis property. */
......
268 268
				this.pViewRefPattern = ReferencePattern.stringToReferencePattern(this.getCorpus(), refPropertyNames);
269 269
			}
270 270
			
271
			refPropertyNames = this.getStringParameterValue(ConcordancePreferences.ANALYSIS_REFERENCE_PATTERN);
271
			refPropertyNames = this.getStringParameterValue(ConcordancePreferences.SORT_REFERENCE_PATTERN);
272 272
			if ("*".equals(refPropertyNames)) { //$NON-NLS-1$
273 273
				Property refProperty = getCorpus().getProperty("ref");//$NON-NLS-1$
274 274
				if (refProperty == null) {
......
1371 1371
			}
1372 1372
		}
1373 1373
		
1374
		p = parameters.get(ConcordancePreferences.ANALYSIS_REFERENCE_PATTERN);
1374
		p = parameters.get(ConcordancePreferences.SORT_REFERENCE_PATTERN);
1375 1375
		if (p != null) {
1376 1376
			if (p instanceof ReferencePattern) this.pAnalysisRefPattern = (ReferencePattern) p;
1377 1377
			else {
......
1814 1814
		
1815 1815
		this.saveParameter(ConcordancePreferences.VIEW_REFERENCE_PATTERN, ReferencePattern.referenceToString(this.pViewRefPattern));
1816 1816
		
1817
		this.saveParameter(ConcordancePreferences.ANALYSIS_REFERENCE_PATTERN, ReferencePattern.referenceToString(pAnalysisRefPattern));
1817
		this.saveParameter(ConcordancePreferences.SORT_REFERENCE_PATTERN, ReferencePattern.referenceToString(pAnalysisRefPattern));
1818 1818
		
1819 1819
		return true;
1820 1820
	}
tmp/org.txm.concordance.core/src/org/txm/concordance/core/preferences/ConcordancePreferences.java (revision 2962)
32 32
	public static final String KEYWORD_VIEW_PROPERTIES = "keyword_view_properties"; //$NON-NLS-1$
33 33
	
34 34
	public static final String RIGHT_VIEW_PROPERTIES = "right_view_properties"; //$NON-NLS-1$
35
	
35
		
36 36
	/** The default value is "*" -> The concordance will use ref or text_id */
37
	public static final String ANALYSIS_REFERENCE_PATTERN = "analysis_pattern"; //$NON-NLS-1$
37
	public static final String VIEW_REFERENCE_PATTERN = "view_reference_pattern"; //$NON-NLS-1$
38 38
	
39
	/** The default value is "*" -> The concordance will use ref or text_id */
40
	public static final String VIEW_REFERENCE_PATTERN = "view_pattern"; //$NON-NLS-1$
39
	public static final String SORT_REFERENCE_PATTERN = "sort_reference_pattern"; //$NON-NLS-1$
41 40
	
42 41
	public static final String LIMIT_CQL = "limit_cql"; //$NON-NLS-1$
43 42
	
......
74 73
		preferences.put(RIGHT_VIEW_PROPERTIES, TXMPreferences.DEFAULT_UNIT_PROPERTY);
75 74
		
76 75
		preferences.put(VIEW_REFERENCE_PATTERN, "*"); //$NON-NLS-1$
77
		preferences.put(ANALYSIS_REFERENCE_PATTERN, "*"); //$NON-NLS-1$
76
		preferences.put(SORT_REFERENCE_PATTERN, "*"); //$NON-NLS-1$
78 77
		
79 78
		preferences.put(LIMIT_CQL, "<text>[]"); //$NON-NLS-1$
80 79
	}

Formats disponibles : Unified diff