Révision 3403
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/editors/imports/MetadataPage.java (revision 3403) | ||
---|---|---|
480 | 480 |
//viewer2.refresh(); |
481 | 481 |
if (main.getRootDir() == null) return; |
482 | 482 |
|
483 |
metadataFile = Metadatas.findMetadataFile(new File(main.getRootDir())); //$NON-NLS-1$
|
|
483 |
metadataFile = Metadatas.findMetadataFile(new File(main.getRootDir())); |
|
484 | 484 |
Metadatas temp = null; |
485 |
if (metadataFile.exists()) {//if their is a metadata file OK |
|
485 |
if (metadataFile != null && metadataFile.exists()) {//if their is a metadata file OK
|
|
486 | 486 |
String encoding = TBXPreferences.getInstance().getString(TBXPreferences.METADATA_ENCODING); |
487 | 487 |
String colsep = TBXPreferences.getInstance().getString(TBXPreferences.METADATA_COLSEPARATOR); |
488 | 488 |
String txtsep = TBXPreferences.getInstance().getString(TBXPreferences.METADATA_TXTSEPARATOR); |
TXM/trunk/org.txm.core/src/java/org/txm/metadatas/Metadatas.java (revision 3403) | ||
---|---|---|
131 | 131 |
* |
132 | 132 |
* @param directory |
133 | 133 |
* @return an input file, try in order : ods, xlsx, tsv and finally csv |
134 |
* extension |
|
134 |
* extension. If no file is found returns NULL
|
|
135 | 135 |
*/ |
136 | 136 |
public static File findMetadataFile(File directory) { |
137 | 137 |
|
... | ... | |
144 | 144 |
f = new File(directory, "metadata.tsv"); |
145 | 145 |
if (f.exists()) return f; |
146 | 146 |
|
147 |
return new File(directory, "metadata.csv"); |
|
147 |
f = new File(directory, "metadata.csv"); |
|
148 |
if (f.exists()) return f; |
|
149 |
|
|
150 |
return null; |
|
148 | 151 |
} |
149 | 152 |
|
150 | 153 |
/** |
TXM/trunk/org.txm.core/src/java/org/txm/scripts/importer/XMLText2TXTCSV.groovy (revision 3403) | ||
---|---|---|
8 | 8 |
println "1) xml -> txt + write metadata.csv" |
9 | 9 |
outdir.deleteDir() |
10 | 10 |
outdir.mkdir() |
11 |
File metadatafile = Metadatas.findMetadataFile(outdir)
|
|
11 |
File metadatafile = new File(outdir, "metadata.csv")
|
|
12 | 12 |
String csvString = "" |
13 | 13 |
|
14 | 14 |
def files = dir.listFiles(IOUtils.HIDDENFILE_FILTER) |
TXM/trunk/org.txm.tigersearch.rcp/groovy/org/txm/scripts/importer/tigersearch/TSImporter.groovy (revision 3403) | ||
---|---|---|
31 | 31 |
|
32 | 32 |
//prepare metadata if any |
33 | 33 |
File allMetadataFile = Metadatas.findMetadataFile(inputDirectory); |
34 |
if (allMetadataFile.exists()) { |
|
34 |
if (allMetadataFile != null && allMetadataFile.exists()) {
|
|
35 | 35 |
File copy = new File(module.getBinaryDirectory(), allMetadataFile.getName()) |
36 | 36 |
if (!FileCopy.copy(allMetadataFile, copy)) { |
37 | 37 |
println "Error: could not create a copy of the metadata file "+allMetadataFile.getAbsoluteFile(); |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/macro/prototypes/importer/XTZImporterMacro.groovy (revision 3403) | ||
---|---|---|
233 | 233 |
|
234 | 234 |
println "Trying to read metadata from: "+allMetadataFile |
235 | 235 |
if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); } |
236 |
if (allMetadataFile.exists()) { |
|
236 |
if (allMetadataFile != null && allMetadataFile.exists()) {
|
|
237 | 237 |
File copy = new File(binDir, allMetadataFile.getName()) |
238 | 238 |
if (!FileCopy.copy(allMetadataFile, copy)) { |
239 | 239 |
println "Error: could not create a copy of metadata file "+allMetadataFile.getAbsoluteFile(); |
240 | 240 |
return; |
241 | 241 |
} |
242 | 242 |
metadatas = new Metadatas(copy, Toolbox.getMetadataEncoding(), Toolbox.getMetadataColumnSeparator(), Toolbox.getMetadataTextSeparator(), 1) |
243 |
} else { |
|
244 |
println "no metadata file: "+allMetadataFile |
|
245 | 243 |
} |
246 | 244 |
|
247 | 245 |
if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); } |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/macro/projects/nov13/PrepareTranscriptionsMacro.groovy (revision 3403) | ||
---|---|---|
63 | 63 |
sectionsDirectory.mkdir() |
64 | 64 |
gse.runMacro(org.txm.macro.transcription.SegmentTRSInSectionFromMarkerMacro, ["trsDirectory":trsDirectory, "resultDirectory":sectionsDirectory, "newSectionMarker":newSectionMarker, "debug":debug]) |
65 | 65 |
|
66 |
if (cleanWorkingDirectories) { |
|
67 |
trsDirectory.deleteDir() |
|
68 |
} |
|
66 | 69 |
|
67 | 70 |
println "SPOTTING 'OTHER' TURNS..." |
68 | 71 |
|
... | ... | |
90 | 93 |
} |
91 | 94 |
} |
92 | 95 |
cpb.done() |
96 |
if (cleanWorkingDirectories) { |
|
97 |
sectionsDirectory.deleteDir() |
|
98 |
} |
|
93 | 99 |
|
94 | 100 |
println "CONVERTING WORD MARKERS TO EVENTS..." |
95 | 101 |
|
... | ... | |
103 | 109 |
eventsDirectory.mkdir() |
104 | 110 |
gse.runMacro(org.txm.macro.transcription.AddEventsFromWordMarkersMacro, ["trsDirectory":otherDirectory, "resultDirectory":eventsDirectory, "wordElement": "w", "newEventMarker":"XXX", "eventDescription":"termes incompréhensibles ou inaudibles", "eventType":"pi", "eventExtent": "instantaneous", "debug":debug]) |
105 | 111 |
|
112 |
if (cleanWorkingDirectories) { |
|
113 |
otherDirectory.deleteDir() |
|
114 |
} |
|
106 | 115 |
|
107 | 116 |
println "NORMALIZING SPEAKER IDs..." |
108 | 117 |
|
... | ... | |
141 | 150 |
cpb.done() |
142 | 151 |
|
143 | 152 |
if (cleanWorkingDirectories) { |
144 |
otherDirectory.deleteDir() |
|
145 |
trsDirectory.deleteDir() |
|
146 |
sectionsDirectory.deleteDir() |
|
147 | 153 |
eventsDirectory.deleteDir() |
148 | 154 |
} |
149 | 155 |
|
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/macro/xml/XMLText2MetadataCSVMacro.groovy (revision 3403) | ||
---|---|---|
48 | 48 |
} |
49 | 49 |
println "XPATH queries: $xpaths" |
50 | 50 |
|
51 |
if (metadataFile == null) |
|
52 |
metadataFile = Metadatas.findMetadataFile(srcDirectory) |
|
51 |
if (metadataFile == null) { |
|
52 |
metadataFile = new File(srcDirectory, "metadata.csv") |
|
53 |
} |
|
53 | 54 |
|
54 | 55 |
def writer = metadataFile.newWriter("UTF-8") |
55 | 56 |
println "Creating file: $metadataFile" |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/prototypes/InjectMetadataCSV.groovy (revision 3403) | ||
---|---|---|
1 | 1 |
package org.txm.scripts.test; |
2 | 2 |
import org.txm.metadatas.*; |
3 | 3 |
|
4 |
def txmfilesdir = new File("C:\\Documents and Settings\\alavrent\\xml\\metadata")
|
|
5 |
def outdir = new File("C:\\Documents and Settings\\alavrent\\xml\\metadata\\meta")
|
|
4 |
def txmfilesdir = new File(System.getProperty("user.home"), "xml/metadata")
|
|
5 |
def outdir = new File(System.getProperty("user.home"), "xml/metadata/meta")
|
|
6 | 6 |
outdir.mkdir() |
7 |
def allMetadataFile = Metadatas.findMetadataFile(new File("C:\\Documents and Settings\\alavrent\\xml\\metadata"));
|
|
8 |
println "-- INJECT METADATA - from csv file: "+allMetadataFile+" in directory: "+txmfilesdir
|
|
7 |
def allMetadataFile = Metadatas.findMetadataFile(outdir);
|
|
8 |
println "-- INJECT METADATA - from table file: "+allMetadataFile+" in directory: "+txmfilesdir
|
|
9 | 9 |
def metadatas = new Metadatas(allMetadataFile, "UTF-8", ",","\"", 1) |
10 | 10 |
if(metadatas != null) |
11 | 11 |
{ |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImport.groovy (revision 3403) | ||
---|---|---|
46 | 46 |
Metadatas metadata = importer.getMetadata(); |
47 | 47 |
if (metadata == null) { // if metadata was not built, try building it |
48 | 48 |
File allMetadataFile = Metadatas.findMetadataFile(binaryDirectory); |
49 |
if (allMetadataFile.exists()) { |
|
49 |
if (allMetadataFile != null && allMetadataFile.exists()) {
|
|
50 | 50 |
metadata = new Metadatas(allMetadataFile, |
51 | 51 |
Toolbox.getPreference(TBXPreferences.METADATA_ENCODING), |
52 | 52 |
Toolbox.getPreference(TBXPreferences.METADATA_COLSEPARATOR), |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImporter.groovy (revision 3403) | ||
---|---|---|
111 | 111 |
|
112 | 112 |
//prepare metadata if any |
113 | 113 |
File allMetadataFile = Metadatas.findMetadataFile(inputDirectory); |
114 |
println "ALLMETADATAFILE="+allMetadataFile |
|
115 |
if (allMetadataFile.exists()) { |
|
114 |
if (allMetadataFile != null && allMetadataFile.exists()) { |
|
116 | 115 |
File copy = new File(binDir, allMetadataFile.getName()) |
117 | 116 |
if (!FileCopy.copy(allMetadataFile, copy)) { |
118 | 117 |
println "Error: could not create a copy of the metadata file "+allMetadataFile.getAbsoluteFile(); |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xmltxm/xmltxmLoader.groovy (revision 3403) | ||
---|---|---|
84 | 84 |
txmDir.deleteDir(); |
85 | 85 |
txmDir.mkdirs(); |
86 | 86 |
|
87 |
File allMetadataFile = Metadatas.findMetadataFile(srcDir); |
|
88 |
|
|
89 | 87 |
// Apply XSL |
90 | 88 |
if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); } |
91 | 89 |
if (MONITOR != null) MONITOR.worked(1, "APPLYING XSL") |
... | ... | |
115 | 113 |
return; |
116 | 114 |
} |
117 | 115 |
|
118 |
////get metadata values from CSV |
|
119 |
//Metadatas metadatas; // text metadata |
|
120 |
//if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); } |
|
121 |
//if (allMetadataFile.exists()) { |
|
122 |
// println "Trying to read metadata from: "+allMetadataFile |
|
123 |
// File copy = new File(binDir, "metadata.csv") |
|
124 |
// if (!FileCopy.copy(allMetadataFile, copy)) { |
|
125 |
// println "Error: could not create a copy of metadata file "+allMetadataFile.getAbsoluteFile(); |
|
126 |
// return; |
|
127 |
// } |
|
128 |
// metadatas = new Metadatas(copy, Toolbox.getMetadataEncoding(), Toolbox.getMetadataColumnSeparator(), Toolbox.getMetadataTextSeparator(), 1) |
|
129 |
//} else { |
|
130 |
// println "no metadata file: "+allMetadataFile |
|
131 |
//} |
|
132 |
// |
|
133 |
//if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); } |
|
134 |
//if (MONITOR != null) MONITOR.worked(20, "INJECTING METADATA - from csv file: "+allMetadataFile) |
|
135 |
//if (metadatas != null) { |
|
136 |
// println("Injecting metadata: "+metadatas.getHeadersList()+" in texts of directory "+txmDir) |
|
137 |
// for (File infile : files) { |
|
138 |
// print "." |
|
139 |
// File outfile = File.createTempFile("temp", ".xml", infile.getParentFile()); |
|
140 |
// |
|
141 |
// if (!metadatas.injectMetadatasInXml(infile, outfile, "text", null)) { |
|
142 |
// outfile.delete(); |
|
143 |
// } else { |
|
144 |
// if (!(infile.delete() && outfile.renameTo(infile))) println "Warning can't rename file "+outfile+" to "+infile |
|
145 |
// if (!infile.exists()) { |
|
146 |
// println "Error: could not replace $infile by $outfile" |
|
147 |
// return false; |
|
148 |
// } |
|
149 |
// } |
|
150 |
// } |
|
151 |
// println "" |
|
152 |
//} |
|
153 |
|
|
154 | 116 |
//sorting files per metadata "date" with format |
155 | 117 |
def dates = [:] |
156 | 118 |
def useDates = false |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/discours/importer.groovy (revision 3403) | ||
---|---|---|
2 | 2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
3 | 3 |
// Lyon 2, University of Franche-Comté, University of Nice |
4 | 4 |
// Sophia Antipolis, University of Paris 3. |
5 |
//
|
|
5 |
// |
|
6 | 6 |
// The TXM platform is free software: you can redistribute it |
7 | 7 |
// and/or modify it under the terms of the GNU General Public |
8 | 8 |
// License as published by the Free Software Foundation, |
9 | 9 |
// either version 2 of the License, or (at your option) any |
10 | 10 |
// later version. |
11 |
//
|
|
11 |
// |
|
12 | 12 |
// The TXM platform is distributed in the hope that it will be |
13 | 13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
14 | 14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
15 | 15 |
// PURPOSE. See the GNU General Public License for more |
16 | 16 |
// details. |
17 |
//
|
|
17 |
// |
|
18 | 18 |
// You should have received a copy of the GNU General |
19 | 19 |
// Public License along with the TXM platform. If not, see |
20 | 20 |
// http://www.gnu.org/licenses. |
... | ... | |
56 | 56 |
import org.txm.utils.io.*; |
57 | 57 |
import org.txm.utils.i18n.DetectBOM; |
58 | 58 |
|
59 |
// TODO: Auto-generated Javadoc |
|
60 | 59 |
/** |
61 | 60 |
* The Class importer. |
62 | 61 |
*/ |
63 | 62 |
class importer { |
64 |
|
|
63 |
|
|
65 | 64 |
/** |
66 | 65 |
* Run. |
67 | 66 |
* |
... | ... | |
70 | 69 |
* @param basename the basename |
71 | 70 |
* @return true, if successful |
72 | 71 |
*/ |
73 |
public boolean run(File srcDir, File binDir, File txmDir, String encoding, String basename, def project) |
|
74 |
{ |
|
72 |
public boolean run(File srcDir, File binDir, File txmDir, String encoding, String basename, def project) {
|
|
73 |
|
|
75 | 74 |
String rootDir = srcDir.getAbsolutePath()+"/" |
76 | 75 |
// scanning directory brut/*.cnr |
77 | 76 |
String extension = "cnr"; |
78 | 77 |
File[] list = srcDir.listFiles(); |
79 | 78 |
|
80 | 79 |
if (list == null || list.length == 0) return false; |
81 |
|
|
80 |
|
|
82 | 81 |
LinkedList filelist = new LinkedList(); |
83 | 82 |
for (File cnr : list) { |
84 | 83 |
if (cnr.getName().endsWith("."+extension)) { |
... | ... | |
86 | 85 |
} |
87 | 86 |
} |
88 | 87 |
Collections.sort(filelist); |
89 |
|
|
88 |
|
|
90 | 89 |
// get the headers |
91 | 90 |
def csvfile = Metadatas.findMetadataFile(srcDir); |
92 | 91 |
Metadatas metadatas; // text metadata |
93 | 92 |
|
94 | 93 |
println "Trying to read metadata from: "+csvfile |
95 |
if (csvfile.exists()) { |
|
94 |
if (csvfile != null && csvfile.exists()) {
|
|
96 | 95 |
File copy = new File(binDir, csvfile.getName()) |
97 | 96 |
if (!FileCopy.copy(csvfile, copy)) { |
98 | 97 |
println "Error: could not create a copy of metadata file "+csvfile.getAbsoluteFile(); |
99 | 98 |
return; |
100 | 99 |
} |
101 |
metadatas = new Metadatas(copy, Toolbox.getMetadataEncoding(),
|
|
102 |
Toolbox.getMetadataColumnSeparator(),
|
|
103 |
Toolbox.getMetadataTextSeparator(), 1) |
|
100 |
metadatas = new Metadatas(copy, Toolbox.getMetadataEncoding(), |
|
101 |
Toolbox.getMetadataColumnSeparator(),
|
|
102 |
Toolbox.getMetadataTextSeparator(), 1)
|
|
104 | 103 |
} else { |
105 | 104 |
println "No metadata file: "+csvfile |
106 | 105 |
println "Aborting" |
... | ... | |
111 | 110 |
def attrs = ["para", "sent", "form", "lem", "pos", "func"]; |
112 | 111 |
int formid = 2; |
113 | 112 |
String separator = "\t"; |
114 |
|
|
113 |
|
|
115 | 114 |
String encodingAll = null; |
116 | 115 |
if (encoding == "??") { |
117 | 116 |
encodingAll = new CharsetDetector(srcDir).getEncoding(); |
118 | 117 |
println "Guessed encoding: $encodingAll" |
119 | 118 |
} |
120 |
|
|
119 |
|
|
121 | 120 |
print "Converting CNR to XML:" |
122 | 121 |
def second = 0 |
123 |
for (String id : metadatas.keySet()) // loop on text nodes |
|
124 |
{ |
|
122 |
for (String id : metadatas.keySet()) { // loop on text nodes
|
|
123 |
|
|
125 | 124 |
int sentence=-1, paragraph=-1, idword=0; |
126 | 125 |
String lastopenlocalname= "", localname = ""; |
127 | 126 |
int para = -1, sent = -1; |
... | ... | |
129 | 128 |
// = textnode.attribute("id") |
130 | 129 |
ArrayList<org.txm.metadatas.Entry> metas = metadatas.get(id); |
131 | 130 |
|
132 |
String filename = id +".cnr";
|
|
133 |
File srcfile = new File(srcDir, filename);
|
|
131 |
String filename = id +".cnr" |
|
132 |
File srcfile = new File(srcDir, filename) |
|
134 | 133 |
if (!srcfile.exists()) { |
135 | 134 |
println "Can't find CNR file : "+filename |
136 | 135 |
continue |
137 | 136 |
} |
138 |
File teifile = new File(txmDir, id+".xml");
|
|
137 |
File teifile = new File(txmDir, id+".xml") |
|
139 | 138 |
//println("||"+srcfile+">>"+teifile.getAbsolutePath()); |
140 |
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(teifile), "UTF-8");
|
|
141 |
|
|
142 |
// if (second) { print(", ") } |
|
143 |
// if ((second % 5) == 0) println "" |
|
144 |
// print(filename.replaceFirst("\\.cnr", "")); |
|
145 |
// second++ |
|
146 |
|
|
139 |
OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(teifile), "UTF-8") |
|
140 |
|
|
141 |
// if (second) { print(", ") }
|
|
142 |
// if ((second % 5) == 0) println ""
|
|
143 |
// print(filename.replaceFirst("\\.cnr", ""));
|
|
144 |
// second++
|
|
145 |
|
|
147 | 146 |
// HEADER |
148 | 147 |
writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); |
149 | 148 |
writer.write("<TEI xmlns=\"http://www.tei-c.org/ns/1.0\" xmlns:txm=\"http://textometrie.org/1.0\">\n"); |
... | ... | |
169 | 168 |
String name = metadata.getId() |
170 | 169 |
String value = metadata.getValue() |
171 | 170 |
if (name != "id") |
172 |
writer.write(" "+name+"=\""+value.replace("&", "&").replace("<", "<").replace("\"", """)+"\"");
|
|
171 |
writer.write(" "+name+"=\""+value.replace("&", "&").replace("<", "<").replace("\"", """)+"\""); |
|
173 | 172 |
} |
174 | 173 |
writer.write(" id=\""+id.replace("&", "&").replace("<", "<").replace("\"", """)+"\""); |
175 | 174 |
writer.write(">\n"); |
176 |
|
|
175 |
|
|
177 | 176 |
//def content = srcfile.getText(encoding) |
178 | 177 |
String tmpEncoding = encoding; |
179 | 178 |
if (encodingAll != null) { |
180 | 179 |
tmpEncoding = encodingAll |
181 | 180 |
if (srcfile.length() > CharsetDetector.MINIMALSIZE) { |
182 |
tmpEncoding = new CharsetDetector(srcfile).getEncoding();
|
|
183 |
//println "file encoding: $tmpEncoding"
|
|
181 |
tmpEncoding = new CharsetDetector(srcfile).getEncoding() |
|
182 |
//println "file encoding: $tmpEncoding" |
|
184 | 183 |
} |
185 | 184 |
} |
186 | 185 |
def input = new FileInputStream(srcfile) |
187 |
def reader = new BufferedReader(new InputStreamReader(input , tmpEncoding));
|
|
186 |
def reader = new BufferedReader(new InputStreamReader(input , tmpEncoding)) |
|
188 | 187 |
DetectBOM bomdetector = new DetectBOM(srcfile); |
189 | 188 |
for (int ibom = 0 ; ibom < bomdetector.getBOMSize() ; ibom++) input.read() |
190 |
|
|
189 |
|
|
191 | 190 |
// BODY |
192 | 191 |
String line = reader.readLine(); |
193 | 192 |
int nline = 0; |
... | ... | |
198 | 197 |
nline++; |
199 | 198 |
String[] fields = line.split(separator); |
200 | 199 |
if (fields.size() == attrs.size()) { |
200 |
|
|
201 | 201 |
idword++; |
202 | 202 |
|
203 | 203 |
String paraV = fields[0].replaceAll("\\p{C}", "") |
... | ... | |
247 | 247 |
} |
248 | 248 |
line = reader.readLine(); |
249 | 249 |
} |
250 |
|
|
250 |
|
|
251 | 251 |
// CLOSE |
252 | 252 |
if(sentence != -1) { writer.write("</s>\n") } |
253 | 253 |
if(paragraph != -1) { writer.write("</p>\n") } |
... | ... | |
264 | 264 |
println "" |
265 | 265 |
|
266 | 266 |
if (project.getCleanAfterBuild()) { |
267 |
|
|
267 | 268 |
new File(project.getProjectDirectory(), "tokenized").deleteDir() |
268 | 269 |
new File(project.getProjectDirectory(), "ptokenized").deleteDir() |
269 | 270 |
new File(project.getProjectDirectory(), "stokenized").deleteDir() |
... | ... | |
272 | 273 |
} |
273 | 274 |
return true; |
274 | 275 |
} |
275 |
|
|
276 |
|
|
276 | 277 |
/** |
277 | 278 |
* Gets the metadata. |
278 | 279 |
* |
279 | 280 |
* @return the metadata |
280 | 281 |
*/ |
281 |
public List<String> getMetadatas() |
|
282 |
{ |
|
283 |
return metaDatas;
|
|
282 |
public List<String> getMetadatas() {
|
|
283 |
|
|
284 |
return metadatas;
|
|
284 | 285 |
} |
285 |
|
|
286 |
|
|
286 | 287 |
/** |
287 | 288 |
* The main method. |
288 | 289 |
* |
289 | 290 |
* @param args the arguments |
290 | 291 |
*/ |
291 |
public static void main(String[] args) |
|
292 |
{ |
|
292 |
public static void main(String[] args) {
|
|
293 |
|
|
293 | 294 |
File dir = new File(System.getProperty("user.home"), "xml/discours/"); |
294 | 295 |
new importer().run(dir); |
295 | 296 |
} |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xml/xmlLoader.groovy (revision 3403) | ||
---|---|---|
177 | 177 |
|
178 | 178 |
println "Trying to read metadata from: "+allMetadataFile |
179 | 179 |
if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done() } |
180 |
if (allMetadataFile.exists()) { |
|
180 |
if (allMetadataFile != null && allMetadataFile.exists()) {
|
|
181 | 181 |
println " Metadata file found: "+allMetadataFile |
182 | 182 |
File copy = new File(binDir, allMetadataFile.getName()) |
183 | 183 |
if (!FileCopy.copy(allMetadataFile, copy)) { |
... | ... | |
185 | 185 |
return |
186 | 186 |
} |
187 | 187 |
metadatas = new Metadatas(copy, Toolbox.getMetadataEncoding(), Toolbox.getMetadataColumnSeparator(), Toolbox.getMetadataTextSeparator(), 1) |
188 |
} else { |
|
189 |
println " No metadata file: "+allMetadataFile |
|
190 | 188 |
} |
191 | 189 |
|
192 | 190 |
if (MONITOR != null && MONITOR.isCanceled()) { return MONITOR.done(); } |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/doc/docLoader.groovy (revision 3403) | ||
---|---|---|
192 | 192 |
if (MONITOR != null) MONITOR.worked(20, "READ METADATA") |
193 | 193 |
Metadatas metadatas; // text metadata |
194 | 194 |
//println "Trying to read metadata from: "+allMetadataFile |
195 |
if (allMetadataFile.exists()) { |
|
195 |
if (allMetadataFile != null && allMetadataFile.exists()) {
|
|
196 | 196 |
File copy = new File(binDir, allMetadataFile.getName()) |
197 | 197 |
if (!FileCopy.copy(allMetadataFile, copy)) { |
198 | 198 |
println "Error: could not create a copy of the $allMetadataFile file "+allMetadataFile.getAbsoluteFile(); |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/factiva/factivaLoader.groovy (revision 3403) | ||
---|---|---|
161 | 161 |
//get metadata values from CSV |
162 | 162 |
Metadatas metadatas; // text metadata |
163 | 163 |
println "Trying to read metadata from: "+allMetadataFile |
164 |
if (allMetadataFile.exists()) { |
|
164 |
if (allMetadataFile != null && allMetadataFile.exists()) {
|
|
165 | 165 |
File copy = new File(binDir, allMetadataFile.getName()) |
166 | 166 |
if (!FileCopy.copy(allMetadataFile, copy)) { |
167 | 167 |
println "Error: could not create a copy of metadata file "+allMetadataFile.getAbsoluteFile(); |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/transcriber/transcriberLoader.groovy (revision 3403) | ||
---|---|---|
102 | 102 |
//get metadata values from CSV |
103 | 103 |
Metadatas metadatas; // text metadata |
104 | 104 |
File allMetadataFile = Metadatas.findMetadataFile(srcDir); |
105 |
println "Reading metadata values from: "+allMetadataFile |
|
106 |
if (allMetadataFile.exists()) { |
|
105 |
|
|
106 |
if (allMetadataFile != null && allMetadataFile.exists()) { |
|
107 |
println "Reading metadata values from: "+allMetadataFile |
|
107 | 108 |
File copy = new File(binDir, allMetadataFile.getName()) |
108 | 109 |
if (!FileCopy.copy(allMetadataFile, copy)) { |
109 | 110 |
println "Error: could not create a copy of metadata file "+allMetadataFile.getAbsoluteFile(); |
... | ... | |
112 | 113 |
metadatas = new Metadatas(copy, Toolbox.getMetadataEncoding(), |
113 | 114 |
Toolbox.getMetadataColumnSeparator(), |
114 | 115 |
Toolbox.getMetadataTextSeparator(), 1) |
115 |
} |
|
116 |
else { |
|
117 |
println "no metadata file: "+allMetadataFile |
|
118 | 116 |
} |
119 | 117 |
|
120 | 118 |
final HashMap<String, String> textordersInfo = new HashMap<String, String>(); |
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/txt/txtLoader.groovy (revision 3403) | ||
---|---|---|
80 | 80 |
Metadatas metadatas; // text metadata |
81 | 81 |
File allMetadataFile = Metadatas.findMetadataFile(srcDir); |
82 | 82 |
|
83 |
if (allMetadataFile.exists()) { |
|
83 |
if (allMetadataFile != null && allMetadataFile.exists()) {
|
|
84 | 84 |
println "Trying to read metadata from: "+allMetadataFile |
85 | 85 |
File copy = new File(binDir, allMetadataFile.getName()) |
86 | 86 |
if (!FileCopy.copy(allMetadataFile, copy)) { |
... | ... | |
90 | 90 |
metadatas = new Metadatas(copy, Toolbox.getMetadataEncoding(), |
91 | 91 |
Toolbox.getMetadataColumnSeparator(), |
92 | 92 |
Toolbox.getMetadataTextSeparator(), 1) |
93 |
} else { |
|
94 |
println "No metadata file: "+allMetadataFile |
|
95 | 93 |
} |
96 | 94 |
|
97 | 95 |
def suffixes = ["txt", "TXT"] |
Formats disponibles : Unified diff