Révision 2246
tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/GroovyProgressMonitor.java (revision 2246) | ||
---|---|---|
60 | 60 |
|
61 | 61 |
@Override |
62 | 62 |
public void subTask(String name) { |
63 |
// TODO Auto-generated method stub
|
|
63 |
if (monitor == null) return;
|
|
64 | 64 |
|
65 |
monitor.subTask(name); |
|
65 | 66 |
} |
66 | 67 |
|
67 | 68 |
@Override |
tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/GroovyScriptedImportEngine.java (revision 2246) | ||
---|---|---|
69 | 69 |
// CorpusBuild c = project.getCorpora().get(0); |
70 | 70 |
// c.delete(); |
71 | 71 |
// } |
72 |
List<Text> texts = project.getTexts(); |
|
73 |
for (Text t : texts) { |
|
74 |
while (t.getEditions().size() > 0) { |
|
75 |
Edition ed = t.getEditions().get(0); |
|
76 |
ed.delete(); |
|
77 |
} |
|
78 |
} |
|
72 |
// List<Text> texts = project.getTexts();
|
|
73 |
// for (Text t : texts) {
|
|
74 |
// while (t.getEditions().size() > 0) {
|
|
75 |
// Edition ed = t.getEditions().get(0);
|
|
76 |
// ed.delete();
|
|
77 |
// }
|
|
78 |
// }
|
|
79 | 79 |
} else { |
80 | 80 |
// clear all children |
81 | 81 |
while (project.getChildren().size() > 0) { |
... | ... | |
93 | 93 |
// if (errorBinDirectory.exists()) DeleteDir.deleteDirectory(errorBinDirectory); |
94 | 94 |
|
95 | 95 |
//this.setCurrentMonitor(monitor); |
96 |
monitor.beginTask("Importing sources" + project.getSrcdir(), 100); //$NON-NLS-1$ |
|
96 |
monitor.beginTask("Importing sources " + project.getSrcdir(), 100); //$NON-NLS-1$
|
|
97 | 97 |
|
98 | 98 |
//org.txm.Toolbox.shutdownSearchEngine(); |
99 | 99 |
monitor.worked(5); |
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/prototypes/stats/AFCMacro.groovy (revision 2246) | ||
---|---|---|
1 |
// STANDARD DECLARATIONS |
|
2 |
package org.txm.macro |
|
3 |
|
|
4 |
import org.kohsuke.args4j.* |
|
5 |
import groovy.transform.Field |
|
6 |
import org.txm.rcpapplication.swt.widget.parameters.* |
|
7 |
import org.txm.searchengine.cqp.clientExceptions.* |
|
8 |
import org.txm.searchengine.cqp.corpus.* |
|
9 |
import org.txm.searchengine.cqp.corpus.query.* |
|
10 |
import org.apache.commons.lang.time.StopWatch |
|
11 |
import java.util.Arrays |
|
12 |
import org.jfree.chart.renderer.xy.* |
|
13 |
import org.jfree.chart.renderer.* |
|
14 |
import org.jfree.chart.plot.* |
|
15 |
import org.jfree.data.xy.* |
|
16 |
import org.jfree.chart.axis.* |
|
17 |
import java.awt.*; |
|
18 |
import java.awt.geom.*; |
|
19 |
import org.jfree.chart.labels.* |
|
20 |
|
|
21 |
import org.txm.ca.core.chartsengine.jfreechart.themes.highcharts.renderers.* |
|
22 |
import org.txm.ca.rcp.editors.* |
|
23 |
import org.txm.libs.office.ReadODS |
|
24 |
import org.txm.ca.core.chartsengine.jfreechart.datasets.* |
|
25 |
import org.jfree.chart.renderer.AbstractRenderer |
|
26 |
|
|
27 |
println "editor: "+editor |
|
28 |
|
|
29 |
if (!(editor instanceof CAEditor)) { |
|
30 |
println "editor is not a CA editor: $editor, Run the macro with F12 when the editor is selected :-)" |
|
31 |
return |
|
32 |
} |
|
33 |
|
|
34 |
@Field @Option(name="patternsODSFile", usage="The starting word", widget="FileOpen", required=true, def='patterns.ods') |
|
35 |
def patternsODSFile |
|
36 |
@Field @Option(name="debug", usage="Show internal variable content", widget="StringArray", metaVar="OFF ON ALL REALLY ALL", required=true, def="OFF") |
|
37 |
debug |
|
38 |
|
|
39 |
// Open the parameters input dialog box |
|
40 |
if (!ParametersDialog.open(this)) return; |
|
41 |
if (debug == "OFF") debug = 0; else if (debug == "ON") debug = 1; else if (debug == "ALL") debug = 2 else if (debug == "REALLY ALL") debug = 3 |
|
42 |
|
|
43 |
if (!patternsODSFile.exists()) { |
|
44 |
println "Pattern file not found: $patternsODSFile" |
|
45 |
return false; |
|
46 |
} |
|
47 |
if (!patternsODSFile.isFile() || !patternsODSFile.getName().toLowerCase().endsWith(".ods")) { |
|
48 |
println "Wrong pattern file: $patternsODSFile" |
|
49 |
return false; |
|
50 |
} |
|
51 |
|
|
52 |
def data = ReadODS.toTable(patternsODSFile, "rows") |
|
53 |
def keys = data[0] |
|
54 |
def row_styles = [:] // reformat data |
|
55 |
for (int i = 1 ; i < data.size() ; i++) { |
|
56 |
def h = data[i] |
|
57 |
def style = [:] // create style entry |
|
58 |
String s = h[0]; |
|
59 |
row_styles[/$s/] = style // with a regexp pattern as key |
|
60 |
|
|
61 |
// fill the style |
|
62 |
for (int j = 1 ; j < h.size() ; j++) { |
|
63 |
style[keys[j]] = h[j] |
|
64 |
} |
|
65 |
} |
|
66 |
if (debug > 0) { |
|
67 |
println "ROW STYLES=$row_styles" |
|
68 |
} |
|
69 |
|
|
70 |
data = ReadODS.toTable(patternsODSFile, "cols") |
|
71 |
keys = data[0] |
|
72 |
def col_styles = [:] // reformat data |
|
73 |
for (int i = 1 ; i < data.size() ; i++) { |
|
74 |
def h = data[i] |
|
75 |
def style = [:] // create style entry |
|
76 |
String s = h[0]; |
|
77 |
col_styles[/$s/] = style // with a regexp pattern as key |
|
78 |
|
|
79 |
// fill the style |
|
80 |
for (int j = 1 ; j < h.size() ; j++) { |
|
81 |
style[keys[j]] = h[j] |
|
82 |
} |
|
83 |
} |
|
84 |
if (debug > 0) { |
|
85 |
println "COL STYLES=$col_styles" |
|
86 |
} |
|
87 |
|
|
88 |
ica = editor.getCA() |
|
89 |
ca = ica.getCA() |
|
90 |
|
|
91 |
// http://txm.sourceforge.net/javadoc/TXM/TBX/org/txm/stat/engine/r/function/CA.html |
|
92 |
|
|
93 |
// SOME DATA |
|
94 |
rows = ica.getRowNames() |
|
95 |
rowsinfo = ica.getRowInfos() |
|
96 |
rowscos2 = ca.getRowCos2() |
|
97 |
cols = ica.getColNames() |
|
98 |
println cols |
|
99 |
colssinfo = ica.getColInfos() |
|
100 |
colscos2 = ca.getColCos2() |
|
101 |
D1 = ica.getFirstDimension() -1; |
|
102 |
D2 = ica.getSecondDimension() -1; |
|
103 |
|
|
104 |
shapes = [:] |
|
105 |
shapes["square"] = AbstractRenderer.DEFAULT_SHAPE; |
|
106 |
shapes["circle"] = AbstractRenderer.DEFAULT_SHAPE; |
|
107 |
shapes["triangle"] = AbstractRenderer.DEFAULT_SHAPE; |
|
108 |
shapes["star"] = AbstractRenderer.DEFAULT_SHAPE; |
|
109 |
shapes["disk"] = AbstractRenderer.DEFAULT_SHAPE; |
|
110 |
|
|
111 |
// styles per col index in dataset |
|
112 |
// set col points label |
|
113 |
colLabelStyle = new HashMap<Integer, String>(); |
|
114 |
// set col points visibility |
|
115 |
colHiddenStyle = new HashSet<Integer>(); // true false |
|
116 |
// set col font size |
|
117 |
colFontSizeStyle = new HashMap<Integer, Integer>(); // 0.0 to 10.0 |
|
118 |
// set col points size |
|
119 |
colSizeStyle = new HashMap<Integer, Double>(); // 0.0 to 10.0 |
|
120 |
// set col points RGBA color |
|
121 |
colColorStyle = new HashMap<Integer, Color>(); |
|
122 |
// set col points shape (circle, square, triangle, ... + color ? + size ?) -> expert |
|
123 |
colShapeStyle = new HashMap<Integer, Shape>(); // circle, square, triangle, etc. |
|
124 |
|
|
125 |
|
|
126 |
rowLabelStyle = new HashMap<Integer, String>(); |
|
127 |
// set row points visibility |
|
128 |
rowHiddenStyle = new HashSet<Integer>(); // true false |
|
129 |
// set row font size |
|
130 |
rowFontSizeStyle = new HashMap<Integer, Integer>(); // 0.0 to 10.0 |
|
131 |
// set row points size |
|
132 |
rowSizeStyle = new HashMap<Integer, Double>(); // 0.0 to 10.0 |
|
133 |
// set row points RGBA color |
|
134 |
rowColorStyle = new HashMap<Integer, Color>(); |
|
135 |
// set row points shape (circle, square, triangle, ... + color ? + size ?) -> expert |
|
136 |
rowShapeStyle = new HashMap<Integer, Shape>(); // circle, square, triangle, etc. |
|
137 |
|
|
138 |
// prepare col style data for the dataset |
|
139 |
for (int i = 0 ; i < cols.length ; i++) { |
|
140 |
for (def p : col_styles.keySet()) { |
|
141 |
if (cols[i] ==~ p) { |
|
142 |
def style = col_styles[p] |
|
143 |
if (style["shape"] != null && shapes.containsKey(style["shape"])) { |
|
144 |
colShapeStyle[i] = shapes[style["shape"]] |
|
145 |
} |
|
146 |
if (style["color"] != null && style["color"].length() > 0 ) { |
|
147 |
colColorStyle[i] = new Color(Integer.parseInt(style["color"]), true) |
|
148 |
} |
|
149 |
if (style["label"] != null && style["label"].length() > 0) { |
|
150 |
colLabelStyle[i] = style["label"] |
|
151 |
} |
|
152 |
if (style["size"] != null && style["size"].length() > 0) { |
|
153 |
colSizeStyle[i] = Double.parseDouble(style["size"]) |
|
154 |
} |
|
155 |
if (style["font-size"] != null && style["font-size"].length() > 0) { |
|
156 |
colFontSizeStyle[i] = Integer.parseInt(style["font-size"]) |
|
157 |
} |
|
158 |
if (style["hidden"] != null && style["hidden"].toUpperCase() == "T") { |
|
159 |
colHiddenStyle << i |
|
160 |
} |
|
161 |
} |
|
162 |
} |
|
163 |
} |
|
164 |
if (debug > 0) { |
|
165 |
println "COL COL=$colColorStyle" |
|
166 |
println "COL SHP=$colShapeStyle" |
|
167 |
println "COL LAB=$colLabelStyle" |
|
168 |
println "COL FONT-SIZ=$colFontSizeStyle" |
|
169 |
println "COL SIZ=$colSizeStyle" |
|
170 |
println "COL VIZ=$colHiddenStyle" |
|
171 |
} |
|
172 |
|
|
173 |
|
|
174 |
|
|
175 |
// UPDATE THE CHART RENDERER |
|
176 |
|
|
177 |
def chartEditor = editor.getEditors()[0] |
|
178 |
def chartComposite = chartEditor.getComposite() |
|
179 |
|
|
180 |
ddebug = debug |
|
181 |
monitor.syncExec( new Runnable() { |
|
182 |
public void run() { |
|
183 |
println chartComposite |
|
184 |
def chart = chartEditor.getChart(); |
|
185 |
|
|
186 |
//println "chart: "+chart |
|
187 |
//println "Plot: "+chart.getPlot() |
|
188 |
//println "Dataset: "+chart.getPlot().getDataset() |
|
189 |
//println "Renderer: "+chart.getPlot().getRenderer() |
|
190 |
|
|
191 |
def renderer = new CAItemSelectionRenderer(ica, chart) { |
|
192 |
Area EMPTYAREA = new Area() |
|
193 |
|
|
194 |
@Override |
|
195 |
public void initItemLabelGenerator() { |
|
196 |
XYItemLabelGenerator generator = new XYItemLabelGenerator() { |
|
197 |
|
|
198 |
@Override |
|
199 |
public String generateLabel(XYDataset dataset, int series, int item) { |
|
200 |
if (series == 0 && rowHiddenStyle.contains(item)) { |
|
201 |
if (ddebug > 1) println "HIDDING ROW LABEL '$item' '${rows[item]}'" |
|
202 |
return "" |
|
203 |
} else if (series == 1 && colHiddenStyle.contains(item)) { |
|
204 |
if (ddebug > 1) println "HIDDING COL LABEL '$item' '${cols[item]}'" |
|
205 |
return "" |
|
206 |
} else if (series == 0 && rowLabelStyle.containsKey(item)) { |
|
207 |
if (ddebug > 1) println "RENAME ROW LABEL '$item' '${rows[item]}' -> '${rowLabelStyle[item]}'" |
|
208 |
return rowLabelStyle[item] |
|
209 |
} else if (series == 1 && colLabelStyle.containsKey(item)) { |
|
210 |
if (ddebug > 1) println "RENAME COL LABEL '$item' '${cols[item]}' -> '${colLabelStyle[item]}'" |
|
211 |
return colLabelStyle[item] |
|
212 |
} else { |
|
213 |
CAXYDataset caDataset = (CAXYDataset) dataset; |
|
214 |
return caDataset.getLabel(series, item); |
|
215 |
} |
|
216 |
} |
|
217 |
}; |
|
218 |
|
|
219 |
this.setBaseItemLabelGenerator(generator); |
|
220 |
this.setBaseItemLabelsVisible(true); |
|
221 |
} |
|
222 |
|
|
223 |
@Override |
|
224 |
public Font getItemLabelFont(int series, int item) { |
|
225 |
Font d = super.getItemLabelFont(series, item); |
|
226 |
if (series == 0 && rowFontSizeStyle.containsKey(item)) { |
|
227 |
if (ddebug > 1) println "FIX ROW FONT-SIZE $item "+rows[item] |
|
228 |
return new Font(d.getFontName(), d.getStyle(), rowFontSizeStyle[item]); |
|
229 |
} else if (series == 1 && colFontSizeStyle.containsKey(item)) { |
|
230 |
if (ddebug > 1) println "FIX COL FONT-SIZE $item "+cols[item] |
|
231 |
return new Font(d.getFontName(), d.getStyle(), colFontSizeStyle[item]); |
|
232 |
} else { |
|
233 |
return d; |
|
234 |
} |
|
235 |
} |
|
236 |
|
|
237 |
@Override |
|
238 |
public Shape getItemShape(int series, int item) { |
|
239 |
// Rows (series == 0), Cols (series == 1) |
|
240 |
if (series == 0 && rowHiddenStyle.contains(item)) { |
|
241 |
return EMPTYAREA; |
|
242 |
} else if (series == 1 && colHiddenStyle.contains(item)) { |
|
243 |
return EMPTYAREA; |
|
244 |
} else { |
|
245 |
AffineTransform t = new AffineTransform(); |
|
246 |
Shape shape = super.getItemShape(series, item); |
|
247 |
if (series == 0 && rowSizeStyle.containsKey(item)) { |
|
248 |
t.setToScale(rowSizeStyle.get(item), rowSizeStyle.get(item)); |
|
249 |
shape = t.createTransformedShape(shape); |
|
250 |
} else if (series == 1 && colSizeStyle.containsKey(item)) { |
|
251 |
t.setToScale(colSizeStyle.get(item), colSizeStyle.get(item)); |
|
252 |
shape = t.createTransformedShape(shape); |
|
253 |
} |
|
254 |
return shape; |
|
255 |
} |
|
256 |
} |
|
257 |
|
|
258 |
@Override |
|
259 |
public Paint getItemPaint(int series, int item) { |
|
260 |
if (series == 0 && rowColorStyle.containsKey(item)) { |
|
261 |
return rowColorStyle.get(item); |
|
262 |
} else if (series == 1 && colColorStyle.containsKey(item)) { |
|
263 |
return colColorStyle.get(item); |
|
264 |
} else { |
|
265 |
return super.getItemPaint(series, item); |
|
266 |
} |
|
267 |
} |
|
268 |
}; |
|
269 |
|
|
270 |
def cp = editor.editors[0].getChart(); |
|
271 |
renderer.chart = cp |
|
272 |
renderer.setSeriesVisible(0, ica.isShowVariables()); // Rows |
|
273 |
renderer.setSeriesVisible(1, ica.isShowIndividuals()); // Columns |
|
274 |
chart.getXYPlot().setRenderer(renderer) |
|
275 |
|
|
276 |
ica.getChartCreator().getChartsEngine().getJFCTheme().apply(chart); // need to be call AFTER setRenderer() cause this method changes some renderering parameters |
|
277 |
} |
|
278 |
}); |
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/prototypes/stats/AFCWithStylesMacro.groovy (revision 2246) | ||
---|---|---|
1 |
// STANDARD DECLARATIONS |
|
2 |
package org.txm.macro |
|
3 |
|
|
4 |
import org.kohsuke.args4j.* |
|
5 |
import groovy.transform.Field |
|
6 |
import org.txm.rcpapplication.swt.widget.parameters.* |
|
7 |
import org.txm.searchengine.cqp.clientExceptions.* |
|
8 |
import org.txm.searchengine.cqp.corpus.* |
|
9 |
import org.txm.searchengine.cqp.corpus.query.* |
|
10 |
import org.apache.commons.lang.time.StopWatch |
|
11 |
import java.util.Arrays |
|
12 |
import org.jfree.chart.renderer.xy.* |
|
13 |
import org.jfree.chart.renderer.* |
|
14 |
import org.jfree.chart.plot.* |
|
15 |
import org.jfree.data.xy.* |
|
16 |
import org.jfree.chart.axis.* |
|
17 |
import java.awt.*; |
|
18 |
import java.awt.geom.*; |
|
19 |
import org.jfree.chart.labels.* |
|
20 |
|
|
21 |
import org.txm.ca.core.chartsengine.jfreechart.themes.highcharts.renderers.* |
|
22 |
import org.txm.ca.rcp.editors.* |
|
23 |
import org.txm.libs.office.ReadODS |
|
24 |
import org.txm.ca.core.chartsengine.jfreechart.datasets.* |
|
25 |
import org.jfree.chart.renderer.AbstractRenderer |
|
26 |
|
|
27 |
println "editor: "+editor |
|
28 |
|
|
29 |
if (!(editor instanceof CAEditor)) { |
|
30 |
println "editor is not a CA editor: $editor, Run the macro with F12 when the editor is selected :-)" |
|
31 |
return |
|
32 |
} |
|
33 |
|
|
34 |
@Field @Option(name="patternsODSFile", usage="The starting word", widget="FileOpen", required=true, def='patterns.ods') |
|
35 |
def patternsODSFile |
|
36 |
@Field @Option(name="debug", usage="Show internal variable content", widget="StringArray", metaVar="OFF ON ALL REALLY ALL", required=true, def="OFF") |
|
37 |
debug |
|
38 |
|
|
39 |
// Open the parameters input dialog box |
|
40 |
if (!ParametersDialog.open(this)) return; |
|
41 |
if (debug == "OFF") debug = 0; else if (debug == "ON") debug = 1; else if (debug == "ALL") debug = 2 else if (debug == "REALLY ALL") debug = 3 |
|
42 |
|
|
43 |
if (!patternsODSFile.exists()) { |
|
44 |
println "Pattern file not found: $patternsODSFile" |
|
45 |
return false; |
|
46 |
} |
|
47 |
if (!patternsODSFile.isFile() || !patternsODSFile.getName().toLowerCase().endsWith(".ods")) { |
|
48 |
println "Wrong pattern file: $patternsODSFile" |
|
49 |
return false; |
|
50 |
} |
|
51 |
|
|
52 |
def data = ReadODS.toTable(patternsODSFile, "rows") |
|
53 |
def keys = data[0] |
|
54 |
def row_styles = [:] // reformat data |
|
55 |
for (int i = 1 ; i < data.size() ; i++) { |
|
56 |
def h = data[i] |
|
57 |
def style = [:] // create style entry |
|
58 |
String s = h[0]; |
|
59 |
row_styles[/$s/] = style // with a regexp pattern as key |
|
60 |
|
|
61 |
// fill the style |
|
62 |
for (int j = 1 ; j < h.size() ; j++) { |
|
63 |
style[keys[j]] = h[j] |
|
64 |
} |
|
65 |
} |
|
66 |
if (debug > 0) { |
|
67 |
println "ROW STYLES=$row_styles" |
|
68 |
} |
|
69 |
|
|
70 |
data = ReadODS.toTable(patternsODSFile, "cols") |
|
71 |
keys = data[0] |
|
72 |
def col_styles = [:] // reformat data |
|
73 |
for (int i = 1 ; i < data.size() ; i++) { |
|
74 |
def h = data[i] |
|
75 |
def style = [:] // create style entry |
|
76 |
String s = h[0]; |
|
77 |
col_styles[/$s/] = style // with a regexp pattern as key |
|
78 |
|
|
79 |
// fill the style |
|
80 |
for (int j = 1 ; j < h.size() ; j++) { |
|
81 |
style[keys[j]] = h[j] |
|
82 |
} |
|
83 |
} |
|
84 |
if (debug > 0) { |
|
85 |
println "COL STYLES=$col_styles" |
|
86 |
} |
|
87 |
|
|
88 |
ica = editor.getCA() |
|
89 |
ca = ica.getCA() |
|
90 |
|
|
91 |
// http://txm.sourceforge.net/javadoc/TXM/TBX/org/txm/stat/engine/r/function/CA.html |
|
92 |
|
|
93 |
// SOME DATA |
|
94 |
rows = ica.getRowNames() |
|
95 |
rowsinfo = ica.getRowInfos() |
|
96 |
rowscos2 = ca.getRowCos2() |
|
97 |
cols = ica.getColNames() |
|
98 |
colssinfo = ica.getColInfos() |
|
99 |
colscos2 = ca.getColCos2() |
|
100 |
D1 = ica.getFirstDimension() -1; |
|
101 |
D2 = ica.getSecondDimension() -1; |
|
102 |
|
|
103 |
shapes = [:] |
|
104 |
shapes["square"] = AbstractRenderer.DEFAULT_SHAPE; |
|
105 |
shapes["circle"] = AbstractRenderer.DEFAULT_SHAPE; |
|
106 |
shapes["triangle"] = AbstractRenderer.DEFAULT_SHAPE; |
|
107 |
shapes["star"] = AbstractRenderer.DEFAULT_SHAPE; |
|
108 |
shapes["disk"] = AbstractRenderer.DEFAULT_SHAPE; |
|
109 |
|
|
110 |
// styles per col index in dataset |
|
111 |
// set col label |
|
112 |
colLabelStyle = new HashMap<Integer, String>(); |
|
113 |
// set col visibility |
|
114 |
colHiddenStyle = new HashSet<Integer>(); // true false |
|
115 |
// set col font size |
|
116 |
colFontSizeStyle = new HashMap<Integer, Integer>(); // 0.0 to 10.0 |
|
117 |
// set row font size |
|
118 |
colFontColorStyle = new HashMap<Integer, Color>(); // 0.0 to 10.0 |
|
119 |
// set row font size |
|
120 |
colFontFamillyStyle = new HashMap<Integer, String>(); // 0.0 to 10.0 |
|
121 |
// set col points size |
|
122 |
colPointSizeStyle = new HashMap<Integer, Double>(); // 0.0 to 10.0 |
|
123 |
// set col points RGBA color |
|
124 |
colPointColorStyle = new HashMap<Integer, Color>(); |
|
125 |
// set col points shape (circle, square, triangle, ... + color ? + size ?) -> expert |
|
126 |
colPointShapeStyle = new HashMap<Integer, Shape>(); // circle, square, triangle, etc. |
|
127 |
|
|
128 |
// set row label |
|
129 |
rowLabelStyle = new HashMap<Integer, String>(); |
|
130 |
// set row visibility |
|
131 |
rowHiddenStyle = new HashSet<Integer>(); // true false |
|
132 |
// set row font size |
|
133 |
rowFontSizeStyle = new HashMap<Integer, Integer>(); // 0.0 to 10.0 |
|
134 |
// set row font size |
|
135 |
rowFontColorStyle = new HashMap<Integer, Color>(); // 0.0 to 10.0 |
|
136 |
// set row font size |
|
137 |
rowFontFamillyStyle = new HashMap<Integer, String>(); // 0.0 to 10.0 |
|
138 |
// set row points size |
|
139 |
rowPointSizeStyle = new HashMap<Integer, Double>(); // 0.0 to 10.0 |
|
140 |
// set row points RGBA color |
|
141 |
rowPointColorStyle = new HashMap<Integer, Color>(); |
|
142 |
// set row points shape (circle, square, triangle, ... + color ? + size ?) -> expert |
|
143 |
rowPointShapeStyle = new HashMap<Integer, Shape>(); // circle, square, triangle, etc. |
|
144 |
|
|
145 |
// prepare col style data for the dataset |
|
146 |
for (int i = 0 ; i < cols.length ; i++) { |
|
147 |
for (def p : col_styles.keySet()) { |
|
148 |
if (cols[i] ==~ p) { |
|
149 |
def style = col_styles[p] |
|
150 |
if (style["label"] != null && style["label"].length() > 0) { |
|
151 |
colLabelStyle[i] = style["label"] |
|
152 |
} |
|
153 |
if (style["hidden"] != null && style["hidden"].toUpperCase() == "T") { |
|
154 |
colHiddenStyle << i |
|
155 |
} |
|
156 |
if (style["point-size"] != null && style["point-size"].length() > 0) { |
|
157 |
colPointSizeStyle[i] = Double.parseDouble(style["point-size"]) |
|
158 |
} |
|
159 |
if (style["point-color"] != null && style["point-color"].length() > 0 ) { |
|
160 |
colPointColorStyle[i] = new Color(Integer.parseInt(style["point-color"]), false) |
|
161 |
} |
|
162 |
if (style["point-shape"] != null && shapes.containsKey(style["point-shape"])) { |
|
163 |
colPointShapeStyle[i] = shapes[style["point-shape"]] |
|
164 |
} |
|
165 |
if (style["font-size"] != null && style["font-size"].length() > 0) { |
|
166 |
colFontSizeStyle[i] = Integer.parseInt(style["font-size"]) |
|
167 |
} |
|
168 |
if (style["font-color"] != null && style["font-color"].length() > 0) { |
|
169 |
colFontColorStyle[i] = Integer.parseInt(style["font-color"]) |
|
170 |
} |
|
171 |
if (style["font-familly"] != null && style["font-familly"].length() > 0) { |
|
172 |
colFontFamillyStyle[i] = style["font-familly"] |
|
173 |
} |
|
174 |
} |
|
175 |
} |
|
176 |
} |
|
177 |
if (debug > 0) { |
|
178 |
println "COL COL=$colPointColorStyle" |
|
179 |
println "COL SHP=$colPointShapeStyle" |
|
180 |
println "COL LAB=$colLabelStyle" |
|
181 |
println "COL FONT-SIZ=$colFontSizeStyle" |
|
182 |
println "COL SIZ=$colPointSizeStyle" |
|
183 |
println "COL VIZ=$colHiddenStyle" |
|
184 |
} |
|
185 |
|
|
186 |
// prepare row style data for the dataset |
|
187 |
for (int i = 0 ; i < rows.length ; i++) { |
|
188 |
for (def p : row_styles.keySet()) { |
|
189 |
if (rows[i] ==~ p) { |
|
190 |
def style = row_styles[p] |
|
191 |
if (style["hidden"] != null && style["hidden"].toUpperCase() == "T") { |
|
192 |
rowHiddenStyle << i |
|
193 |
} |
|
194 |
if (style["label"] != null && style["label"].length() > 0) { |
|
195 |
rowLabelStyle[i] = style["label"] |
|
196 |
} |
|
197 |
if (style["point-size"] != null && style["point-size"].length() > 0) { |
|
198 |
rowPointSizeStyle[i] = Double.parseDouble(style["point-size"]) |
|
199 |
} |
|
200 |
if (style["point-color"] != null && style["point-color"].length() > 0 ) { |
|
201 |
rowPointColorStyle[i] = new Color(Integer.parseInt(style["point-color"]), false) |
|
202 |
} |
|
203 |
if (style["point-shape"] != null && shapes.containsKey(style["point-shape"])) { |
|
204 |
rowPointShapeStyle[i] = shapes[style["point-shape"]] |
|
205 |
} |
|
206 |
if (style["font-size"] != null && style["font-size"].length() > 0) { |
|
207 |
rowFontSizeStyle[i] = Integer.parseInt(style["font-size"]) |
|
208 |
} |
|
209 |
if (style["font-color"] != null && style["font-color"].length() > 0) { |
|
210 |
rowFontColorStyle[i] = Integer.parseInt(style["font-color"]) |
|
211 |
} |
|
212 |
if (style["font-familly"] != null && style["font-familly"].length() > 0) { |
|
213 |
rowFontFamillyStyle[i] = style["font-familly"] |
|
214 |
} |
|
215 |
} |
|
216 |
} |
|
217 |
} |
|
218 |
if (debug > 0) { |
|
219 |
println "ROW COL=$rowPointColorStyle" |
|
220 |
println "ROW SHP=$rowPointShapeStyle" |
|
221 |
println "ROW LAB=$rowLabelStyle" |
|
222 |
println "ROW FONT-SIZ=$rowFontSizeStyle" |
|
223 |
println "ROW SIZ=$rowPointSizeStyle" |
|
224 |
println "ROW VIZ=$rowHiddenStyle" |
|
225 |
} |
|
226 |
|
|
227 |
|
|
228 |
// UPDATE THE CHART RENDERER |
|
229 |
|
|
230 |
def chartEditor = editor.getEditors()[0] |
|
231 |
def chartComposite = chartEditor.getComposite() |
|
232 |
|
|
233 |
ddebug = debug |
|
234 |
monitor.syncExec( new Runnable() { |
|
235 |
public void run() { |
|
236 |
println chartComposite |
|
237 |
def chart = chartEditor.getChart(); |
|
238 |
|
|
239 |
//println "chart: "+chart |
|
240 |
//println "Plot: "+chart.getPlot() |
|
241 |
//println "Dataset: "+chart.getPlot().getDataset() |
|
242 |
//println "Renderer: "+chart.getPlot().getRenderer() |
|
243 |
|
|
244 |
def renderer = new CAItemSelectionRenderer(ica, chart) { |
|
245 |
Area EMPTYAREA = new Area() |
|
246 |
|
|
247 |
@Override |
|
248 |
public void initItemLabelGenerator() { |
|
249 |
XYItemLabelGenerator generator = new XYItemLabelGenerator() { |
|
250 |
|
|
251 |
@Override |
|
252 |
public String generateLabel(XYDataset dataset, int series, int item) { |
|
253 |
if (series == 0 && rowHiddenStyle.contains(item)) { |
|
254 |
if (ddebug > 1) println "HIDDING ROW LABEL '$item' '${rows[item]}'" |
|
255 |
return "" |
|
256 |
} else if (series == 1 && colHiddenStyle.contains(item)) { |
|
257 |
if (ddebug > 1) println "HIDDING COL LABEL '$item' '${cols[item]}'" |
|
258 |
return "" |
|
259 |
} else if (series == 0 && rowLabelStyle.containsKey(item)) { |
|
260 |
if (ddebug > 1) println "RENAME ROW LABEL '$item' '${rows[item]}' -> '${rowLabelStyle[item]}'" |
|
261 |
return rowLabelStyle[item] |
|
262 |
} else if (series == 1 && colLabelStyle.containsKey(item)) { |
|
263 |
if (ddebug > 1) println "RENAME COL LABEL '$item' '${cols[item]}' -> '${colLabelStyle[item]}'" |
|
264 |
return colLabelStyle[item] |
|
265 |
} else { |
|
266 |
CAXYDataset caDataset = (CAXYDataset) dataset; |
|
267 |
return caDataset.getLabel(series, item); |
|
268 |
} |
|
269 |
} |
|
270 |
}; |
|
271 |
|
|
272 |
this.setBaseItemLabelGenerator(generator); |
|
273 |
this.setBaseItemLabelsVisible(true); |
|
274 |
} |
|
275 |
|
|
276 |
@Override |
|
277 |
public Font getItemLabelFont(int series, int item) { |
|
278 |
Font d = super.getItemLabelFont(series, item); |
|
279 |
|
|
280 |
if (series == 0 && rowFontSizeStyle.containsKey(item)) { |
|
281 |
if (ddebug > 1) println "FIX ROW FONT-SIZE $item ${rows[item]} -> ${rowFontSizeStyle[item]}" |
|
282 |
d = new Font(d.getFontName(), d.getStyle(), rowFontSizeStyle[item]); |
|
283 |
} else if (series == 1 && colFontSizeStyle.containsKey(item)) { |
|
284 |
if (ddebug > 1) println "FIX COL FONT-SIZE $item ${cols[item]} -> ${colFontSizeStyle[item]}" |
|
285 |
d = new Font(d.getFontName(), d.getStyle(), colFontSizeStyle[item]); |
|
286 |
} |
|
287 |
|
|
288 |
if (series == 0 && rowFontFamillyStyle.containsKey(item)) { |
|
289 |
if (ddebug > 1) println "FIX ROW FONT-FAMILLY $item ${rows[item]} -> ${rowFontFamillyStyle[item]}" |
|
290 |
d = new Font(rowFontFamillyStyle[item], d.getStyle(), d.getSize()); |
|
291 |
} else if (series == 1 && colFontFamillyStyle.containsKey(item)) { |
|
292 |
if (ddebug > 1) println "FIX COL FONT-FAMILLY $item ${cols[item]} -> ${colFontFamillyStyle[item]}" |
|
293 |
d = new Font(colFontFamillyStyle[item], d.getStyle(), d.getSize()); |
|
294 |
} |
|
295 |
|
|
296 |
return d; |
|
297 |
} |
|
298 |
|
|
299 |
@Override |
|
300 |
public Shape getItemShape(int series, int item) { |
|
301 |
// Rows (series == 0), Cols (series == 1) |
|
302 |
if (series == 0 && rowHiddenStyle.contains(item)) { |
|
303 |
return EMPTYAREA; |
|
304 |
} else if (series == 1 && colHiddenStyle.contains(item)) { |
|
305 |
return EMPTYAREA; |
|
306 |
} else { |
|
307 |
AffineTransform t = new AffineTransform(); |
|
308 |
Shape shape = super.getItemShape(series, item); |
|
309 |
if (series == 0 && rowPointSizeStyle.containsKey(item)) { |
|
310 |
if (ddebug > 1) println "FIX ROW POINT SIZE $item ${rows[item]} -> ${rowPointSizeStyle[item]}" |
|
311 |
t.setToScale(rowPointSizeStyle.get(item), rowPointSizeStyle.get(item)); |
|
312 |
shape = t.createTransformedShape(shape); |
|
313 |
} else if (series == 1 && colPointSizeStyle.containsKey(item)) { |
|
314 |
if (ddebug > 1) println "FIX COL POINT SIZE $item ${cols[item]} -> ${colPointSizeStyle[item]}" |
|
315 |
t.setToScale(colPointSizeStyle.get(item), colPointSizeStyle.get(item)); |
|
316 |
shape = t.createTransformedShape(shape); |
|
317 |
} |
|
318 |
return shape; |
|
319 |
} |
|
320 |
} |
|
321 |
|
|
322 |
@Override |
|
323 |
public Paint getItemPaint(int series, int item) { |
|
324 |
if (series == 0 && rowPointColorStyle.containsKey(item)) { |
|
325 |
if (ddebug > 1) println "FIX ROW POINT COLOR $item ${rows[item]} -> ${rowPointColorStyle[item]}" |
|
326 |
return rowPointColorStyle.get(item); |
|
327 |
} else if (series == 1 && colPointColorStyle.containsKey(item)) { |
|
328 |
if (ddebug > 1) println "FIX COL POINT COLOR $item ${cols[item]} -> ${colPointColorStyle[item]}" |
|
329 |
return colPointColorStyle.get(item); |
|
330 |
} else { |
|
331 |
return super.getItemPaint(series, item); |
|
332 |
} |
|
333 |
} |
|
334 |
}; |
|
335 |
|
|
336 |
def cp = editor.editors[0].getChart(); |
|
337 |
renderer.chart = cp |
|
338 |
renderer.setSeriesVisible(0, ica.isShowVariables()); // Rows |
|
339 |
renderer.setSeriesVisible(1, ica.isShowIndividuals()); // Columns |
|
340 |
chart.getXYPlot().setRenderer(renderer) |
|
341 |
|
|
342 |
ica.getChartCreator().getChartsEngine().getJFCTheme().apply(chart); // need to be call AFTER setRenderer() cause this method changes some renderering parameters |
|
343 |
} |
|
344 |
}); |
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/prototypes/commands/PrunePartitionMacro.groovy (revision 2246) | ||
---|---|---|
1 |
// STANDARD DECLARATIONS |
|
2 |
package org.txm.macro |
|
3 |
|
|
4 |
import org.kohsuke.args4j.* |
|
5 |
import groovy.transform.Field |
|
6 |
import org.txm.rcp.swt.widget.parameters.* |
|
7 |
import org.txm.searchengine.cqp.corpus.* |
|
8 |
|
|
9 |
// BEGINNING OF PARAMETERS |
|
10 |
|
|
11 |
|
|
12 |
@Field @Option(name="min", usage="F min", widget="Float", required=false, def="18") |
|
13 |
def min |
|
14 |
|
|
15 |
@Field @Option(name="relative", usage="min is a % of the total frequency", widget="Boolean", required=false, def="false") |
|
16 |
def relative |
|
17 |
|
|
18 |
@Field @Option(name="doIt", usage="delete the selected parts", widget="Boolean", required=false, def="false") |
|
19 |
def doIt |
|
20 |
|
|
21 |
@Field @Option(name="debug", usage="show debug messages", widget="Boolean", required=false, def="false") |
|
22 |
def debug |
|
23 |
|
|
24 |
// Open the parameters input dialog box |
|
25 |
if (!ParametersDialog.open(this)) return; |
|
26 |
|
|
27 |
// END OF PARAMETERS |
|
28 |
|
|
29 |
if (!(corpusViewSelection instanceof Partition)) { |
|
30 |
println "Aborting, the selection is not a Partition: $corpusViewSelection" |
|
31 |
return |
|
32 |
} |
|
33 |
|
|
34 |
def partition = corpusViewSelection |
|
35 |
partition.compute(false) // ensure parts are ready to use |
|
36 |
|
|
37 |
int F = 0; |
|
38 |
for (def part : partition.getParts()) { |
|
39 |
F += part.getSize(); |
|
40 |
} |
|
41 |
if (debug) println "F=$F" |
|
42 |
if (relative) { |
|
43 |
min = (F*min)/100 |
|
44 |
} |
|
45 |
if (debug) println "F min threshold=$min" |
|
46 |
|
|
47 |
def toDelete = [] |
|
48 |
for (def part : partition.getParts()) { |
|
49 |
if (part.getSize() < min) { |
|
50 |
toDelete << part |
|
51 |
} |
|
52 |
} |
|
53 |
if (toDelete.size() > 0) { |
|
54 |
println (doIt?"Deleting ${toDelete.size()} parts: $toDelete":"Selected parts $toDelete") |
|
55 |
for (def part : toDelete) { |
|
56 |
if (doIt) part.delete() |
|
57 |
} |
|
58 |
} |
|
59 |
println "Done" |
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/prototypes/importer/XTZImporterMacro.groovy (revision 2246) | ||
---|---|---|
230 | 230 |
//get metadatas values from CSV |
231 | 231 |
Metadatas metadatas; // text metadatas |
232 | 232 |
|
233 |
println "Trying to read metadatas from: "+allMetadataFile
|
|
233 |
println "Trying to read metadata from: "+allMetadataFile |
|
234 | 234 |
if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); } |
235 | 235 |
if (allMetadataFile.exists()) { |
236 | 236 |
File copy = new File(binDir, allMetadataFile.getName()) |
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/clix/treetagger-wrapper-definition.xml (revision 2246) | ||
---|---|---|
9 | 9 |
<arg state="optional" type="float" name="threshold" desc="Print all tags of a word with a probability higher than p times the largest probability"/> |
10 | 10 |
<arg state="optional" type="none" name="prob" desc="Print tag probabilities"/> |
11 | 11 |
<arg state="optional" type="none" name="ignore-prefix" desc=" Ignore prefix when guessing pos for unknown words"/> |
12 |
<arg state="optional" type="none" name="no-unknown" desc="Print the token rather than [unknown] for unknown lemmas"/>
|
|
12 |
<arg state="optional" type="none" name="no-unknown" desc="Print the token rather than [unknown] for unknown lemma"/> |
|
13 | 13 |
<arg state="optional" type="none" name="cap-heuristics" desc="Look up unknown capitalized words in the list of lower-case words"/> |
14 | 14 |
<arg state="optional" type="none" name="hyphen-heuristics" desc="Turn on the heuristics fur guessing the parts of speech of unknown hyphenated words"/> |
15 | 15 |
<arg state="optional" type="none" name="quiet" desc="quiet mode"/> |
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/cqp/pager.groovy (revision 2246) | ||
---|---|---|
183 | 183 |
|
184 | 184 |
pagedWriter = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(outfile)) , "UTF-8"); |
185 | 185 |
pagedWriter.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); |
186 |
pagedWriter.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n")
|
|
186 |
pagedWriter.write("<!DOCTYPE html>\n") |
|
187 | 187 |
pagedWriter.write("<html>"); |
188 | 188 |
pagedWriter.write("<head>"); |
189 | 189 |
pagedWriter.write("<title>"+basename.toUpperCase()+" $txtname Edition - Page "+pagecount+"</title>"); |
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/xtzLoader.groovy (revision 2246) | ||
---|---|---|
46 | 46 |
try {project=projectBinding;MONITOR=monitor} catch (Exception) |
47 | 47 |
{ } |
48 | 48 |
if (project == null) { println "no project set. Aborting"; return; } |
49 |
|
|
50 | 49 |
XTZImport i = new XTZImport(project); |
50 |
i.setMonitor(monitor) |
|
51 | 51 |
/* |
52 | 52 |
* To customize the XTZ import, replace the importer, compiler, annotater or pager objects before calling process() |
53 | 53 |
i.importer = new XTZImporter(i) |
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZCompiler.groovy (revision 2246) | ||
---|---|---|
6 | 6 |
import org.txm.scripts.importer.SAttributesListener |
7 | 7 |
import org.txm.importer.cwb.* |
8 | 8 |
import org.txm.utils.ConsoleProgressBar |
9 |
import org.txm.utils.logger.Log |
|
9 | 10 |
import org.txm.core.preferences.TXMPreferences |
10 | 11 |
import org.txm.core.preferences.TBXPreferences |
11 | 12 |
import org.txm.libs.cqp.CQPLibPreferences |
... | ... | |
19 | 20 |
|
20 | 21 |
SAttributesListener sattrsListener; // store scanned structures |
21 | 22 |
private def anatypes = new HashSet<String>() // store scanned word attributes |
22 |
|
|
23 |
|
|
23 | 24 |
String regPath; |
24 | 25 |
String corpusname; |
25 | 26 |
String wtag; |
26 |
|
|
27 |
|
|
27 | 28 |
boolean doNormalizeAttributeValues = false; |
28 | 29 |
boolean doNormalizeAnaValues = true; |
29 |
|
|
30 |
|
|
30 | 31 |
public XTZCompiler(ImportModule module) { |
31 | 32 |
super(module); |
32 | 33 |
|
33 | 34 |
corpusname = module.getProject().getName(); |
34 | 35 |
regPath = module.getBinaryDirectory().getAbsolutePath() + "/registry/"+corpusname.toLowerCase() |
35 |
|
|
36 |
|
|
36 | 37 |
wtag = module.getProject().getTokenizerWordElement(); |
37 |
|
|
38 |
|
|
38 | 39 |
doNormalizeAttributeValues = "true".equals(module.getProject().getPreferencesScope().getNode("import").get(TBXPreferences.NORMALISEATTRIBUTEVALUES, "false")) |
39 | 40 |
doNormalizeAnaValues = "true".equals(module.getProject().getPreferencesScope().getNode("import").get(TBXPreferences.NORMALISEANAVALUES, "false")) |
40 | 41 |
} |
41 | 42 |
|
42 |
public void process(ArrayList<File> files) { |
|
43 |
super.process(files); // set member |
|
44 |
|
|
45 |
if (files == null) files = inputDirectory.listFiles(); |
|
46 |
|
|
43 |
@Override |
|
44 |
public void process(List<String> orderedTextIDs) { |
|
45 |
super.process(orderedTextIDs); // set member |
|
46 |
|
|
47 |
if (orderedTextIDs == null) orderedTextIDs = module.getProject().getTextsID() ; |
|
48 |
|
|
47 | 49 |
Project project = module.getProject(); |
48 | 50 |
CorpusBuild corpus = project.getCorpusBuild(project.getName(), MainCorpus.class); |
49 | 51 |
if (corpus != null) { |
... | ... | |
58 | 60 |
corpus.setName(project.getName()); |
59 | 61 |
} |
60 | 62 |
corpus.setDescription("Built with the XTZ import module"); |
61 |
|
|
63 |
|
|
62 | 64 |
if (!doScanStep()) return; |
63 | 65 |
if (!doCQPStep()) return; |
64 | 66 |
if (!doCWBEncodeStep()) return; |
65 | 67 |
if (!doCWBMakeAllStep()) return; |
66 |
|
|
67 |
if (module.getProject().getCleanAfterBuild()) { |
|
68 |
|
|
69 |
if (module.getProject().getCleanAfterBuild() && !module.getProject().getDoUpdate()) {
|
|
68 | 70 |
new File(module.getBinaryDirectory(), "cqp").deleteDir() |
69 | 71 |
} |
70 |
|
|
72 |
|
|
71 | 73 |
isSuccessFul = true; |
72 | 74 |
} |
73 | 75 |
|
... | ... | |
75 | 77 |
* Scan all XML-TXM files to find out structures and word properties |
76 | 78 |
*/ |
77 | 79 |
public boolean doScanStep() { |
78 |
// get all anatypes
|
|
80 |
// get all anatypes |
|
79 | 81 |
sattrsListener = SAttributesListener.scanFiles(inputDirectory, wtag) |
80 |
println "-- Listing structures&properties to create for "+files.size()+" XML-TXM files..." |
|
81 |
ConsoleProgressBar cpb = new ConsoleProgressBar(files.size()) |
|
82 |
for (File f : files) { |
|
82 |
def texts = module.getProject().getTexts() |
|
83 |
println "-- Listing structures&properties to create for "+texts.size()+" texts..." |
|
84 |
ConsoleProgressBar cpb = new ConsoleProgressBar(texts.size()) |
|
85 |
for (Text t : texts) { |
|
83 | 86 |
try { |
84 | 87 |
cpb.tick(); |
85 |
getAnaTypes(f)
|
|
88 |
getAnaTypes(t.getXMLTXMFile())
|
|
86 | 89 |
} catch (Exception e) { |
87 |
println "Error while processing $f text: "+e
|
|
90 |
println "Error while processing $t text XML-TXM file : "+t.getSource()+". Error: "+e
|
|
88 | 91 |
e.printStackTrace(); |
89 | 92 |
return false; |
90 | 93 |
} |
... | ... | |
92 | 95 |
println "" |
93 | 96 |
return true; |
94 | 97 |
} |
95 |
|
|
98 |
|
|
96 | 99 |
private void getAnaTypes(File xmlFile) { |
97 | 100 |
def inputData = xmlFile.toURI().toURL().openStream(); |
98 | 101 |
def factory = XMLInputFactory.newInstance(); |
... | ... | |
115 | 118 |
} else if (event == XMLStreamConstants.END_ELEMENT) { // start elem |
116 | 119 |
if (wtag.equals(parser.getLocalName())) { |
117 | 120 |
start = false; |
118 |
}
|
|
121 |
} |
|
119 | 122 |
} |
120 | 123 |
} |
121 |
|
|
124 |
|
|
122 | 125 |
if (parser != null) parser.close(); |
123 | 126 |
if (inputData != null) inputData.close(); |
124 |
|
|
125 |
// for (String type : types) |
|
126 |
// if (!anatypes.contains(type)) |
|
127 |
// anatypes << type |
|
127 |
|
|
128 |
// for (String type : types)
|
|
129 |
// if (!anatypes.contains(type))
|
|
130 |
// anatypes << type
|
|
128 | 131 |
} |
129 | 132 |
|
130 | 133 |
def cqpFiles = [] |
134 |
int cqpFilesUpdated = 0; |
|
131 | 135 |
public boolean doCQPStep() { |
132 | 136 |
println "-- Building CQP files $inputDirectory..." |
133 | 137 |
cqpDirectory.mkdir(); // if not created |
134 |
|
|
135 |
ConsoleProgressBar cpb = new ConsoleProgressBar(files.size()) |
|
136 |
for (File xmlFile : files) { |
|
138 |
|
|
139 |
def texts = module.getProject().getTexts() |
|
140 |
ConsoleProgressBar cpb = new ConsoleProgressBar(texts.size()) |
|
141 |
cqpFilesUpdated = 0; |
|
142 |
for (Text text : texts) { |
|
137 | 143 |
cpb.tick(); |
138 |
String textname = xmlFile.getName(); |
|
139 |
int idx = textname.lastIndexOf(".")
|
|
140 |
if (idx > 0) textname = textname.substring(0, idx)
|
|
141 |
|
|
144 |
|
|
145 |
File xmlFile = text.getXMLTXMFile()
|
|
146 |
String textname = text.getName()
|
|
147 |
|
|
142 | 148 |
File cqpFile = new File(cqpDirectory, textname + ".cqp") |
143 | 149 |
cqpFiles << cqpFile |
144 |
// skip step if cqpFile is more recent than xmlFile |
|
145 |
if (cqpFile.exists() && cqpFile.lastModified() >= xmlFile.lastModified()) continue; |
|
150 |
|
|
151 |
// skip step if cqpFile exists AND is more recent than the XML-TXM File |
|
152 |
boolean mustBuild = false; |
|
153 |
if (!cqpFile.exists() || xmlFile.lastModified() >= cqpFile.lastModified()) { |
|
154 |
mustBuild = true |
|
155 |
} |
|
156 |
|
|
157 |
if (!text.isDirty() && !mustBuild) { |
|
158 |
Log.finer("skipping .cqp step of $text"); |
|
159 |
continue |
|
160 |
} |
|
146 | 161 |
|
162 |
cqpFilesUpdated++ |
|
163 |
|
|
147 | 164 |
XTZCompilerStep step = new XTZCompilerStep(xmlFile, cqpFile, textname, corpusname, "default", anatypes, wtag) |
148 | 165 |
step.setNormalizeAnaValues(doNormalizeAnaValues) |
149 | 166 |
step.setNormalizeAttributeValues(doNormalizeAttributeValues) |
... | ... | |
160 | 177 |
println "-- Running cwb-encode..." |
161 | 178 |
CwbEncode cwbEn = new CwbEncode() |
162 | 179 |
cwbEn.setDebug(debug) |
163 |
|
|
180 |
|
|
164 | 181 |
List<String> pargs = [] |
165 | 182 |
pargs.add("id") |
166 | 183 |
for (String ana : anatypes) |
... | ... | |
175 | 192 |
println structs |
176 | 193 |
println structsProf |
177 | 194 |
} |
178 |
|
|
195 |
|
|
179 | 196 |
List<String> sargs = new ArrayList<String>() |
180 | 197 |
def tmpTextAttrs = [] |
181 | 198 |
for (String name : structs.keySet()) { |
... | ... | |
188 | 205 |
String concat = name+":"+structsProf.get(name); // append the depth |
189 | 206 |
for (String attributeName : structs.get(name)) // append the attributes |
190 | 207 |
concat += "+"+attributeName.toLowerCase(); |
191 |
|
|
208 |
|
|
192 | 209 |
if (structs.get(name).size() == 0) { |
193 | 210 |
concat += "+n"; |
194 | 211 |
} else { |
195 | 212 |
if (!structs.get(name).contains("n")) |
196 | 213 |
concat += "+n" |
197 | 214 |
} |
198 |
|
|
215 |
|
|
199 | 216 |
if ((name == "p" || name == "body" || name == "back" || name == "front") |
200 |
&& !concat.contains("+n+") && !concat.endsWith("+n"))
|
|
217 |
&& !concat.contains("+n+") && !concat.endsWith("+n")) |
|
201 | 218 |
concat += "+n" |
202 |
|
|
219 |
|
|
203 | 220 |
sargs.add(concat) |
204 | 221 |
} |
205 | 222 |
|
... | ... | |
225 | 242 |
println "Fail to write the master cqp file: "+allcqpFile |
226 | 243 |
return false; |
227 | 244 |
} |
228 |
|
|
245 |
|
|
229 | 246 |
if (!cwbEn.run(outputDirectory.getAbsolutePath() + "/$corpusname", |
230 |
allcqpFile.getAbsolutePath(),
|
|
231 |
regPath, pAttributes, sAttributes, false)) {
|
|
247 |
allcqpFile.getAbsolutePath(), |
|
248 |
regPath, pAttributes, sAttributes, false)) { |
|
232 | 249 |
println "** cwb-encode did not ends well. Activate finer logs to see details." |
233 | 250 |
return false; |
234 | 251 |
} |
235 |
|
|
252 |
|
|
236 | 253 |
allcqpFile.delete(); // clean |
237 | 254 |
} catch (Exception e) { |
238 | 255 |
println "Error while running cwb-encode: "+e |
239 | 256 |
e.printStackTrace() |
240 |
allcqpFile.delete(); // clean
|
|
257 |
allcqpFile.delete(); // clean |
|
241 | 258 |
return false; |
242 | 259 |
} |
243 | 260 |
println "" |
... | ... | |
258 | 275 |
println "** cwb-makeall did not ends well. Activate finer logs to see details." |
259 | 276 |
return false; |
260 | 277 |
} |
261 |
|
|
278 |
|
|
262 | 279 |
// remove milestones from CWB registry and data files |
263 | 280 |
FixMilestoneDeclarations fm = new FixMilestoneDeclarations( |
264 |
new File(regPath), new File(outputDirectory.getAbsolutePath(), corpusname)); |
|
281 |
new File(regPath), new File(outputDirectory.getAbsolutePath(), corpusname));
|
|
265 | 282 |
if (!fm.process()) { |
266 | 283 |
println "Fail to verify&fix milestone declarations" |
267 | 284 |
return false |
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImport.groovy (revision 2246) | ||
---|---|---|
36 | 36 |
} |
37 | 37 |
|
38 | 38 |
@Override |
39 |
protected ArrayList<File> getTXMFilesOrder() {
|
|
39 |
protected ArrayList<String> getTXMFilesOrder() {
|
|
40 | 40 |
//System.out.println("XTZ FILES ORDER"); |
41 | 41 |
if (importer == null) { |
42 | 42 |
println "no importer step, using default text order" |
... | ... | |
55 | 55 |
} |
56 | 56 |
}))); |
57 | 57 |
|
58 |
final HashMap<File, String> textorder = new HashMap<File, String>(); |
|
59 |
for (File f : files) { |
|
60 |
HashMap<String, String> m = metadata.getTextMetadata(f); |
|
61 |
if (m != null && m.containsKey("textorder")) textorder[f] = m["textorder"]; |
|
58 |
// fill sort data map |
|
59 |
final HashMap<String, String> textorder = new HashMap<String, String>(); |
|
60 |
for (String t : metadata.keySet()) { |
|
61 |
def ti = metadata.get(t) |
|
62 |
for (org.txm.metadatas.Entry e : ti) { |
|
63 |
if ("textorder".equals(e.getId())) { |
|
64 |
textorder[t] = ti.get("textorder") |
|
65 |
} |
|
66 |
} |
|
62 | 67 |
} |
68 |
|
|
63 | 69 |
println "Sorting texts using 'textorder' metadata values: "+textorder |
64 |
Collections.sort(files, new Comparator<File>() { |
|
65 |
public int compare(File f1, File f2) { |
|
70 |
def texts = project.getTextsID(); |
|
71 |
Collections.sort(texts, new Comparator<String>() { |
|
72 |
public int compare(String f1, String f2) { |
|
66 | 73 |
String o1 = textorder[f1]; |
67 | 74 |
String o2 = textorder[f2]; |
68 | 75 |
if (o1 == null && o2 == null) { |
69 |
return f1.getName().compareTo(f2.getName());
|
|
76 |
return f1.compareTo(f2);
|
|
70 | 77 |
} else if (o1 == null) { |
71 | 78 |
return 1 |
72 | 79 |
} else if (o2 == null) { |
73 | 80 |
return -1 |
74 | 81 |
} else { |
75 | 82 |
int c = o1.compareTo(o2); |
76 |
if (c == 0) return f1.getName().compareTo(f2.getName());
|
|
83 |
if (c == 0) return f1.compareTo(f2);
|
|
77 | 84 |
else return c; |
78 | 85 |
} |
79 | 86 |
} |
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZPager.groovy (revision 2246) | ||
---|---|---|
13 | 13 |
import org.txm.utils.i18n.* |
14 | 14 |
import org.txm.importer.xtz.* |
15 | 15 |
import javax.xml.stream.* |
16 |
|
|
16 | 17 |
import org.txm.objects.* |
17 | 18 |
import org.txm.importer.ApplyXsl2 |
19 |
import org.txm.utils.logger.Log |
|
18 | 20 |
|
19 | 21 |
class XTZPager extends Pager { |
20 | 22 |
|
... | ... | |
43 | 45 |
imagesDirectory = new File(module.getSourceDirectory(), "images") |
44 | 46 |
} |
45 | 47 |
|
46 |
public void process(ArrayList<File> files) { |
|
47 |
super.process(files); |
|
48 |
@Override |
|
49 |
public void process(List<String> orderedTextIDs) { |
|
50 |
super.process(orderedTextIDs); |
|
48 | 51 |
|
49 |
if (files == null) { |
|
50 |
files = inputDirectory.listFiles(); |
|
51 |
if (files != null) Collections.sort(files); |
|
52 |
} |
|
52 |
if (orderedTextIDs == null) { module.getProject().getTextsID() } |
|
53 | 53 |
|
54 | 54 |
if (!doDefaultEditionStep()) return; |
55 | 55 |
if (!doFacsEditionStep()) return; |
56 |
|
|
57 |
// remove extra XSL editions -> they will be recreated by the doPostEditionXSLStep call
|
|
56 |
|
|
57 |
// remove extra XSL editions -> they will be recreated by the doPostEditionXSLStep call |
|
58 | 58 |
for (EditionDefinition eDef : project.getEditionDefinitions()) { |
59 | 59 |
if (eDef.getName() != "facs" && eDef.getName() != "default") { |
60 | 60 |
eDef.delete(); |
... | ... | |
74 | 74 |
} |
75 | 75 |
|
76 | 76 |
def second = 0 |
77 |
def texts = module.getProject().getTexts() |
|
78 |
println "-- Building 'default' edition of ${texts.size()} texts..." |
|
77 | 79 |
|
78 |
println "-- Building 'default' edition of ${files.size()} texts..." |
|
79 |
|
|
80 | 80 |
def css = ["css/txm.css", "css/${corpusname}.css"] // default CSS inclusion |
81 | 81 |
|
82 | 82 |
// scan existing css files that must be declared in each HTML page |
83 | 83 |
if (cssDirectory.exists()) { |
84 | 84 |
def cssFiles = cssDirectory.listFiles(); |
85 |
if (cssFiles != null) |
|
85 |
if (cssFiles != null) {
|
|
86 | 86 |
for (File cssFile : cssFiles) { |
87 | 87 |
if (cssFile.isFile() && !cssFile.isHidden() && cssFile.getName().endsWith(".css")) |
88 | 88 |
css << "css/"+cssFile.getName(); |
89 | 89 |
} |
90 |
} |
|
90 | 91 |
} |
91 | 92 |
|
92 |
ConsoleProgressBar cpb = new ConsoleProgressBar(files.size()) |
|
93 |
for (File txmFile : files) { |
|
93 |
ConsoleProgressBar cpb = new ConsoleProgressBar(texts.size()) |
|
94 |
for (Text text : texts) { |
|
95 |
|
|
96 |
File txmFile = text.getXMLTXMFile() |
|
94 | 97 |
try { |
95 | 98 |
cpb.tick() |
96 |
String textname = txmFile.getName(); |
|
97 |
int i = textname.lastIndexOf("."); |
|
98 |
if (i > 0) textname = textname.substring(0, i); |
|
99 | 99 |
|
100 |
String textname = text.getName() |
|
101 |
|
|
100 | 102 |
File firstHTMLPageFile = new File(outputDirectory, textname+"_1.html"); |
101 |
if (firstHTMLPageFile.exists() && firstHTMLPageFile.lastModified() >= txmFile.lastModified()) continue; |
|
103 |
boolean mustBuild = false; |
|
104 |
if (!firstHTMLPageFile.exists() || txmFile.lastModified() >= firstHTMLPageFile.lastModified()) { |
|
105 |
mustBuild = true |
|
106 |
} |
|
107 |
|
|
108 |
if (!text.isDirty() && !mustBuild) { |
|
109 |
Log.finer("skipping 'default html' step of $text"); |
|
110 |
continue |
|
111 |
} |
|
102 | 112 |
|
113 |
Edition edition = text.getEdition("default") |
|
114 |
if (edition != null) { |
|
115 |
edition.delete() |
|
116 |
} |
|
117 |
|
|
118 |
edition = new Edition(text); |
|
119 |
|
|
103 | 120 |
List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang); |
104 | 121 |
List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang); |
105 | 122 |
|
106 |
Text t = project.getText(textname); |
|
107 |
if (t == null) { |
|
108 |
t = new Text(project); |
|
109 |
} |
|
110 |
t.setName(textname); |
|
111 |
t.setSourceFile(txmFile) |
|
112 |
t.setTXMFile(txmFile) |
|
113 | 123 |
|
114 | 124 |
def ed = new XTZDefaultPagerStep(this, txmFile, textname, NoSpaceBefore, NoSpaceAfter, css); |
115 | 125 |
if (!ed.process()) { |
116 | 126 |
println "Fail to build 'default' edition for text: $txmFile" |
117 | 127 |
continue; |
118 | 128 |
} |
119 |
Edition edition = t.getEdition("default") |
|
120 |
if (edition == null) { |
|
121 |
edition = new Edition(t); |
|
122 |
} |
|
129 |
|
|
123 | 130 |
edition.setName("default"); |
124 | 131 |
edition.setIndex(outputDirectory.getAbsolutePath()); |
125 |
|
|
126 |
for (i = 0 ; i < ed.getPageFiles().size();) { |
|
132 |
|
|
133 |
for (int i = 0 ; i < ed.getPageFiles().size();) {
|
|
127 | 134 |
File f = ed.getPageFiles().get(i); |
128 | 135 |
String wordid = "w_0"; |
129 | 136 |
if (i < ed.getIdx().size()) wordid = ed.getIdx().get(i); |
... | ... | |
165 | 172 |
|
166 | 173 |
String imageDirectoryPath = project.getEditionDefinition("facs").getImagesDirectory(); |
167 | 174 |
File imageDirectory = null |
168 |
|
|
175 |
|
|
169 | 176 |
if (imageDirectoryPath != null) { |
170 | 177 |
imageDirectoryPath = imageDirectoryPath.trim() |
171 | 178 |
imageDirectory = new File(imageDirectoryPath) |
... | ... | |
176 | 183 |
|
177 | 184 |
def second = 0 |
178 | 185 |
|
179 |
println "-- Building 'facs' edition of ${files.size()} texts..." |
|
186 |
def texts = module.getProject().getTexts() |
|
187 |
println "-- Building 'facs' edition of ${texts.size()} texts..." |
|
180 | 188 |
File newEditionDirectory = new File(htmlDirectory, "facs"); |
181 | 189 |
newEditionDirectory.mkdir(); |
182 | 190 |
|
183 |
ConsoleProgressBar cpb = new ConsoleProgressBar(files.size())
|
|
184 |
for (File txmFile : files) {
|
|
191 |
ConsoleProgressBar cpb = new ConsoleProgressBar(texts.size())
|
|
192 |
for (Text text : texts) {
|
|
185 | 193 |
cpb.tick() |
186 |
String txtname = txmFile.getName(); |
|
187 |
int i = txtname.lastIndexOf("."); |
|
188 |
if (i > 0) txtname = txtname.substring(0, i); |
|
189 | 194 |
|
195 |
File txmFile = text.getXMLTXMFile() |
|
196 |
String txtname = text.getName() |
|
197 |
|
|
190 | 198 |
File firstHTMLPageFile = new File(newEditionDirectory, txtname+"_1.html"); |
191 |
if (firstHTMLPageFile.exists() && firstHTMLPageFile.lastModified() >= txmFile.lastModified()) continue; |
|
199 |
boolean mustBuild = false; |
|
200 |
if (!firstHTMLPageFile.exists() || txmFile.lastModified() >= firstHTMLPageFile.lastModified()) { |
|
201 |
mustBuild = true |
|
202 |
} |
|
203 |
|
|
204 |
if (!text.isDirty() && !mustBuild) { |
|
205 |
Log.finer("skipping 'default html' step of $text"); |
|
206 |
continue |
|
207 |
} |
|
192 | 208 |
|
209 |
Edition edition = text.getEdition("facs") |
|
210 |
if (edition != null) { |
|
211 |
edition.delete() |
|
212 |
} |
|
213 |
|
|
214 |
edition = new Edition(text); |
|
215 |
|
|
193 | 216 |
List<String> NoSpaceBefore = LangFormater.getNoSpaceBefore(lang); |
194 | 217 |
List<String> NoSpaceAfter = LangFormater.getNoSpaceAfter(lang); |
195 | 218 |
|
196 |
Text t = project.getText(txtname); |
|
197 |
if (t == null) { |
|
198 |
t = new Text(project); |
|
199 |
} |
|
200 |
t.setName(txtname); |
|
201 |
t.setSourceFile(txmFile) |
|
202 |
t.setTXMFile(txmFile) |
|
203 |
|
|
204 |
Edition edition = t.getEdition("facs") |
|
205 |
if (edition == null) { |
|
206 |
edition = new Edition(t); |
|
207 |
} |
|
208 | 219 |
edition.setName("facs"); |
209 | 220 |
edition.setIndex(outputDirectory.getAbsolutePath()); |
210 | 221 |
|
... | ... | |
216 | 227 |
} |
217 | 228 |
|
218 | 229 |
def pages = ed.getPageFiles() |
219 |
for (i = 0 ; i < pages.size();) { |
|
230 |
for (int i = 0 ; i < pages.size();) {
|
|
220 | 231 |
File f = pages[i][0]; |
221 | 232 |
String wordid = pages[i][1] |
222 | 233 |
//TODO replace '""+(++i)' with something that fetch/findout the page 'name' |
... | ... | |
231 | 242 |
} |
232 | 243 |
} |
233 | 244 |
|
234 |
|
|
245 |
|
|
235 | 246 |
if (!imageDirectoryPath.startsWith("http") && imageDirectory != null) { // copy files only if local |
236 | 247 |
File editionImagesDirectory = new File(newEditionDirectory, "res/images/"+corpusname+"/facs"); |
237 | 248 |
editionImagesDirectory.mkdirs(); |
... | ... | |
281 | 292 |
String s = project.getEditionDefinition("default").getWordsPerPage(); |
282 | 293 |
if (s != null && s.length() > 0) |
283 | 294 |
|
284 |
// shared XSL parameters |
|
295 |
// shared XSL parameters
|
|
285 | 296 |
xslParams["number-words-per-page"] = Integer.parseInt(s); |
286 | 297 |
xslParams["pagination-element"] = project.getEditionDefinition("default").getPageElement(); |
287 | 298 |
xslParams["import-xml-path"] = project.getProjectDirectory() |
288 | 299 |
//println "XSL PARAMS: "+xslParams |
289 | 300 |
|
290 | 301 |
def xslFiles = xslDirectory.listFiles() |
291 |
xslFiles = xslFiles.sort() { f ->
|
|
302 |
xslFiles = xslFiles.sort() { f -> |
|
292 | 303 |
try { |
293 |
return Integer.parseInt(f.getName().substring(0, f.getName().indexOf("-"))) |
|
304 |
return Integer.parseInt(f.getName().substring(0, f.getName().indexOf("-")))
|
|
294 | 305 |
} catch(Exception e) {} |
295 | 306 |
return -1; |
296 | 307 |
} |
... | ... | |
323 | 334 |
|
324 | 335 |
if (editionsCreated[editionName] == null) { // first XSL, replace an edition |
325 | 336 |
editionsCreated[editionName] = xslFile |
326 |
//if (!importModule.isUpdatingCorpus()) { |
|
327 |
//TODO: optimisation if update is enable, |
|
337 |
|
|
328 | 338 |
newEditionDirectory.deleteDir(); // delete previous edition if any |
329 |
//} |
|
330 | 339 |
newEditionDirectory.mkdir() |
331 | 340 |
|
332 | 341 |
boolean deleteOutputFiles = "pager" == pagerStep; |
342 |
|
|
333 | 343 |
if (ApplyXsl2.processImportSources(xslFile, inputDirectory, newEditionDirectory, xslParams, deleteOutputFiles)) { |
334 | 344 |
println "" |
335 | 345 |
} else { |
... | ... | |
384 | 394 |
|
385 | 395 |
getFirstWordIDs(textName, editionName, newEditionDirectory, xslFile, txmFile); |
386 | 396 |
} |
387 |
|
|
397 |
|
|
388 | 398 |
def editionDeclaration = project.getEditionDefinition(editionName); // create the edition definition |
389 | 399 |
editionDeclaration.setBuildEdition(true) |
390 | 400 |
editionDeclaration.setPageBreakTag(project.getEditionDefinition("default").getPageElement()) |
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZDefaultPagerStep.groovy (revision 2246) | ||
---|---|---|
211 | 211 |
pagedWriter = new StaxStackWriter(outfile, "UTF-8"); |
212 | 212 |
|
213 | 213 |
//pagedWriter.writeStartDocument() |
214 |
pagedWriter.writeDTD("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
|
|
214 |
pagedWriter.writeDTD("<!DOCTYPE html>") |
|
215 | 215 |
pagedWriter.writeCharacters("\n") |
216 | 216 |
pagedWriter.writeStartElement("html"); |
217 | 217 |
pagedWriter.writeCharacters("\n") |
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImporter.groovy (revision 2246) | ||
---|---|---|
115 | 115 |
Toolbox.getPreference(TBXPreferences.METADATA_TXTSEPARATOR), 1) |
116 | 116 |
} |
117 | 117 |
|
118 |
String cleanDirectories = project.getCleanAfterBuild(); |
|
118 |
// remove previous Text if any |
|
119 |
project.deleteChildren(Text.class); |
|
120 |
|
|
121 |
|
|
122 |
// main workflow of XTZ importer step |
|
123 |
|
|
119 | 124 |
|
120 | 125 |
if (!doFixSurrogates()) return; |
121 | 126 |
if (!doSplitMergeXSLStep()) return; |
... | ... | |
126 | 131 |
if (!doEncodeMileStonesStep()) return; |
127 | 132 |
if (!doToXMLTXMStep()) return; |
128 | 133 |
if (!doInjectMetadataStep()) return; |
129 |
|
|
134 |
|
|
130 | 135 |
isSuccessFul = filesToProcess.size() > 0 |
131 | 136 |
|
137 |
String cleanDirectories = project.getCleanAfterBuild(); |
|
132 | 138 |
if ("true".equals(cleanDirectories)) { |
133 | 139 |
new File(module.getBinaryDirectory(), "tokenized").deleteDir() |
134 | 140 |
new File(module.getBinaryDirectory(), "src").deleteDir() |
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xml/pager.groovy (revision 2246) | ||
---|---|---|
209 | 209 |
pagedWriter = new StaxStackWriter(outfile, "UTF-8"); |
210 | 210 |
|
211 | 211 |
//pagedWriter.writeStartDocument() |
212 |
pagedWriter.writeDTD("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
|
|
212 |
pagedWriter.writeDTD("<!DOCTYPE html>") |
|
213 | 213 |
pagedWriter.writeCharacters("\n") |
214 | 214 |
pagedWriter.writeStartElement("html"); |
215 | 215 |
pagedWriter.writeCharacters("\n") |
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/tmx/pager.groovy (revision 2246) | ||
---|---|---|
182 | 182 |
multiwriter = new OutputStreamWriter(new FileOutputStream(outfile) , "UTF-8"); |
183 | 183 |
|
184 | 184 |
multiwriter.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); |
185 |
multiwriter.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n")
|
|
185 |
multiwriter.write("<!DOCTYPE html>\n") |
|
186 | 186 |
multiwriter.write("<html>"); |
187 | 187 |
multiwriter.write("<head>"); |
188 | 188 |
multiwriter.write("<title>"+basename.toUpperCase()+" $txtname Edition - Page "+pagecount+"</title>"); |
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/importer.groovy (revision 2246) | ||
---|---|---|
133 | 133 |
if (metadatas != null) { |
134 | 134 |
if (metadatas.getHeadersList().size() > 0) { |
135 | 135 |
|
136 |
println "Injecting metadatas "+metadatas.getHeadersList()+" in "+trsfiles.size()+" files"
|
|
136 |
println "Injecting metadata "+metadatas.getHeadersList()+" in "+trsfiles.size()+" files" |
|
137 | 137 |
|
138 | 138 |
trsfiles = txmDir.listFiles(); |
139 | 139 |
trsfiles.sort() |
... | ... | |
142 | 142 |
if (metadatas != null && metadatas.isInitialized()) { |
143 | 143 |
print "." |
144 | 144 |
if (!metadatas.injectMetadatasInXml(infile, outfile, "text")) { |
145 |
println("Failed to inject metadatas in "+infile)
|
|
145 |
println("Failed to inject metadata in "+infile) |
|
146 | 146 |
outfile.delete() |
147 | 147 |
} |
148 | 148 |
if (!infile.delete()) { |
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/transcriberLoader.groovy (revision 2246) | ||
---|---|---|
101 | 101 |
//get metadata values from CSV |
102 | 102 |
Metadatas metadatas; // text metadata |
103 | 103 |
File allMetadataFile = Metadatas.findMetadataFile(srcDir); |
104 |
println "Trying to read metadatas values from: "+allMetadataFile
|
|
104 |
println "Trying to read metadata values from: "+allMetadataFile |
|
105 | 105 |
if (allMetadataFile.exists()) { |
106 | 106 |
File copy = new File(binDir, allMetadataFile.getName()) |
107 | 107 |
if (!FileCopy.copy(allMetadataFile, copy)) { |
Formats disponibles : Unified diff