Index: tmp/org.txm.core/src/java/org/txm/importer/scripts/xmltxm/AnnotationInjection.groovy
===================================================================
--- tmp/org.txm.core/src/java/org/txm/importer/scripts/xmltxm/AnnotationInjection.groovy	(revision 2986)
+++ tmp/org.txm.core/src/java/org/txm/importer/scripts/xmltxm/AnnotationInjection.groovy	(revision 2987)
@@ -57,7 +57,10 @@
 
 	/** The links. */
 	private LinkedHashSet<String> links;
-	boolean replace
+	/**
+	 * if set, existing values are replaced
+	 */
+	boolean fixExistingValues
 
 	/** The linkparsers. key=type*/
 	private LinkedHashMap<String, XMLStreamReader> linkparsers;
@@ -97,11 +100,11 @@
 	 * @param url the xml-tei-txm file
 	 * @param anaurl the stand-off file
 	 */
-	public AnnotationInjection(URL url, URL anaurl, boolean replace) {
+	public AnnotationInjection(URL url, URL anaurl, boolean fixExistingValues) {
 		super(url); // init reader and writer
 		try {
 			this.anaurl = anaurl;
-			this.replace = replace
+			this.fixExistingValues = fixExistingValues
 			factory = XMLInputFactory.newInstance();
 			this.buildLinkParsers();// build a parser per linkgroup
 		} catch (XMLStreamException ex) {
@@ -288,16 +291,16 @@
 			writer.writeStartElement(TXMNS, "ana");
 			writer.writeAttribute("resp", "#"+respStmtID);
 			writer.writeAttribute("type", "#"+link);
-			if (replace) {
-				if (linkparsers.containsKey(link)) { // order is important
-					writer.writeCharacters(getNextAnaValue(link, wordId));
-				} else {
-					writer.writeCharacters(anaValues.get(link));
-				}
-			} else { // ok no problem
-				writer.writeCharacters(getNextAnaValue(link, wordId));
+			
+			String newValue = getNextAnaValue(link, wordId)
+			if (fixExistingValues || anaValues.containsKey(link) == null) {
+				anaValues.put(link, newValue)
+			} else {
+				anaValues.put(link, "")
 			}
 			
+			writer.writeCharacters(anaValues.get(link));
+			
 			writer.writeEndElement(); // txm:ana
 		}
 	}
@@ -311,7 +314,7 @@
 		if (localname.equals("taxonomy")) {
 			String taxo = parser.getAttributeValue(0) // taxonomy type
 			presentTaxonomies.add(taxo);
-		} else if (flagW && replace && localname.equals("ana")) {
+		} else if (flagW && localname.equals("ana")) {
 			flagAna = true
 			anaValue= ""
 			type = null
Index: tmp/org.txm.treetagger.core/src/org/txm/importer/xmltxm/AnnotateWTC.groovy
===================================================================
--- tmp/org.txm.treetagger.core/src/org/txm/importer/xmltxm/AnnotateWTC.groovy	(revision 2986)
+++ tmp/org.txm.treetagger.core/src/org/txm/importer/xmltxm/AnnotateWTC.groovy	(revision 2987)
@@ -1,179 +0,0 @@
-// Copyright © 2010-2013 ENS de Lyon.
-// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
-// Lyon 2, University of Franche-Comté, University of Nice
-// Sophia Antipolis, University of Paris 3.
-//
-// The TXM platform is free software: you can redistribute it
-// and/or modify it under the terms of the GNU General Public
-// License as published by the Free Software Foundation,
-// either version 2 of the License, or (at your option) any
-// later version.
-//
-// The TXM platform is distributed in the hope that it will be
-// useful, but WITHOUT ANY WARRANTY; without even the implied
-// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-// PURPOSE. See the GNU General Public License for more
-// details.
-//
-// You should have received a copy of the GNU General
-// Public License along with the TXM platform. If not, see
-// http://www.gnu.org/licenses.
-//
-//
-//
-// $LastChangedDate: 2013-12-06 16:57:35 +0100 (Fri, 06 Dec 2013) $
-// $LastChangedRevision: 2583 $
-// $LastChangedBy: mdecorde $
-//
-package org.txm.importer.xmltxm
-
-import java.io.File
-import java.text.DateFormat
-import java.util.Date
-
-import org.txm.Toolbox
-import org.txm.importer.*
-import org.txm.importer.cwb.*
-import org.txm.objects.*
-import org.txm.treetagger.core.preferences.TreeTaggerPreferences
-import org.txm.utils.ConsoleProgressBar
-import org.txm.utils.DeleteDir;
-import org.txm.utils.LangDetector;
-import org.txm.utils.io.IOUtils
-import org.txm.utils.treetagger.TreeTagger
-
-// TODO: Auto-generated Javadoc
-/**
- * Annotate and replace the TEI-TXM files of the folder $rootDirFile/txm with TreeTagger.
- * creates $rootDirFile/interp and $rootDirFile/treetagger
- *
- */
-class AnnotateCQP {
-
-	/** The debug. */
-	boolean debug = true;
-
-	/**
-	 * Sets the debug.
-	 */
-	public void setDebug() { debug=true; }
-
-	String id;
-
-	/**
-	 * Apply tt.
-	 *
-	 * @param ttsrcfile the ttsrcfile
-	 * @param ttoutfile the ttoutfile
-	 * @param modelfile the modelfile
-	 * @return true, if successful
-	 */
-	public boolean applyTT(File ttsrcfile, File ttoutfile, File modelfile)
-	{
-		try {
-			File infile = ttsrcfile;
-			File outfile = ttoutfile;
-
-			// TODO: why org.txm.utils.treetagger.TreeTagger tt = ..., throw IllegalAccessError ???
-			String opt = Toolbox.getPreference(Toolbox.TREETAGGER_OPTIONS);
-			if (opt == null) opt = "";
-			String[] options = opt.split("  ");
-			def tt = new TreeTagger(Toolbox.getPreference(Toolbox.TREETAGGER_INSTALL_PATH)+"/bin/", options);
-			tt.settoken();
-			tt.setlemma();
-			tt.setquiet();
-			tt.setsgml();
-			tt.setnounknown();
-			tt.seteostag("<s>");
-			tt.treetagger(modelfile.getAbsolutePath(), infile.getAbsolutePath(), outfile.getAbsolutePath())
-			//infile.delete();
-		}
-		catch(Exception e)
-		{
-			e.printStackTrace();
-			return false;
-		}
-		return true;
-	}
-
-	/**
-	 * Run.
-	 *
-	 * @param rootDirFile the root dir file
-	 * @param modelfilename the modelfilename
-	 * @return true, if successful
-	 */
-	public boolean run(File binDir, File txmDir,  String modelfilename)
-	{
-		//test if modelfile exists
-		if(debug) {
-			println "rootDirFile "+binDir
-			println "txmDir "+txmDir
-			println "TREETAGGER INSTALL PATH : "+TreeTaggerPreferences.getInstance().getBoolean(TreeTaggerPreferences.INSTALL_PATH)
-			println "TREETAGGER MODELS PATH : "+TreeTaggerPreferences.getInstance().getBoolean(TreeTaggerPreferences.MODELS_PATH)
-		}
-
-		//test if the Toolbox know TreeTagger
-		if (!new File(Toolbox.getPreference(Toolbox.TREETAGGER_INSTALL_PATH)+"/bin/").exists())
-		{
-			println("Could not find TreeTagger binaries in "+Toolbox.getPreference(Toolbox.TREETAGGER_INSTALL_PATH)+"/bin/")
-			return false;
-		}
-
-		//cleaning
-		File annotDir = new File(binDir, "annotations")
-		annotDir.mkdir();
-
-		//BUILD TT FILE READY TO BE TAGGED
-		List<File> files = txmDir.listFiles(IOUtils.HIDDENFILE_FILTER)
-
-		// get model file and check it
-		File modelfile = new File(TreeTaggerPreferences.getInstance().getBoolean(TreeTaggerPreferences.MODELS_PATH), modelfilename);
-		if (debug)
-			println "model file : "+modelfile;
-
-		if (!modelfile.exists()) {
-			println "Skipping ANNOTATE: Incorrect modelfile path: "+modelfile;
-			if(System.getProperty("os.name").startsWith("Windows"))
-				println "Windows users: Windows might be hiding files extension. To see them, in the explorer parameters."
-			return false;
-		}
-
-		//APPLY TREETAGGER
-		println("Applying $modelfilename TreeTagger model on dir: "+txmDir+ " ("+files.size()+" files)")
-		if (files == null || files.size() == 0)
-			return false;
-
-		ConsoleProgressBar cpb = new ConsoleProgressBar(files.size());
-		for (File f : files) {
-			cpb.tick();
-			
-			File infile = f;
-			File outfile = new File(new File(binDir, "annotations"), f.getName());
-			if (outfile.exists() && // outfile exists
-				outfile.lastModified() >= infile.lastModified() && // outfile is more recent 
-				outfile.length() > infile.length()) { // outfile is bigger
-				// skip
-			} else {
-				if (!applyTT(infile, outfile, modelfile)) {
-					System.out.println("Failed to apply treetagger on file "+f);
-					return false;
-				}
-			}
-		}
-		println("")
-
-//		if (DeleteDir.deleteDirectory(txmDir)) {
-//			if (annotDir.renameTo(txmDir)) {
-//
-//			} else {
-//				println "Could not rename  'annotations' directory to 'txm' directory"
-//				return false
-//			}
-//		} else {
-//			println "Could not delete txmDir: $txmDir (and could not copy 'annotations' directory"
-//		}
-
-		return true;
-	}
-}
\ No newline at end of file
Index: tmp/org.txm.treetagger.core/src/org/txm/importer/xmltxm/Annotate.groovy
===================================================================
--- tmp/org.txm.treetagger.core/src/org/txm/importer/xmltxm/Annotate.groovy	(revision 2986)
+++ tmp/org.txm.treetagger.core/src/org/txm/importer/xmltxm/Annotate.groovy	(revision 2987)
@@ -546,7 +546,7 @@
 		return true;
 	}
 	
-	public boolean run(File f, String lang, File binDir, File txmDir) {
+	public boolean run(File f, String lang, boolean fixExistingValues, File binDir, File txmDir) {
 		
 		File annotDir = new File(binDir,"annotations");
 		annotDir.mkdir();
@@ -555,10 +555,10 @@
 		File treetaggerDir = new File(binDir,"treetagger");
 		treetaggerDir.mkdir();
 		
-		return run(f, lang, binDir, txmDir, false, new String[0], new String[0], annotDir, ptreetaggerDir, treetaggerDir)
+		return run(f, lang, binDir, txmDir, fixExistingValues, new String[0], new String[0], annotDir, ptreetaggerDir, treetaggerDir)
 	}
 	
-	public boolean run(File f, String lang, File binDir, File txmDir, boolean replace, String[] properties, String[] options, File annotDir, File ptreetaggerDir, File treetaggerDir) {
+	public boolean run(File f, String lang, File binDir, File txmDir, boolean fixExistingValues, String[] properties, String[] options, File annotDir, File ptreetaggerDir, File treetaggerDir) {
 		
 		File modelfile = new File(modelsDirectory, lang+".par");
 		if (!"??".equals(lang) && !modelfile.exists()) {
@@ -593,7 +593,7 @@
 		
 		//INJECT ANNOTATIONS
 		File tmpFile = new File(txmDir, "temp_"+f.getName())
-		builder = new AnnotationInjection(f.toURL(), annotfile.toURL(), replace);
+		builder = new AnnotationInjection(f.toURL(), annotfile.toURL(), fixExistingValues);
 		builder.process(tmpFile);
 		if (!(f.delete() && tmpFile.renameTo(f))) println "Warning can't rename file "+tmpFile+" to "+f
 		
Index: tmp/org.txm.treetagger.core/src/org/txm/importer/xmltxm/AnnotateCQP.groovy
===================================================================
--- tmp/org.txm.treetagger.core/src/org/txm/importer/xmltxm/AnnotateCQP.groovy	(revision 0)
+++ tmp/org.txm.treetagger.core/src/org/txm/importer/xmltxm/AnnotateCQP.groovy	(revision 2987)
@@ -0,0 +1,184 @@
+// Copyright © 2010-2013 ENS de Lyon.
+// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
+// Lyon 2, University of Franche-Comté, University of Nice
+// Sophia Antipolis, University of Paris 3.
+//
+// The TXM platform is free software: you can redistribute it
+// and/or modify it under the terms of the GNU General Public
+// License as published by the Free Software Foundation,
+// either version 2 of the License, or (at your option) any
+// later version.
+//
+// The TXM platform is distributed in the hope that it will be
+// useful, but WITHOUT ANY WARRANTY; without even the implied
+// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+// PURPOSE. See the GNU General Public License for more
+// details.
+//
+// You should have received a copy of the GNU General
+// Public License along with the TXM platform. If not, see
+// http://www.gnu.org/licenses.
+//
+//
+//
+// $LastChangedDate: 2013-12-06 16:57:35 +0100 (Fri, 06 Dec 2013) $
+// $LastChangedRevision: 2583 $
+// $LastChangedBy: mdecorde $
+//
+package org.txm.importer.xmltxm
+
+import java.io.File
+import java.text.DateFormat
+import java.util.Date
+
+import org.txm.Toolbox
+import org.txm.importer.*
+import org.txm.importer.cwb.*
+import org.txm.objects.*
+import org.txm.treetagger.core.preferences.TreeTaggerPreferences
+import org.txm.utils.ConsoleProgressBar
+import org.txm.utils.DeleteDir;
+import org.txm.utils.LangDetector;
+import org.txm.utils.io.IOUtils
+import org.txm.utils.treetagger.TreeTagger
+
+// TODO: Auto-generated Javadoc
+/**
+ * Annotate and replace the TEI-TXM files of the folder $rootDirFile/txm with TreeTagger.
+ * creates $rootDirFile/interp and $rootDirFile/treetagger
+ *
+ */
+class AnnotateCQP {
+
+	/** The debug. */
+	boolean debug = true;
+
+	/**
+	 * Sets the debug.
+	 */
+	public void setDebug() { debug=true; }
+
+	String id;
+
+	/**
+	 * Apply tt.
+	 *
+	 * @param ttsrcfile the ttsrcfile
+	 * @param ttoutfile the ttoutfile
+	 * @param modelfile the modelfile
+	 * @return true, if successful
+	 */
+	public boolean applyTT(File ttsrcfile, File ttoutfile, File modelfile)
+	{
+		try {
+			File infile = ttsrcfile;
+			File outfile = ttoutfile;
+
+			// TODO: why org.txm.utils.treetagger.TreeTagger tt = ..., throw IllegalAccessError ???
+			String opt = Toolbox.getPreference(Toolbox.TREETAGGER_OPTIONS);
+			if (opt == null) opt = "";
+			String[] options = opt.split("  ");
+			def tt = new TreeTagger(Toolbox.getPreference(Toolbox.TREETAGGER_INSTALL_PATH)+"/bin/", options);
+			tt.settoken();
+			tt.setlemma();
+			tt.setquiet();
+			tt.setsgml();
+			tt.setnounknown();
+			tt.seteostag("<s>");
+			tt.treetagger(modelfile.getAbsolutePath(), infile.getAbsolutePath(), outfile.getAbsolutePath())
+			//infile.delete();
+		}
+		catch(Exception e)
+		{
+			e.printStackTrace();
+			return false;
+		}
+		return true;
+	}
+
+	/**
+	 * Run.
+	 *
+	 * @param rootDirFile the root dir file
+	 * @param modelfilename the modelfilename
+	 * @return true, if successful
+	 */
+	public boolean run(File binDir, File txmDir,  String modelfilename)
+	{
+		//test if modelfile exists
+		if(debug) {
+			println "rootDirFile "+binDir
+			println "txmDir "+txmDir
+			println "TREETAGGER INSTALL PATH : "+TreeTaggerPreferences.getInstance().getBoolean(TreeTaggerPreferences.INSTALL_PATH)
+			println "TREETAGGER MODELS PATH : "+TreeTaggerPreferences.getInstance().getBoolean(TreeTaggerPreferences.MODELS_PATH)
+		}
+
+		//test if the Toolbox know TreeTagger
+		if (!new File(Toolbox.getPreference(Toolbox.TREETAGGER_INSTALL_PATH)+"/bin/").exists())
+		{
+			println("Could not find TreeTagger binaries in "+Toolbox.getPreference(Toolbox.TREETAGGER_INSTALL_PATH)+"/bin/")
+			return false;
+		}
+
+		//cleaning
+		File annotDir = new File(binDir, "annotations")
+		annotDir.mkdir();
+
+		//BUILD TT FILE READY TO BE TAGGED
+		List<File> files = txmDir.listFiles(IOUtils.HIDDENFILE_FILTER)
+
+		// get model file and check it
+		File modelfile = new File(TreeTaggerPreferences.getInstance().getBoolean(TreeTaggerPreferences.MODELS_PATH), modelfilename);
+		if (debug)
+			println "model file : "+modelfile;
+
+		if (!modelfile.exists()) {
+			println "Skipping ANNOTATE: Incorrect modelfile path: "+modelfile;
+			if(System.getProperty("os.name").startsWith("Windows"))
+				println "Windows users: Windows might be hiding files extension. To see them, in the explorer parameters."
+			return false;
+		}
+
+		//APPLY TREETAGGER
+		println("Applying $modelfilename TreeTagger model on dir: "+txmDir+ " ("+files.size()+" files)")
+		if (files == null || files.size() == 0)
+			return false;
+
+		ConsoleProgressBar cpb = new ConsoleProgressBar(files.size());
+		for (File f : files) {
+			cpb.tick();
+			
+			File infile = f;
+			File outfile = new File(new File(binDir, "annotations"), f.getName());
+			if (outfile.exists() && // outfile exists
+				outfile.lastModified() >= infile.lastModified() && // outfile is more recent 
+				outfile.length() > infile.length()) { // outfile is bigger
+				// skip
+			} else {
+				if (!applyTT(infile, outfile, modelfile)) {
+					System.out.println("Failed to apply treetagger on file "+f);
+					return false;
+				}
+			}
+		}
+		println("")
+
+//		if (DeleteDir.deleteDirectory(txmDir)) {
+//			if (annotDir.renameTo(txmDir)) {
+//
+//			} else {
+//				println "Could not rename  'annotations' directory to 'txm' directory"
+//				return false
+//			}
+//		} else {
+//			println "Could not delete txmDir: $txmDir (and could not copy 'annotations' directory"
+//		}
+
+		return true;
+	}
+
+	public boolean run(File xmlFile, String lang, File binaryCorpusDirectory, File parentFile) {
+		System.out.println("AnnotateCQP called from the TreeTaggerEngine.processFile() is not yet implemented.")
+		return false;
+	}
+}
\ No newline at end of file
Index: tmp/org.txm.treetagger.core/src/org/txm/treetagger/core/TreeTaggerEngine.java
===================================================================
--- tmp/org.txm.treetagger.core/src/org/txm/treetagger/core/TreeTaggerEngine.java	(revision 2986)
+++ tmp/org.txm.treetagger.core/src/org/txm/treetagger/core/TreeTaggerEngine.java	(revision 2987)
@@ -8,8 +8,10 @@
 import org.txm.annotation.core.AnnotationEngine;
 import org.txm.core.results.TXMResult;
 import org.txm.importer.xmltxm.Annotate;
+import org.txm.importer.xmltxm.AnnotateCQP;
 import org.txm.objects.CorpusBuild;
 import org.txm.treetagger.core.preferences.TreeTaggerPreferences;
+import org.txm.utils.FileUtils;
 import org.txm.utils.logger.Log;
 import org.txm.utils.treetagger.TreeTagger;
 
@@ -80,7 +82,7 @@
 	public boolean processFile(File xmlFile, File binaryCorpusDirectory, HashMap<String, Object> parameters) {
 		if (!isRunning()) return false;
 		
-		Annotate annotate = new Annotate();
+		
 		Object p = parameters.get("lang");
 		if (p == null) {
 			System.out.println(NLS.bind("** Error: no 'lang' parameter given: {0}. Aborting TreeTagger annotation.", parameters));
@@ -90,7 +92,17 @@
 		if (!canAnnotateLang(lang)) {
 			return false;
 		}
-		return annotate.run(xmlFile, lang, binaryCorpusDirectory, xmlFile.getParentFile());
+		boolean fixExistingValues = false; // default behavior is to replace existing values
+		if (parameters.get("fix_existing_values") != null) {
+			fixExistingValues = "true".equals(parameters.get("fix_existing_values"));
+		}
+		if (FileUtils.isExtension(xmlFile, "cqp")) {
+			AnnotateCQP annotate = new AnnotateCQP();
+			return annotate.run(xmlFile, lang, binaryCorpusDirectory, xmlFile.getParentFile());
+		} else {
+			Annotate annotate = new Annotate();
+			return annotate.run(xmlFile, lang, fixExistingValues, binaryCorpusDirectory, xmlFile.getParentFile());
+		}
 	}
 	
 	/**
@@ -103,7 +115,6 @@
 		Object p = parameters.get("langs");
 		if (p != null && p instanceof HashMap<?, ?>) {
 			
-			
 			Annotate annotate = new Annotate();
 			HashMap<String, String> langs = (HashMap<String, String>) p;
 			return annotate.run(binaryCorpusDirectory, new File(binaryCorpusDirectory, "txm"), langs);
