Revision 1094 tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/txt/compiler.groovy

compiler.groovy (revision 1094)
34 34
import org.txm.scripts.importer.*;
35 35
import org.txm.scripts.*;
36 36
import org.txm.importer.scripts.xmltxm.*;
37
import org.txm.objects.Project
37 38
import org.txm.utils.treetagger.TreeTagger;
38 39

  
39 40
import javax.xml.stream.*;
......
71 72
	private def url;
72 73
	
73 74
	/** The anahash. */
74
	private HashMap<String,String> anahash = new HashMap<String,String>() ;
75
	private HashMap<String, String> anahash = new HashMap<String,String>() ;
75 76
	
76 77
	/** The text. */
77 78
	String text="";
......
79 80
	/** The base. */
80 81
	String base="";
81 82
	
82
	/** The project. */
83
	String project="";
84
	
85 83
	/** The lang. */
86 84
	private String lang ="fr";
87 85
	
......
94 92
	 * @param project the project
95 93
	 */
96 94
	
97
	public compiler(URL url,String text,String base, String project)
95
	public compiler(URL url,String text,String base, String projectName)
98 96
	{
99 97
		this.text = text
100 98
		this.base = base;
101
		this.project = project;
102 99
		this.url = url;
103 100
	}
104 101
	
......
172 169
	 * @param basename the basename
173 170
	 * @return true, if successful
174 171
	 */
175
	public boolean run(File binDir, File txmDir, String corpusname) 
172
	public boolean run(Project project) 
176 173
	{
174
		File binDir = project.getProjectDirectory()
175
		String corpusname = project.getName();
176
		File txmDir = new File(binDir, "txm/"+corpusname)
177
		
177 178
		if (!(CwbEncode.isExecutableAvailable() && CwbMakeAll.isExecutableAvailable())) {
178 179
			println ("Error: CWB executables not well set.")
179 180
			return false;
180 181
		}
181
		if (!binDir.exists()) {
182
			println ("Binary directory does not exists: "+binDir)
183
			return false;
182
		
183
		CorpusBuild corpus = project.getCorpusBuild(project.getName());
184
		if (corpus != null) {
185
			println "CLEAN PREVIOUS CORPUS"
186
			corpus.delete(); // remove old files
184 187
		}
188
			
189
		// make new one
190
		corpus = new MainCorpus(project);
191
		corpus.setID(project.getName());
192
		corpus.setName(project.getName());
193
		corpus.setDescription("Build the alceste import module");
185 194
		
186 195
		File cqpFile = new File(binDir,"cqp/"+corpusname+".cqp");
187
		new File(binDir, "cqp").deleteDir();
188
		new File(binDir, "cqp").mkdir();
189
		new File(binDir, "data").deleteDir();
190
		new File(binDir, "data").mkdir();
191
		new File(binDir, "registry").mkdir();
196
		new File(binDir,"cqp").mkdirs()
197
		new File(binDir,"data").mkdirs()
198
		new File(binDir,"registry").mkdirs()
192 199
		
193 200
		String textid="";
194 201
		int counttext =0;
......
216 223
			if (!cqpbuilder.transformFile(cqpFile)) {
217 224
				println("Failed to compile "+txmfile)
218 225
			}
219
			
220
//			println "$txmfile pAttrs : "+cqpbuilder.getpAttributs()
221
//			println "$txmfile sAttrs : "+cqpbuilder.getsAttributs()
222 226
		}
223 227
		println ""
224 228
		
......
248 252
		
249 253
		try {
250 254
			String regPath = outDir + "/registry/"+corpusname.toLowerCase();
251
			cwbEn.run(outDir + "/data/$corpusname", outDir + "/cqp/"+corpusname+".cqp", regPath, pAttributes, sAttributes);
255
			cwbEn.run(outDir + "/data/${corpusname}", outDir + "/cqp/"+corpusname+".cqp", regPath, pAttributes, sAttributes);
252 256
			if (!new File(regPath).exists()) {
253 257
				println "Error: The registry file was not created: $regPath. See https://groupes.renater.fr/wiki/txm-users/public/faq"
254 258
				return false;

Also available in: Unified diff