Revision 479 tmp/org.txm.groovy.core/src/groovy/org/txm/importer/xml/importer.groovy

importer.groovy (revision 479)
21 21
//
22 22
//
23 23
//
24
// $LastChangedDate: 2016-12-01 17:48:31 +0100 (Thu, 01 Dec 2016) $
25
// $LastChangedRevision: 3351 $
24
// $LastChangedDate: 2017-06-26 16:53:47 +0200 (lun. 26 juin 2017) $
25
// $LastChangedRevision: 3451 $
26 26
// $LastChangedBy: mdecorde $
27 27
//
28 28
package org.txm.importer.xml
......
134 134
			return false;
135 135
		}
136 136
		
137
		// Fix surrogates
138
		File srcDirectory = new File(binDir, "src")
139
		srcDirectory.mkdir()
140
		for (File f : okfiles) {
141
			File outputFile = new File (srcDirectory, f.getName())
142
			CleanFile.removeSurrogateFromXmlFile(f, outputFile);
143
		}
144
		okfiles = srcDirectory.listFiles()
145
		okfiles.sort()
146
		
137 147
		//println "ptokenfiles "+ptokenfiles
138 148
		//TOKENIZE FILES
139 149
		List<File> tokenfiles;
......
142 152
			for (File f : okfiles) {
143 153
				print "."
144 154
				File infile = f;
145
				File outfile = new File(binDir,"tokenized/"+f.getName());
155
				File outfile = new File(binDir, "tokenized/"+f.getName());
146 156
				SimpleTokenizerXml tokenizer = new SimpleTokenizerXml(infile, outfile, lang)
147 157
				if (ignoredElements != null && ignoredElements.trim().length() > 0)
148 158
					tokenizer.setOutSideTextTagsAndKeepContent(ignoredElements)
......
151 161
					outfile.delete()
152 162
				}
153 163
			}
154
			tokenfiles = new File(binDir,"tokenized").listFiles()
164
			tokenfiles = new File(binDir, "tokenized").listFiles()
155 165
			println ""
156 166
		} else {
157 167
			tokenfiles = okfiles;
......
164 174
//				return false;
165 175
//			}
166 176
//		}
167

  
177
		if (tokenfiles.size() == 0) {
178
			return false;
179
		}
168 180
		//TRANSFORM INTO XML-TEI-TXM
169 181
		println("Building XML-TXM ("+tokenfiles.size()+" files)")
170 182
		for (File f : tokenfiles) {
......
199 211
			}
200 212
		}
201 213
		println ""
202
		return true;
214
		okfiles = txmDir.listFiles()
215
		
216
		return okfiles != null && okfiles.size() > 0;
203 217
	}
204 218

  
205 219
	boolean stopIfMalformed = false;

Also available in: Unified diff