Index: tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/ChartsEngine.java
===================================================================
--- tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/ChartsEngine.java	(revision 312)
+++ tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/ChartsEngine.java	(revision 313)
@@ -13,6 +13,7 @@
 import org.txm.chartsengine.core.messages.ChartsEngineCoreMessages;
 import org.txm.chartsengine.core.preferences.ChartsEnginePreferences;
 import org.txm.chartsengine.core.results.IChartResult;
+import org.txm.core.preferences.TBXPreferences;
 import org.txm.core.preferences.TXMPreferences;
 import org.txm.utils.logger.Log;
 
@@ -345,7 +346,7 @@
 	public File createTmpFile(String prefix)	{
 		File file = null;
 		try {
-			File resultsDir = new File(Toolbox.getParam(Toolbox.USER_TXM_HOME), "results"); //$NON-NLS-1$
+			File resultsDir = new File(Toolbox.getParam(TBXPreferences.USER_TXM_HOME), "results"); //$NON-NLS-1$
 			resultsDir.mkdirs();
 			
 			// right padding to 3 characters long
Index: tmp/org.txm.ca.core/src/org/txm/ca/core/statsengine/r/functions/CA.java
===================================================================
--- tmp/org.txm.ca.core/src/org/txm/ca/core/statsengine/r/functions/CA.java	(revision 312)
+++ tmp/org.txm.ca.core/src/org/txm/ca/core/statsengine/r/functions/CA.java	(revision 313)
@@ -31,12 +31,11 @@
 
 import org.rosuda.REngine.REXP;
 import org.txm.ca.core.messages.CACoreMessages;
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
+import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
 import org.txm.statsengine.core.StatException;
 import org.txm.statsengine.r.core.RWorkspace;
 import org.txm.statsengine.r.core.data.QuantitativeDataStructureImpl;
 import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
-import org.txm.utils.messages.Utf8NLS;
 
 /**
  * Access to the R implementation of the Correspondance Analysis.
@@ -96,7 +95,7 @@
 	/**
 	 * The lexical table.
 	 */
-	private LexicalTable table;
+	private ILexicalTable table;
 	
 	/**
 	 * Create a correspondance analysis on the given table. The correspondance
@@ -105,10 +104,8 @@
 	 * @param table the table
 	 * @throws StatException the stat exception
 	 */
-	public CA(LexicalTable table) throws StatException {
-
+	public CA(ILexicalTable table) throws StatException {
 		
-		
 		if (!rw.containsVariable(table.getSymbol())) {
 			throw new StatException(CACoreMessages.ERROR_0);
 		}
Index: tmp/org.txm.ca.core/src/org/txm/ca/core/statsengine/r/functions/FactoMineRCA.java
===================================================================
--- tmp/org.txm.ca.core/src/org/txm/ca/core/statsengine/r/functions/FactoMineRCA.java	(revision 312)
+++ tmp/org.txm.ca.core/src/org/txm/ca/core/statsengine/r/functions/FactoMineRCA.java	(revision 313)
@@ -33,7 +33,7 @@
 import org.rosuda.REngine.REXP;
 import org.rosuda.REngine.REXPMismatchException;
 import org.txm.ca.core.messages.CACoreMessages;
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
+import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
 import org.txm.statsengine.core.StatException;
 import org.txm.statsengine.r.core.RWorkspace;
 import org.txm.statsengine.r.core.data.QuantitativeDataStructureImpl;
@@ -95,7 +95,7 @@
 	/** The colscoords. */
 	private double[][] colscoords;
 
-	private LexicalTable table;	
+	private ILexicalTable table;	
 	
 	/**
 	 * Create a correspondence analysis on the given table. The correspondence analysis is computed as soon as the object is created.
@@ -103,7 +103,7 @@
 	 * @param table the table
 	 * @throws StatException the stat exception
 	 */
-	public FactoMineRCA(LexicalTable table) throws StatException {
+	public FactoMineRCA(ILexicalTable table) throws StatException {
 
 		if (!rw.containsVariable(table.getSymbol())) {
 			throw new StatException(CACoreMessages.ERROR_0);
Index: tmp/org.txm.ca.core/src/org/txm/ca/core/functions/CA.java
===================================================================
--- tmp/org.txm.ca.core/src/org/txm/ca/core/functions/CA.java	(revision 312)
+++ tmp/org.txm.ca.core/src/org/txm/ca/core/functions/CA.java	(revision 313)
@@ -44,8 +44,8 @@
 import org.txm.chartsengine.core.results.IChartResult;
 import org.txm.core.preferences.TXMPreferences;
 import org.txm.functions.Function;
+import org.txm.lexicaltable.core.functions.LexicalTable;
 import org.txm.lexicaltable.core.functions.LexicalTableFactory;
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.Corpus;
 import org.txm.searchengine.cqp.corpus.Partition;
@@ -123,12 +123,12 @@
 		this.corpus = lexicaltable.getCorpus();
 		this.analysisProperty = lexicaltable.getProperty();
 		this.table = lexicaltable;
-		this.fmin = table.getFmin();
+		this.fmin = table.getData().getFmin();
 
 		if (useFactoMineR)
-			ca = new FactoMineRCA(table);
+			ca = new FactoMineRCA(table.getData());
 		else
-			ca = new org.txm.ca.core.statsengine.r.functions.CA(table);
+			ca = new org.txm.ca.core.statsengine.r.functions.CA(table.getData());
 	}
 
 
@@ -844,9 +844,9 @@
 	public void stepCompute() throws StatException
 	{
 		if (useFactoMineR)
-			ca = new FactoMineRCA(table);
+			ca = new FactoMineRCA(table.getData());
 		else
-			ca = new org.txm.ca.core.statsengine.r.functions.CA(table);
+			ca = new org.txm.ca.core.statsengine.r.functions.CA(table.getData());
 		getColNames(); // in case the lexical table changes
 		getRowNames(); // in case the lexical table changes
 	}
@@ -870,7 +870,7 @@
 	public void stepSortTableLexical()
 	{
 		try {
-			table.filter(vmax, fmin);
+			table.getData().filter(vmax, fmin);
 		} catch (Exception e) {
 			// TODO Auto-generated catch block
 			org.txm.utils.logger.Log.printStackTrace(e);
Index: tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/preferences/RPreferences.java
===================================================================
--- tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/preferences/RPreferences.java	(revision 312)
+++ tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/preferences/RPreferences.java	(revision 313)
@@ -2,7 +2,6 @@
 
 
 import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.osgi.framework.FrameworkUtil;
 import org.osgi.service.prefs.Preferences;
 import org.txm.core.preferences.TXMPreferences;
 
@@ -17,7 +16,7 @@
 
 
 	// auto populate the preference node qualifier from the current bundle id
-	public static final String PREFERENCES_NODE = FrameworkUtil.getBundle(RPreferences.class).getSymbolicName();
+	public static final String PREFERENCES_NODE = RPreferences.class.getName();//FrameworkUtil.getBundle(RPreferences.class).getSymbolicName();
 	
 	//FIXME: tests
 	//public static final String PREFERENCES_NODE = "org.txm.statsengine.r.core";
@@ -60,9 +59,6 @@
 	public static final String FILE_TRANSFERT = PREFERENCES_PREFIX + "file_transfert"; //$NON-NLS-1$
 	public static final String SVG_DEVICE = PREFERENCES_PREFIX + "svg_device"; //$NON-NLS-1$
 
-
-	
-
 	/**
 	 * 
 	 */
Index: tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/data/QuantitativeDataStructureImpl.java
===================================================================
--- tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/data/QuantitativeDataStructureImpl.java	(revision 312)
+++ tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/data/QuantitativeDataStructureImpl.java	(revision 313)
@@ -42,7 +42,7 @@
  * 
  * @author Sylvain Loiseau &lt;sloiseau@ens-lsh.fr&gt;
  */
-public abstract class QuantitativeDataStructureImpl extends TXMResult implements QuantitativeDataStructure {
+public abstract class QuantitativeDataStructureImpl implements QuantitativeDataStructure {
 	
 	/** The counter. */
 	private static int counter = 1;
Index: tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/data/Factor.java
===================================================================
--- tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/data/Factor.java	(revision 312)
+++ tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/data/Factor.java	(revision 313)
@@ -37,7 +37,7 @@
  * @author sloiseau
  * 
  */
-public class Factor extends QuantitativeDataStructureImpl {
+public abstract class Factor extends QuantitativeDataStructureImpl {
 
 	/**
 	 * Create a factor.
@@ -58,28 +58,4 @@
 	public String[] getLevels() {
 		throw new UnsupportedOperationException(StatsEngineCoreMessages.Factor_0);
 	}
-
-	@Override
-	public String getName() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public String getSimpleName() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public String getDetails() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public void clean() {
-		// TODO Auto-generated method stub
-		
-	}
 }
Index: tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/data/VectorImpl.java
===================================================================
--- tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/data/VectorImpl.java	(revision 312)
+++ tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/data/VectorImpl.java	(revision 313)
@@ -360,28 +360,4 @@
 			org.txm.utils.logger.Log.printStackTrace(e);
 		}
 	}
-
-	@Override
-	public String getName() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public String getSimpleName() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public String getDetails() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public void clean() {
-		// TODO Auto-generated method stub
-		
-	}
 }
Index: tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/data/MatrixImpl.java
===================================================================
--- tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/data/MatrixImpl.java	(revision 312)
+++ tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/data/MatrixImpl.java	(revision 313)
@@ -63,7 +63,6 @@
  */
 public class MatrixImpl extends QuantitativeDataStructureImpl implements Matrix {
 
-
 	public static int[][] asIntMatrix(REXP r) throws REXPMismatchException {
 
 		int[] ct = r.asIntegers();
@@ -1044,28 +1043,4 @@
 			RWorkspace.printLastSafeEvalExpr();
 		}
 	}
-
-	@Override
-	public String getName() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public String getSimpleName() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public String getDetails() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public void clean() {
-		// TODO Auto-generated method stub
-		
-	}
 }
Index: tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/data/ContingencyTableImpl.java
===================================================================
--- tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/data/ContingencyTableImpl.java	(revision 312)
+++ tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/data/ContingencyTableImpl.java	(revision 313)
@@ -42,7 +42,7 @@
  * 
  * @author sloiseau
  */
-public class ContingencyTableImpl extends MatrixImpl implements ContingencyTable {
+public abstract class ContingencyTableImpl extends MatrixImpl implements ContingencyTable {
 
 	/**
 	 * Create a new contingency table after a {@link DoubleMatrix2D}.
Index: tmp/org.txm.lexicaltable.core/src/org/txm/functions/intertextualdistance/InterTextDistance.java
===================================================================
--- tmp/org.txm.lexicaltable.core/src/org/txm/functions/intertextualdistance/InterTextDistance.java	(revision 312)
+++ tmp/org.txm.lexicaltable.core/src/org/txm/functions/intertextualdistance/InterTextDistance.java	(revision 313)
@@ -8,7 +8,7 @@
 import org.rosuda.REngine.REXP;
 import org.rosuda.REngine.REXPMismatchException;
 import org.txm.functions.Function;
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
+import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException;
 import org.txm.statsengine.core.StatException;
@@ -16,10 +16,10 @@
 
 public class InterTextDistance extends Function {
 	
-	LexicalTable table;
+	ILexicalTable table;
 	String method = "euclidian"; //$NON-NLS-1$
 	
-	public InterTextDistance(LexicalTable table) {
+	public InterTextDistance(ILexicalTable table) {
 		this.table = table;
 	}
 	public boolean compute() throws CqiClientException, InvalidCqpIdException, REXPMismatchException, StatException {
@@ -48,7 +48,7 @@
 		return true;
 	}
 	
-	public LexicalTable getTable() {
+	public ILexicalTable getTable() {
 		return table;
 	}
 	
Index: tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/statsengine/data/LexicalTable.java
===================================================================
--- tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/statsengine/data/LexicalTable.java	(revision 312)
+++ tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/statsengine/data/LexicalTable.java	(revision 313)
@@ -1,272 +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: 2016-09-19 10:31:00 +0200 (Mon, 19 Sep 2016) $
-// $LastChangedRevision: 3298 $
-// $LastChangedBy: mdecorde $ 
-//
-package org.txm.lexicaltable.core.statsengine.data;
-
-import java.io.File;
-import java.util.List;
-
-import org.rosuda.REngine.REXPMismatchException;
-import org.txm.core.results.ITXMResult;
-import org.txm.searchengine.cqp.corpus.Corpus;
-import org.txm.searchengine.cqp.corpus.Partition;
-import org.txm.searchengine.cqp.corpus.Property;
-import org.txm.statsengine.core.StatException;
-import org.txm.statsengine.core.data.ContingencyTable;
-import org.txm.statsengine.core.data.Vector;
-import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
-
-// TODO: Auto-generated Javadoc
-/**
- * A LexicalTable is a special kind of {@link ContingencyTable} extracted from a
- * corpora given a {@link Partition} (the columns) and a {@link Property} (the
- * rows).
- * 
- * Can be edited, rows can be deleted cols can be deleted
- * 
- * can be exported of imported from/to a file
- * 
- * @author sloiseau
- */
-public interface LexicalTable extends ContingencyTable, ITXMResult {
-
-	/**
-	 * Get the partition this lexical table is bound to.
-	 * 
-	 * @return the partition
-	 */
-	public abstract Partition getPartition();
-
-	/**
-	 * Get the property this lexical table is bound to.
-	 * 
-	 * @return the property.
-	 */
-	public abstract Property getProperty();
-
-	/**
-	 * Insert a column representing the reference corpus
-	 * @param symbol
-	 */
-	public abstract void setReference(String symbol);
-	
-	/**
-	 * Gets the copy.
-	 *
-	 * @return the copy
-	 */
-	public abstract LexicalTable getCopy();
-
-	/**
-	 * Sort.
-	 *
-	 * @param colindex the colindex
-	 * @param reverse the reverse
-	 */
-	public abstract void sort(int colindex, Boolean reverse);
-
-	/**
-	 * Sort row names.
-	 *
-	 * @param reverse the reverse
-	 */
-	public void sortRowNames(Boolean reverse);
-
-	/**
-	 * Removes the col.
-	 *
-	 * @param col the col
-	 * @param checkEmptyLines the check empty lines
-	 */
-	public abstract void removeCol(int col, boolean checkEmptyLines);
-
-	/**
-	 * Removes the cols.
-	 *
-	 * @param cols the cols
-	 */
-	public abstract void removeCols(List<Integer> cols);
-
-	/**
-	 * Removes the cols.
-	 *
-	 * @param coltodelete the coltodelete
-	 */
-	public abstract void removeCols(int[] coltodelete);
-
-	/**
-	 * Removes the row.
-	 *
-	 * @param row the row
-	 */
-	public abstract void removeRow(int row);
-
-	/**
-	 * Removes the rows.
-	 *
-	 * @param row the row
-	 */
-	public abstract void removeRows(List<Integer> row);
-
-	/**
-	 * Removes the rows.
-	 *
-	 * @param selectionIndices the selection indices
-	 */
-	public abstract void removeRows(int[] selectionIndices);
-
-	/**
-	 * Sets the.
-	 *
-	 * @param row the row
-	 * @param col the col
-	 * @param value the value
-	 */
-	public abstract void set(int row, int col, double value);
-
-	/**
-	 * Gets the fmin.
-	 *
-	 * @return the fmin
-	 */
-	public abstract int getFmin();
-	
-	/**
-	 * Gets the constructor fmin.
-	 *
-	 * @return the constructor fmin
-	 */
-	public abstract int getConstructorFmin();
-
-	/**
-	 * Gets the fmax.
-	 *
-	 * @return the fmax
-	 */
-	public abstract int getFmax();
-
-	/**
-	 * Removes the rows.
-	 *
-	 * @param i the i
-	 * @param j the j
-	 */
-	public abstract void removeRows(int i, int j);
-
-	/**
-	 * Cut.
-	 * TODO: must be done after calling copy(), check why.
-	 *
-	 * @param nlines the number of lines to keep
-	 */
-	public abstract void cut(int nlines);
-
-	/**
-	 * Filter.
-	 *
-	 * @param freqs the freqs
-	 * @param nlines the nlines
-	 * @param fmin the fmin
-	 */
-	public abstract void filter(int nlines, int fmin) throws Exception;
-
-	/**
-	 * Sets the order.
-	 *
-	 * @param neworder the neworder
-	 * @param reverse the reverse
-	 */
-	abstract public void setOrder(List<Integer> neworder, Boolean reverse);
-
-	/**
-	 * Gets the freqs.
-	 *
-	 * @return the freqs
-	 */
-	public abstract List<Integer> getFreqs();
-
-	/**
-	 * Export data.
-	 *
-	 * @param file the file
-	 * @param colseparator the colseparator
-	 * @param txtseparator the txtseparator
-	 */
-	public abstract void exportData(File file, String colseparator, String txtseparator);
-	public abstract void toTxt(File outfile, String encoding, String colseparator, String txtseparator);
-	
-	/**
-	 * Import data.
-	 *
-	 * @param file the file
-	 */
-	public abstract boolean importData(File file) throws RWorkspaceException, REXPMismatchException;
-
-	/**
-	 * Gets the corpus.
-	 *
-	 * @return the corpus
-	 */
-	public abstract Corpus getCorpus();
-
-	/**
-	 * Sets the corpus.
-	 *
-	 * @param corpus the new corpus
-	 */
-	public abstract void setCorpus(Corpus corpus);
-
-	public abstract void sortByFreqs(boolean reverse) throws Exception;
-
-	@Override
-	public abstract Vector getRowMarginsVector() throws StatException;
-	
-	@Override
-	public abstract Vector getColMarginsVector() throws StatException;
-	
-	@Override
-	public abstract int[] getRowMargins() throws Exception;
-	
-	@Override
-	public abstract int[] getColMargins() throws Exception;
-	
-	
-	/**
-	 * Gets the number of rows.
-	 * @return the number of rows
-	 */
-	public abstract int getRowsCount();
-
-	
-	/**
-	 * Gets the number of columns.
-	 * @return the number of columns
-	 */
-	public abstract int getColumnsCount();
-
-
-}
Index: tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/statsengine/data/ILexicalTable.java
===================================================================
--- tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/statsengine/data/ILexicalTable.java	(revision 0)
+++ tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/statsengine/data/ILexicalTable.java	(revision 313)
@@ -0,0 +1,237 @@
+// 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: 2016-09-19 10:31:00 +0200 (Mon, 19 Sep 2016) $
+// $LastChangedRevision: 3298 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.lexicaltable.core.statsengine.data;
+
+import java.io.File;
+import java.util.List;
+
+import org.rosuda.REngine.REXPMismatchException;
+import org.txm.core.results.ITXMResult;
+import org.txm.searchengine.cqp.corpus.Corpus;
+import org.txm.searchengine.cqp.corpus.Partition;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.statsengine.core.StatException;
+import org.txm.statsengine.core.data.ContingencyTable;
+import org.txm.statsengine.core.data.Vector;
+import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
+
+// TODO: Auto-generated Javadoc
+/**
+ * A LexicalTable is a special kind of {@link ContingencyTable} extracted from a
+ * corpora given a {@link Partition} (the columns) and a {@link Property} (the
+ * rows).
+ * 
+ * Can be edited, rows can be deleted cols can be deleted
+ * 
+ * can be exported of imported from/to a file
+ * 
+ * @author sloiseau
+ */
+public interface ILexicalTable extends ContingencyTable {
+
+	/**
+	 * Insert a column representing the reference corpus
+	 * @param symbol
+	 */
+	public abstract void setReference(String symbol);
+	
+	/**
+	 * Gets the copy.
+	 *
+	 * @return the copy
+	 */
+	public abstract ILexicalTable getCopy();
+
+	/**
+	 * Sort.
+	 *
+	 * @param colindex the colindex
+	 * @param reverse the reverse
+	 */
+	public abstract void sort(int colindex, Boolean reverse);
+
+	/**
+	 * Sort row names.
+	 *
+	 * @param reverse the reverse
+	 */
+	public void sortRowNames(Boolean reverse);
+
+	/**
+	 * Removes the col.
+	 *
+	 * @param col the col
+	 * @param checkEmptyLines the check empty lines
+	 */
+	public abstract void removeCol(int col, boolean checkEmptyLines);
+
+	/**
+	 * Removes the cols.
+	 *
+	 * @param cols the cols
+	 */
+	public abstract void removeCols(List<Integer> cols);
+
+	/**
+	 * Removes the cols.
+	 *
+	 * @param coltodelete the coltodelete
+	 */
+	public abstract void removeCols(int[] coltodelete);
+
+	/**
+	 * Removes the row.
+	 *
+	 * @param row the row
+	 */
+	public abstract void removeRow(int row);
+
+	/**
+	 * Removes the rows.
+	 *
+	 * @param row the row
+	 */
+	public abstract void removeRows(List<Integer> row);
+
+	/**
+	 * Removes the rows.
+	 *
+	 * @param selectionIndices the selection indices
+	 */
+	public abstract void removeRows(int[] selectionIndices);
+
+	/**
+	 * Sets the.
+	 *
+	 * @param row the row
+	 * @param col the col
+	 * @param value the value
+	 */
+	public abstract void set(int row, int col, double value);
+
+	/**
+	 * Gets the fmin.
+	 *
+	 * @return the fmin
+	 */
+	public abstract int getFmin();
+	
+	/**
+	 * Gets the fmax.
+	 *
+	 * @return the fmax
+	 */
+	public abstract int getFmax();
+
+	/**
+	 * Removes the rows.
+	 *
+	 * @param i the i
+	 * @param j the j
+	 */
+	public abstract void removeRows(int i, int j);
+
+	/**
+	 * Cut.
+	 * TODO: must be done after calling copy(), check why.
+	 *
+	 * @param nlines the number of lines to keep
+	 */
+	public abstract void cut(int nlines);
+
+	/**
+	 * Filter.
+	 *
+	 * @param freqs the freqs
+	 * @param nlines the nlines
+	 * @param fmin the fmin
+	 */
+	public abstract void filter(int nlines, int fmin) throws Exception;
+
+	/**
+	 * Sets the order.
+	 *
+	 * @param neworder the neworder
+	 * @param reverse the reverse
+	 */
+	abstract public void setOrder(List<Integer> neworder, Boolean reverse);
+
+	/**
+	 * Gets the freqs.
+	 *
+	 * @return the freqs
+	 */
+	public abstract List<Integer> getFreqs();
+
+	/**
+	 * Export data.
+	 *
+	 * @param file the file
+	 * @param colseparator the colseparator
+	 * @param txtseparator the txtseparator
+	 */
+	public abstract void exportData(File file, String colseparator, String txtseparator);
+	public abstract void toTxt(File outfile, String encoding, String colseparator, String txtseparator);
+	
+	/**
+	 * Import data.
+	 *
+	 * @param file the file
+	 */
+	public abstract boolean importData(File file) throws RWorkspaceException, REXPMismatchException;
+
+	public abstract void sortByFreqs(boolean reverse) throws Exception;
+
+	@Override
+	public abstract Vector getRowMarginsVector() throws StatException;
+	
+	@Override
+	public abstract Vector getColMarginsVector() throws StatException;
+	
+	@Override
+	public abstract int[] getRowMargins() throws Exception;
+	
+	@Override
+	public abstract int[] getColMargins() throws Exception;
+	
+	
+	/**
+	 * Gets the number of rows.
+	 * @return the number of rows
+	 */
+	public abstract int getRowsCount();
+
+	
+	/**
+	 * Gets the number of columns.
+	 * @return the number of columns
+	 */
+	public abstract int getColumnsCount();
+
+
+}

Property changes on: tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/statsengine/data/ILexicalTable.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/statsengine/r/data/LexicalTableImpl.java
===================================================================
--- tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/statsengine/r/data/LexicalTableImpl.java	(revision 312)
+++ tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/statsengine/r/data/LexicalTableImpl.java	(revision 313)
@@ -40,11 +40,11 @@
 import java.util.Map;
 
 
+
 //import org.txm.functions.queryindex.*;
 import org.txm.index.core.functions.Index;
 import org.txm.index.core.functions.Line;
 import org.txm.lexicaltable.core.messages.LexicalTableCoreMessages;
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
 import org.txm.lexicon.core.corpusengine.cqp.Lexicon;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.Corpus;
@@ -60,13 +60,13 @@
 
 import cern.colt.matrix.DoubleFactory2D;
 import cern.colt.matrix.DoubleMatrix2D;
+import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
 
 
 
-
 // TODO: Auto-generated Javadoc
 /**
- * Implementation of the {@link LexicalTable} interface, wrapping a R matrix.
+ * Implementation of the {@link ILexicalTable} interface, wrapping a R matrix.
  * 
  * A lexical table is a contingency table representing the frequencies of
  * linguistic types accross several sub-parts of a corpus.
@@ -78,47 +78,13 @@
  * @author Sylvain Loiseau &lt;sloiseau@ens-lsh.fr&gt;
  * 
  */
-public class LexicalTableImpl extends ContingencyTableImpl implements LexicalTable {
+public class LexicalTableImpl extends ContingencyTableImpl implements ILexicalTable {
 
-	/** The partition. */
-	private Partition partition;
-
-	/** The corpus. */
-	private Corpus corpus;
-
-	/** The property. */
-	private Property property;
-
 	/** The sortedindex. */
 	private int[] sortedindex;
 
-	/** The constructor_fmin. */
-	private int constructor_fmin;
-
-
 	protected ArrayList<Integer> frequencies;
-	
-	/**
-	 * Instantiates a new lexical table impl.
-	 *
-	 * @param matrix the matrix
-	 * @param partition the partition
-	 * @param property the property
-	 * @param formNames the form names
-	 * @param partNames the part names
-	 * @throws RWorkspaceException the r workspace exception
-	 */
-	private LexicalTableImpl(DoubleMatrix2D matrix, Partition partition,
-			Property property, String[] formNames, String[] partNames)
-					throws RWorkspaceException {
-		super(matrix, formNames, partNames);
 
-		this.partition = partition;
-		this.partition.addResult(this);
-		this.property = property;
-		initSortedIndex();
-	}
-
 	/**
 	 * Instantiates a new lexical table impl.
 	 *
@@ -128,48 +94,23 @@
 	 * @param partNames the part names
 	 * @throws RWorkspaceException the r workspace exception
 	 */
-	private LexicalTableImpl(DoubleMatrix2D matrix, Property property,
-			String[] formNames, String[] partNames) throws RWorkspaceException {
+	private LexicalTableImpl(DoubleMatrix2D matrix, String[] formNames, String[] partNames) throws RWorkspaceException {
 		super(matrix, formNames, partNames);
-
-		this.property = property;
 		initSortedIndex();
-
 	}
 
 	/**
 	 * Instantiates a new lexical table impl.
 	 *
-	 * @param mat the mat
-	 * @param partition the partition
-	 * @param property the property
-	 * @param array the array
-	 * @param array2 the array2
-	 * @throws RWorkspaceException the r workspace exception
-	 */
-	public LexicalTableImpl(int[][] mat, Partition partition,
-			Property property, String[] array, String[] array2) throws RWorkspaceException {
-		this(mat,property, array, array2);
-		this.partition = partition;
-		this.partition.addResult(this);
-	}
-
-	/**
-	 * Instantiates a new lexical table impl.
-	 *
 	 * @param matrix the matrix
 	 * @param property the property
 	 * @param formNames the form names
 	 * @param partNames the part names
 	 * @throws RWorkspaceException the r workspace exception
 	 */
-	private LexicalTableImpl(int[][] matrix, Property property,
-			String[] formNames, String[] partNames) throws RWorkspaceException {
-		super(matrix, formNames, partNames);
-
-		this.property = property;
+	public LexicalTableImpl(int[][] matrix, String[] rowNames, String[] colNames) throws RWorkspaceException {
+		super(matrix, rowNames, colNames);
 		initSortedIndex();
-
 	}
 
 	/**
@@ -182,13 +123,10 @@
 	public LexicalTableImpl(LexicalTableImpl table, String symbol)
 			throws RWorkspaceException {
 		super(symbol);
-		this.partition = table.getPartition();
-		this.partition.addResult(this);
-		this.property = table.getProperty();
 		initSortedIndex();
 	}
 
-	
+
 	/**
 	 * Instantiates a new lexical table impl.
 	 *
@@ -199,8 +137,6 @@
 	public LexicalTableImpl(String symbol)
 			throws RWorkspaceException {
 		super(symbol);
-		this.partition = null;
-		this.property = null;
 	}
 
 	public LexicalTableImpl(String symbol, Lexicon corpusLexicon, Lexicon subcorpusLexicon) throws StatException {
@@ -208,12 +144,8 @@
 		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
 		Vector corpusLexiconV = corpusLexicon.asVector();
 		Vector subcorpusLexiconV = subcorpusLexicon.asVector();
-		
+
 		rw.callFunction("lexicons2LexicalTable", new QuantitativeDataStructure[] { corpusLexiconV, subcorpusLexiconV }, symbol); //$NON-NLS-1$
-		
-		this.property = corpusLexicon.getProperty();
-		this.corpus = corpusLexicon.getCorpus();
-		this.corpus.addResult(this);
 	}
 
 	/**
@@ -226,94 +158,9 @@
 			sortedindex[i] = i;
 	}
 
-	/* (non-Javadoc)
-	 * @see org.txm.stat.data.LexicalTable#getPartition()
-	 */
-	@Override
-	public Partition getPartition() {
-		return partition;
-	}
 
-	/* (non-Javadoc)
-	 * @see org.txm.stat.data.LexicalTable#getProperty()
-	 */
-	@Override
-	public Property getProperty() {
-		return property;
-	}
 
-	/**
-	 * Create a Complete Lexical Table according to a Partition and a Property.
-	 *
-	 * @param partition the partition
-	 * @param analysisProperty the analysis property
-	 * @param Fmin the fmin
-	 * @return the lexical table
-	 * @throws CqiClientException the cqi client exception
-	 * @throws RWorkspaceException the r workspace exception
-	 */
-	public static final LexicalTable getLexicalTable(Partition partition,
-			Property analysisProperty, int Fmin) throws CqiClientException,
-			RWorkspaceException {
-		//long time = System.currentTimeMillis();
-		List<Lexicon> lexicons = new ArrayList<Lexicon>();
-		// Set<String> allLexiconEntry = new HashSet<String>();
-		for (int i = 0; i < partition.getNPart(); i++) {
-			Lexicon l = partition.getParts().get(i).getLexicon(analysisProperty);
-			lexicons.add(l);
-			// allLexiconEntry.addAll(Arrays.asList(l.getForms()));
-		}
-		//System.out.println("time lexicon build "+(System.currentTimeMillis()-time));
-		//time = System.currentTimeMillis();
-		// String[] entries = allLexiconEntry.toArray(new String[]{});
-		Corpus c = partition.getCorpus();
-		Lexicon ll = c.getLexicon(analysisProperty);
 
-		ArrayList<String> filteredForms = new ArrayList<String>();
-		//create a copy and filter line with Fmin;
-		for (int i = 0 ; i < ll.getFreq().length ; i++) {
-			if (ll.getFreq()[i] >= Fmin) {
-				filteredForms.add(ll.getForms()[i]);
-			}
-		}
-		//System.out.println("remove freq too low "+(System.currentTimeMillis()-time));
-		//time = System.currentTimeMillis();
-		Map<String, Integer> entries2index = new HashMap<String, Integer>();
-		for (int i = 0; i < filteredForms.size(); i++) {
-			entries2index.put(filteredForms.get(i), i);
-		}
-
-		//System.out.println("entries2index "+(System.currentTimeMillis()-time));
-		//time = System.currentTimeMillis();
-		int[][] mat = new int[filteredForms.size()][lexicons.size()];//DoubleFactory2D.sparse.make(filteredForms.size(), lexicons.size(), 0);
-
-
-		Integer id= null;
-		for (int i = 0; i < lexicons.size(); i++) {
-			Lexicon l = lexicons.get(i);
-			String[] ents = l.getForms();
-			int[] freqs = l.getFreq();
-			for (int j = 0; j < freqs.length; j++) {
-				id = entries2index.get(ents[j]);
-				// if (entriesFreqs[id] >= 2)
-				if (id != null)
-					mat[id][i] = freqs[j]; //mat.setQuick(id, i, freqs[j]);
-			}
-		}
-		//System.out.println("time build matrix "+(System.currentTimeMillis()-time));
-		//time = System.currentTimeMillis();
-		//System.out.println("Entries size " + filteredForms.size());
-		//System.out.println("mat size " + mat.rows());
-		//System.out.println("mat columns " + mat.columns());
-
-		LexicalTableImpl table = new LexicalTableImpl(mat, partition,
-				analysisProperty, filteredForms.toArray(new String[]{}), partition.getPartShortNames()
-				.toArray(new String[] {}));
-		table.constructor_fmin = Fmin;
-		//System.out.println("time build table lexical "+(System.currentTimeMillis()-time));
-		return table;
-	}
-
 	/**
 	 * Creates the lexical table impl.
 	 *
@@ -322,13 +169,12 @@
 	 * @return the lexical table
 	 * @throws RWorkspaceException the r workspace exception
 	 */
-	static public LexicalTable createLexicalTableImpl(Index partindex,
+	static public ILexicalTable createLexicalTableImpl(Index partindex,
 			String symbol) throws RWorkspaceException {
 		List<Index> vocabularies = new ArrayList<Index>();
 		vocabularies.add(partindex);
-		
-		LexicalTable lt = createLexicalTableImpl(vocabularies, symbol, false);
-		lt.setParent(partindex);
+
+		ILexicalTable lt = createLexicalTableImpl(vocabularies, symbol, false);
 		return lt;
 	}
 
@@ -340,94 +186,93 @@
 			while(reader.readLine() != null) i++;
 			return i;
 		} catch (Exception e) { return 0; }
-
 	}
-	
-//	/**
-//	 * Creates the lexical table impl.
-//	 *
-//	 * @param partindex the partindex
-//	 * @param symbol the symbol
-//	 * @return the lexical table
-//	 * @throws RWorkspaceException the r workspace exception
-//	 */
-//	static public LexicalTable createLexicalTableImpl(QueryIndex partindex,
-//			String symbol) throws RWorkspaceException {
-//		List<QueryIndex> qindexes = new ArrayList<QueryIndex>();
-//		qindexes.add(partindex);
-//
-//		return createLexicalTableImpl(qindexes, symbol);
-//	}
-	
-//	/**
-//	 * Creates the lexical table impl.
-//	 *
-//	 * @param query indexes 
-//	 * @param symbol the symbol
-//	 * @param useAllOccurrences 
-//	 * @return the lexical table
-//	 * @throws RWorkspaceException the r workspace exception
-//	 */
-//	static public LexicalTable createLexicalTableImpl(
-//		List<QueryIndex> qindexes, String symbol)
-//					throws RWorkspaceException {
-//
-//		System.out.println(Messages.LexicalTableImpl_1 + qindexes);
-//		QueryIndex partindex = qindexes.get(0);// FRIGO
-//		if (!partindex.isComputedWithPartition())
-//			return null;
-//
-//		Partition partition = partindex.getPartition();
-//		Property property = null;
-//		try {
-//			property = partindex.getCorpus().getProperties().get(0);
-//		} catch (CqiClientException e) {
-//			// TODO Auto-generated catch block
-//			org.txm.utils.logger.Log.printStackTrace(e);
-//		}
-//
-//		HashMap<String, QueryIndexLine> alllines = new HashMap<String, QueryIndexLine>();
-//		// merge lines of all indexes
-//		for (QueryIndex voc : qindexes) {
-//			for (QueryIndexLine l : voc.getLines()) {
-//				alllines.put(l.getName(), l);
-//			}
-//		}
-//
-//		List<String> colnames = partindex.getPartnames();
-//
-//		Collection<QueryIndexLine> lines = alllines.values();
-//		List<String> rownames = new ArrayList<String>(lines.size());
-//		for (QueryIndexLine l : lines) {
-//			rownames.add(l.getName());
-//		}
-//
-//		String[] entries = new String[alllines.size()];
-//
-//		int[][] mat = new int[rownames.size()][colnames.size()];
-//		int[] margins = new int[colnames.size()]; // compute margins
-//		int i = 0;
-//		for (QueryIndexLine l : lines) {
-//			for (int j = 0; j < colnames.size(); j++) {
-//				mat[i][j] = l.getFrequency(j);
-//				margins[j] += l.getFrequency(j);
-//			}
-//			entries[i++] = l.toString();
-//		}
-//
-//		//System.out.println("mat size : ["+(rownames.size() + extra)+"]["+colnames.size()+"]");
-//		//System.out.println("rownames size : "+rownames.size());
-//		//System.out.println("colnames size : "+colnames.size());
-//		LexicalTableImpl table = new LexicalTableImpl(mat, partition, property,
-//				rownames.toArray(new String[] {}), colnames
-//				.toArray(new String[] {}));
-//		table.constructor_fmin = qindexes.get(0).getFmin();
-//		return table;
-//	}
-	
 
-	static public LexicalTable createLexicalTableImpl(File tsvFile) throws IOException, RWorkspaceException {
-		
+	//	/**
+	//	 * Creates the lexical table impl.
+	//	 *
+	//	 * @param partindex the partindex
+	//	 * @param symbol the symbol
+	//	 * @return the lexical table
+	//	 * @throws RWorkspaceException the r workspace exception
+	//	 */
+	//	static public LexicalTable createLexicalTableImpl(QueryIndex partindex,
+	//			String symbol) throws RWorkspaceException {
+	//		List<QueryIndex> qindexes = new ArrayList<QueryIndex>();
+	//		qindexes.add(partindex);
+	//
+	//		return createLexicalTableImpl(qindexes, symbol);
+	//	}
+
+	//	/**
+	//	 * Creates the lexical table impl.
+	//	 *
+	//	 * @param query indexes 
+	//	 * @param symbol the symbol
+	//	 * @param useAllOccurrences 
+	//	 * @return the lexical table
+	//	 * @throws RWorkspaceException the r workspace exception
+	//	 */
+	//	static public LexicalTable createLexicalTableImpl(
+	//		List<QueryIndex> qindexes, String symbol)
+	//					throws RWorkspaceException {
+	//
+	//		System.out.println(Messages.LexicalTableImpl_1 + qindexes);
+	//		QueryIndex partindex = qindexes.get(0);// FRIGO
+	//		if (!partindex.isComputedWithPartition())
+	//			return null;
+	//
+	//		Partition partition = partindex.getPartition();
+	//		Property property = null;
+	//		try {
+	//			property = partindex.getCorpus().getProperties().get(0);
+	//		} catch (CqiClientException e) {
+	//			// TODO Auto-generated catch block
+	//			org.txm.utils.logger.Log.printStackTrace(e);
+	//		}
+	//
+	//		HashMap<String, QueryIndexLine> alllines = new HashMap<String, QueryIndexLine>();
+	//		// merge lines of all indexes
+	//		for (QueryIndex voc : qindexes) {
+	//			for (QueryIndexLine l : voc.getLines()) {
+	//				alllines.put(l.getName(), l);
+	//			}
+	//		}
+	//
+	//		List<String> colnames = partindex.getPartnames();
+	//
+	//		Collection<QueryIndexLine> lines = alllines.values();
+	//		List<String> rownames = new ArrayList<String>(lines.size());
+	//		for (QueryIndexLine l : lines) {
+	//			rownames.add(l.getName());
+	//		}
+	//
+	//		String[] entries = new String[alllines.size()];
+	//
+	//		int[][] mat = new int[rownames.size()][colnames.size()];
+	//		int[] margins = new int[colnames.size()]; // compute margins
+	//		int i = 0;
+	//		for (QueryIndexLine l : lines) {
+	//			for (int j = 0; j < colnames.size(); j++) {
+	//				mat[i][j] = l.getFrequency(j);
+	//				margins[j] += l.getFrequency(j);
+	//			}
+	//			entries[i++] = l.toString();
+	//		}
+	//
+	//		//System.out.println("mat size : ["+(rownames.size() + extra)+"]["+colnames.size()+"]");
+	//		//System.out.println("rownames size : "+rownames.size());
+	//		//System.out.println("colnames size : "+colnames.size());
+	//		LexicalTableImpl table = new LexicalTableImpl(mat, partition, property,
+	//				rownames.toArray(new String[] {}), colnames
+	//				.toArray(new String[] {}));
+	//		table.constructor_fmin = qindexes.get(0).getFmin();
+	//		return table;
+	//	}
+
+
+	static public ILexicalTable createLexicalTableImpl(File tsvFile) throws IOException, RWorkspaceException {
+
 		BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(tsvFile) , "UTF-8")); //$NON-NLS-1$
 		String line = reader.readLine();
 		String[] split = line.split("\t"); //$NON-NLS-1$
@@ -435,11 +280,11 @@
 		if (ncol <= 1) {
 			throw new IOException(LexicalTableCoreMessages.LexicalTableImpl_5+ncol+")"); //$NON-NLS-1$
 		}
-		
+
 		int nlines = getNline(tsvFile);
 		String[] forms = new String[nlines];
 		int[][] freqs = new int[nlines][ncol-1];
-		
+
 		int i = 0;
 		while(line != null) {
 			split = line.split("\t"); //$NON-NLS-1$
@@ -453,12 +298,12 @@
 			i++;
 			line = reader.readLine();
 		}
-		
+
 		String[] colnames = new String[ncol-1];
 		for( int j = 0 ; j < ncol - 1 ; j++) colnames[j] = "forms"+(j+1); //$NON-NLS-1$
-		
-		LexicalTable lt = LexicalTableImpl.createLexicalTable(freqs, null, forms, colnames, 1);
-		
+
+		ILexicalTable lt = LexicalTableImpl.createLexicalTable(freqs, null, forms, colnames, 1);
+
 		return lt;
 	}
 
@@ -471,7 +316,7 @@
 	 * @return the lexical table
 	 * @throws RWorkspaceException the r workspace exception
 	 */
-	static public LexicalTable createLexicalTableImpl(
+	static public ILexicalTable createLexicalTableImpl(
 			List<Index> vocabularies, String symbol, boolean useAllOccurrences)
 					throws RWorkspaceException {
 
@@ -555,10 +400,8 @@
 		//System.out.println("mat size : ["+(rownames.size() + extra)+"]["+colnames.size()+"]");
 		//System.out.println("rownames size : "+rownames.size());
 		//System.out.println("colnames size : "+colnames.size());
-		LexicalTableImpl table = new LexicalTableImpl(mat, partition, property,
-				rownames.toArray(new String[] {}), colnames
+		LexicalTableImpl table = new LexicalTableImpl(mat, rownames.toArray(new String[] {}), colnames
 				.toArray(new String[] {}));
-		table.constructor_fmin = vocabularies.get(0).getFmin();
 		return table;
 	}
 
@@ -573,7 +416,7 @@
 	 * @return the lexical table
 	 * @throws RWorkspaceException the r workspace exception
 	 */
-	public static LexicalTable createLexicalTable(int[][] freqs, Property prop,
+	public static ILexicalTable createLexicalTable(int[][] freqs, Property prop,
 			String[] rownames, String[] colnames, int Fmin) throws RWorkspaceException {
 
 		ArrayList<Integer> idx = new ArrayList<Integer>();
@@ -604,25 +447,10 @@
 		for(int i = 0 ; i < idx.size() ; i++)
 			filteredrownames[i] = rownames[idx.get(i)];
 
-		LexicalTableImpl table = new LexicalTableImpl(mat, prop, filteredrownames, colnames);
-		table.constructor_fmin = Fmin;
+		LexicalTableImpl table = new LexicalTableImpl(mat, filteredrownames, colnames);
 		return table;
 	}
 
-
-	@Override
-	public LexicalTable getCopy() {
-		try {
-			if (partition != null)
-				return getLexicalTable(this.partition, this.property,this.constructor_fmin);
-			else
-				return null;
-		} catch (Exception e) {
-			org.txm.utils.logger.Log.printStackTrace(e);
-		}
-		return null;
-	}
-
 	/* (non-Javadoc)
 	 * @see org.txm.stat.data.LexicalTable#getFmax()
 	 */
@@ -703,37 +531,7 @@
 		}
 	}
 
-	/* (non-Javadoc)
-	 * @see org.txm.stat.data.LexicalTable#getConstructorFmin()
-	 */
 	@Override
-	public int getConstructorFmin() {
-		return constructor_fmin;
-	}
-
-	/* (non-Javadoc)
-	 * @see org.txm.stat.data.LexicalTable#getCorpus()
-	 */
-	@Override
-	public Corpus getCorpus() {
-		try {
-			return ((Partition)this.parent).getCorpus();
-		}
-		catch(Exception e) {
-		}
-		return (Corpus) this.parent;
-	}
-
-	/* (non-Javadoc)
-	 * @see org.txm.stat.data.LexicalTable#setCorpus(org.txm.searchengine.cqp.corpus.Corpus)
-	 */
-	@Override
-	public void setCorpus(Corpus corpus)
-	{
-		this.corpus = corpus;
-	}
-
-	@Override
 	public int getRowsCount() {
 		return this.getNRows();
 	}
@@ -743,27 +541,23 @@
 		return this.getNColumns();
 	}
 
-	
 	@Override
-	public String getName() {
-		return this.getPartition().getSimpleName() + ":" + this.getSimpleName(); //$NON-NLS-1$
-	}
+	public ILexicalTable getCopy() {
 
-	@Override
-	public String getSimpleName() {
-		return property.getName() + " (" + this.getFmin() + " / " + this.getNRows() + ")";
-	}
+		try {
+			RWorkspace rw = RWorkspace.getRWorkspaceInstance();
 
-	@Override
-	public String getDetails() {
-		// TODO Auto-generated method stub
+			String newsymbol = this.getSymbol()+"_copy";
+			while (rw.containsVariable(newsymbol)) {
+				newsymbol += "_copy";
+			}
+			ILexicalTable copy = new LexicalTableImpl(newsymbol);
+			rw.eval(newsymbol+ " <- "+this.getSymbol());
+			return copy;
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
 		return null;
 	}
-
-	@Override
-	public void clean() {
-		// TODO Auto-generated method stub
-		
-	}
-
 }
Index: tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java
===================================================================
--- tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java	(revision 0)
+++ tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java	(revision 313)
@@ -0,0 +1,143 @@
+package org.txm.lexicaltable.core.functions;
+
+import org.txm.core.results.TXMResult;
+import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
+import org.txm.lexicaltable.core.statsengine.r.data.LexicalTableImpl;
+import org.txm.lexicon.core.corpusengine.cqp.Lexicon;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.corpus.Corpus;
+import org.txm.searchengine.cqp.corpus.Partition;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.searchengine.cqp.corpus.Subcorpus;
+import org.txm.statsengine.core.StatException;
+import org.txm.statsengine.core.data.Vector;
+import org.txm.statsengine.r.core.RWorkspace;
+import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
+
+/**
+ * ILexicalTable logic + TXMResult management methods
+ * 
+ * @author mdecorde
+ *
+ */
+public class LexicalTable extends TXMResult {
+	
+	/** the statengine data object */
+	ILexicalTable data;
+	
+	/** The partition. */
+	private Partition partition;
+
+	/** The corpus. */
+	private Corpus corpus;
+
+	/** The property. */
+	private Property property;
+
+	/** The constructor_fmin. */
+	private int constructor_fmin;
+	
+	/**
+	 * Get the partition this lexical table is bound to.
+	 * 
+	 * @return the partition
+	 */
+	public Partition getPartition() {
+		return partition;
+	}
+	
+	/**
+	 * Get the corpus this lexical table is bound to.
+	 * 
+	 * @return the corpus or null if the LexicalTable was build without a Corpus or thiout a Partition (built with a Corpus)
+	 */
+	public Corpus getCorpus() {
+		if (corpus != null) return corpus;
+		else if (partition != null) return partition.getCorpus();
+		else return null;
+	}
+
+	/**
+	 * Get the property this lexical table is bound to.
+	 * 
+	 * @return the property.
+	 */
+	public Property getProperty() {
+		return property;
+	}
+
+	@Override
+	public String getName() {
+		return data.getSymbol();
+	}
+
+	@Override
+	public String getSimpleName() {
+		return data.getSymbol();
+	}
+
+	@Override
+	public String getDetails() {
+		return data.getSymbol();
+	}
+
+	@Override
+	public void clean() {
+		try {
+			RWorkspace.getRWorkspaceInstance().removeVariableFromWorkspace(data.getSymbol());
+		} catch (RWorkspaceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	
+	
+	public LexicalTable(Lexicon corpusLexicon, Lexicon subcorpusLexicon) throws StatException {
+		super();
+		
+		data = new LexicalTableImpl(corpusLexicon.getName()+ "minus" + subcorpusLexicon.getName(), corpusLexicon, subcorpusLexicon);
+		
+		this.property = corpusLexicon.getProperty();
+		this.corpus = corpusLexicon.getCorpus();
+		this.corpus.addResult(this);
+	}
+	
+	public LexicalTable(Corpus corpus, Subcorpus subcorpus) throws StatException, CqiClientException {
+		this(Lexicon.getLexicon(corpus, corpus.getProperty("word")), Lexicon.getLexicon(subcorpus, subcorpus.getProperty("word")));
+	}
+	
+	public LexicalTable(Corpus corpus, Subcorpus subcorpus, Property property) throws StatException, CqiClientException {
+		this(Lexicon.getLexicon(corpus, property), Lexicon.getLexicon(subcorpus, property));
+	}
+
+	public LexicalTable(Partition partition, Property analysisProperty, int fmin, LexicalTableImpl itable) {
+		this.property = partition.getProperty();
+		this.partition = partition;
+		this.corpus = partition.getCorpus();
+	}
+
+	public ILexicalTable getData() {
+		return data;
+	}
+
+	public Vector getRowNames() {
+		return data.getRowNames();
+	}
+	
+	public Vector getColNames() {
+		return data.getRowNames();
+	}
+
+	public int getNColumns() {
+		return data.getNColumns();
+	}
+
+	public Vector getColMarginsVector() throws StatException {
+		return data.getColMarginsVector();
+	}
+
+	public Vector getRowMarginsVector() throws StatException {
+		return data.getRowMarginsVector();
+	}
+}

Property changes on: tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTable.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTableFactory.java
===================================================================
--- tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTableFactory.java	(revision 312)
+++ tmp/org.txm.lexicaltable.core/src/org/txm/lexicaltable/core/functions/LexicalTableFactory.java	(revision 313)
@@ -1,37 +1,92 @@
 package org.txm.lexicaltable.core.functions;
 
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.txm.core.results.ITXMResult;
+import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
 import org.txm.lexicaltable.core.statsengine.r.data.LexicalTableImpl;
+import org.txm.lexicon.core.corpusengine.cqp.Lexicon;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
+import org.txm.searchengine.cqp.corpus.Corpus;
 import org.txm.searchengine.cqp.corpus.Partition;
 import org.txm.searchengine.cqp.corpus.Property;
 import org.txm.statsengine.core.StatException;
+import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
 
 public class LexicalTableFactory {
+
 	/**
-	 * Create a lexical table for this partition given an analysis property.
-	 * Lexical table are cached and recycled. In order to drop from memory a
-	 * lexical table, use {@link #dropLexicalTable(Property)}.
+	 * Create a Complete Lexical Table according to a Partition and a Property.
 	 *
+	 * @param partition the partition
 	 * @param analysisProperty the analysis property
 	 * @param Fmin the fmin
 	 * @return the lexical table
-	 * @throws StatException the stat exception
 	 * @throws CqiClientException the cqi client exception
-	 * @author sloiseau
+	 * @throws RWorkspaceException the r workspace exception
 	 */
-	public static LexicalTable getLexicalTable(Partition partition, Property analysisProperty, int Fmin)
-	throws StatException, CqiClientException {
-		// System.out.println("CL : test si déja existant ds cache");
-		/*if (lexicalTables.containsKey(analysisProperty.getName())) {
-			if (lexicalTables.get(analysisProperty.getName()).getConstructorFmin() == Fmin)
-				return lexicalTables.get(analysisProperty.getName());
-		}*/
-		// System.out.println("CL : fait un new lexique");
-		LexicalTable t = LexicalTableImpl.getLexicalTable(partition, analysisProperty, Fmin);
+	public static final LexicalTable getLexicalTable(Partition partition,
+			Property analysisProperty, int Fmin) throws CqiClientException,
+			RWorkspaceException {
+		//long time = System.currentTimeMillis();
+		List<Lexicon> lexicons = new ArrayList<Lexicon>();
+		// Set<String> allLexiconEntry = new HashSet<String>();
+		for (int i = 0; i < partition.getNPart(); i++) {
+			Lexicon l = Lexicon.getLexicon(partition.getParts().get(i), analysisProperty);
+			lexicons.add(l);
+		}
+		//System.out.println("time lexicon build "+(System.currentTimeMillis()-time));
+		//time = System.currentTimeMillis();
+		// String[] entries = allLexiconEntry.toArray(new String[]{});
+		Corpus c = partition.getCorpus();
+		Lexicon ll = Lexicon.getLexicon(c, analysisProperty);
 
-		// System.out.println("CL : put results ds le cache");
-		//partition.storeResult(t);
-		return t;
+		ArrayList<String> filteredForms = new ArrayList<String>();
+		//create a copy and filter line with Fmin;
+		for (int i = 0 ; i < ll.getFreq().length ; i++) {
+			if (ll.getFreq()[i] >= Fmin) {
+				filteredForms.add(ll.getForms()[i]);
+			}
+		}
+		//System.out.println("remove freq too low "+(System.currentTimeMillis()-time));
+		//time = System.currentTimeMillis();
+		Map<String, Integer> entries2index = new HashMap<String, Integer>();
+		for (int i = 0; i < filteredForms.size(); i++) {
+			entries2index.put(filteredForms.get(i), i);
+		}
+
+		//System.out.println("entries2index "+(System.currentTimeMillis()-time));
+		//time = System.currentTimeMillis();
+		int[][] mat = new int[filteredForms.size()][lexicons.size()];//DoubleFactory2D.sparse.make(filteredForms.size(), lexicons.size(), 0);
+
+
+		Integer id= null;
+		for (int i = 0; i < lexicons.size(); i++) {
+			Lexicon l = lexicons.get(i);
+			String[] ents = l.getForms();
+			int[] freqs = l.getFreq();
+			for (int j = 0; j < freqs.length; j++) {
+				id = entries2index.get(ents[j]);
+				// if (entriesFreqs[id] >= 2)
+				if (id != null)
+					mat[id][i] = freqs[j]; //mat.setQuick(id, i, freqs[j]);
+			}
+		}
+		//System.out.println("time build matrix "+(System.currentTimeMillis()-time));
+		//time = System.currentTimeMillis();
+		//System.out.println("Entries size " + filteredForms.size());
+		//System.out.println("mat size " + mat.rows());
+		//System.out.println("mat columns " + mat.columns());
+
+		LexicalTableImpl itable = new LexicalTableImpl(mat, filteredForms.toArray(new String[]{}), partition.getPartShortNames()
+				.toArray(new String[] {}));
+		
+		LexicalTable table = new LexicalTable(partition,
+				analysisProperty, Fmin, itable);
+		//System.out.println("time build table lexical "+(System.currentTimeMillis()-time));
+		return table;
 	}
 }
Index: tmp/org.txm.lexicaltable.core/src/org/txm/lexicon/core/messages/messages_ru.properties
===================================================================
--- tmp/org.txm.lexicaltable.core/src/org/txm/lexicon/core/messages/messages_ru.properties	(revision 0)
+++ tmp/org.txm.lexicaltable.core/src/org/txm/lexicon/core/messages/messages_ru.properties	(revision 313)
@@ -0,0 +1,6 @@
+
+DetailsFromCorpus = Словарь:\n\	Корпус {0}\n\	Запрос {1}\n\	Свойства {2}\n\	Fmin {3}\n\	Fmax {4}
+
+DetailsFromPartition = Словарь:\n\	Распределение {0}\n\	Запрос {1}\n\	Свойства {2}\n\	Fmin {3}\n\	Fmax {4}
+
+RESULT_TYPE = Словарь

Property changes on: tmp/org.txm.lexicaltable.core/src/org/txm/lexicon/core/messages/messages_ru.properties
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.lexicaltable.core/src/org/txm/lexicon/core/messages/messages_fr.properties
===================================================================
--- tmp/org.txm.lexicaltable.core/src/org/txm/lexicon/core/messages/messages_fr.properties	(revision 0)
+++ tmp/org.txm.lexicaltable.core/src/org/txm/lexicon/core/messages/messages_fr.properties	(revision 313)
@@ -0,0 +1,9 @@
+
+DetailsFromCorpus = Lexique :\n\	Corpus {0}\n\	Requête {1}\n\	Propriétés {2}\n\	Fmin {3}\n\	Fmax {4}
+
+DetailsFromPartition = Lexique :\n\	Partition {0}\n\	Requête {1}\n\	Propriétés {2}\n\	Fmin {3}\n\	Fmax {4}
+
+Lexicon_0 = Le tableau des formes et des fréquences doivent avoir la même longueur.
+Lexicon_3 = Lexique :
+
+RESULT_TYPE = Lexique

Property changes on: tmp/org.txm.lexicaltable.core/src/org/txm/lexicon/core/messages/messages_fr.properties
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.lexicaltable.core/src/org/txm/lexicon/core/messages/LexiconCoreMessages.java
===================================================================
--- tmp/org.txm.lexicaltable.core/src/org/txm/lexicon/core/messages/LexiconCoreMessages.java	(revision 0)
+++ tmp/org.txm.lexicaltable.core/src/org/txm/lexicon/core/messages/LexiconCoreMessages.java	(revision 313)
@@ -0,0 +1,32 @@
+package org.txm.lexicon.core.messages;
+
+import org.eclipse.osgi.util.NLS;
+import org.txm.utils.messages.Utf8NLS;
+
+
+/**
+ * Lexicon core messages.
+ * 
+ * @author mdecorde
+ * @author sjacquot
+ *
+ */
+public class LexiconCoreMessages extends NLS {
+
+	private static final String BUNDLE_NAME = "org.txm.lexicon.core.messages.messages"; //$NON-NLS-1$
+
+	public static String RESULT_TYPE;
+	public static String Lexicon_0;
+	public static String Lexicon_3;
+	public static String DetailsFromPartition;
+	public static String DetailsFromCorpus;
+
+	
+	static {
+		// initialize resource bundle
+		Utf8NLS.initializeMessages(BUNDLE_NAME, LexiconCoreMessages.class);
+	}
+
+	private LexiconCoreMessages() {
+	}
+}

Property changes on: tmp/org.txm.lexicaltable.core/src/org/txm/lexicon/core/messages/LexiconCoreMessages.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.lexicaltable.core/src/org/txm/lexicon/core/messages/messages.properties
===================================================================
--- tmp/org.txm.lexicaltable.core/src/org/txm/lexicon/core/messages/messages.properties	(revision 0)
+++ tmp/org.txm.lexicaltable.core/src/org/txm/lexicon/core/messages/messages.properties	(revision 313)
@@ -0,0 +1,9 @@
+
+DetailsFromCorpus = Lexicon:\n\	Corpus {0}\n\	query {1}\n\	properties {2}\n\	Fmin {3}\n\	Fmax {4}
+
+DetailsFromPartition = Lexicon:\n\	Partition {0}\n\	query {1}\n\	properties {2}\n\	Fmin {3}\n\	Fmax {4}
+
+Lexicon_0 = Forms and frequencies tables must be of the same length.
+Lexicon_3 = Lexicon : 
+
+RESULT_TYPE = Lexicon

Property changes on: tmp/org.txm.lexicaltable.core/src/org/txm/lexicon/core/messages/messages.properties
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.wordcloud.core/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.wordcloud.core/META-INF/MANIFEST.MF	(revision 312)
+++ tmp/org.txm.wordcloud.core/META-INF/MANIFEST.MF	(revision 313)
@@ -9,7 +9,8 @@
  org.txm.core;bundle-version="0.7.0",
  org.txm.chartsengine.jfreechart.core;bundle-version="1.0.0",
  org.txm.chartsengine.r.core;bundle-version="1.0.0",
- org.txm.index.core;bundle-version="1.0.0"
+ org.txm.index.core;bundle-version="1.0.0",
+ org.txm.lexicon.core
 Export-Package: org.txm.wordcloud.core.chartsengine.jfreechart,
  org.txm.wordcloud.core.chartsengine.r,
  org.txm.wordcloud.core.functions,
Index: tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java
===================================================================
--- tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java	(revision 312)
+++ tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java	(revision 313)
@@ -226,7 +226,7 @@
 			this.props = new ArrayList<Property>();
 			this.props.add(property);
 
-			lexicon = corpus.getLexicon(property);
+			lexicon = Lexicon.getLexicon(corpus, property);
 
 			lexicon.addResult(this);
 			
Index: tmp/org.txm.utils/src/org/txm/utils/io/IOUtils.java
===================================================================
--- tmp/org.txm.utils/src/org/txm/utils/io/IOUtils.java	(revision 312)
+++ tmp/org.txm.utils/src/org/txm/utils/io/IOUtils.java	(revision 313)
@@ -11,6 +11,7 @@
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
 
 import org.txm.utils.i18n.DetectBOM;
 
@@ -60,11 +61,11 @@
 	public static PrintWriter getWriter(File file, String encoding) throws UnsupportedEncodingException, FileNotFoundException {
 		return getWriter(file, encoding, false);
 	}
-	
+
 	public static PrintWriter getWriter(File file, boolean append) throws UnsupportedEncodingException, FileNotFoundException {
 		return getWriter(file, "UTF-8", append);
 	}
-	
+
 	public static PrintWriter getWriter(File file, String encoding, boolean append) throws UnsupportedEncodingException, FileNotFoundException {
 		return new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream(file, append)) , "UTF-8")); //$NON-NLS-1$
 	}
@@ -77,6 +78,21 @@
 		PrintWriter writer = getWriter(file);
 		writer.write(str);
 		writer.close();
-		
+
 	}
+
+	public static ArrayList<String> getLines(File file, String encoding) {
+		ArrayList<String> lines = new ArrayList<String>();
+		try {
+			BufferedReader reader = IOUtils.getReader(file, encoding);
+			String line = reader.readLine();
+			while (line != null) {
+				lines.add(line);
+				line = reader.readLine();
+			}
+		} catch(Exception e) {
+			System.out.println("Error while getting lines: "+e.getLocalizedMessage());
+		}
+		return lines;
+	}
 }
Index: tmp/org.txm.cooccurrence.core/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.cooccurrence.core/META-INF/MANIFEST.MF	(revision 312)
+++ tmp/org.txm.cooccurrence.core/META-INF/MANIFEST.MF	(revision 313)
@@ -3,8 +3,9 @@
 Bundle-Name: Cooccurrence Core
 Bundle-SymbolicName: org.txm.cooccurrence.core;singleton:=true
 Bundle-Version: 1.0.0.qualifier
-Require-Bundle: org.txm.lexicaltable.core,
+Require-Bundle: org.txm.concordance.core;bundle-version="1.0.0",
  org.txm.core;bundle-version="0.7.0";visibility:=reexport,
+ org.txm.lexicaltable.core,
  org.txm.specificities.core;bundle-version="1.0.0",
  org.eclipse.core.runtime,
  org.txm.index.core;bundle-version="1.0.0"
Index: tmp/org.txm.cooccurrence.core/src/org/txm/cooccurrence/core/functions/Cooccurrence.java
===================================================================
--- tmp/org.txm.cooccurrence.core/src/org/txm/cooccurrence/core/functions/Cooccurrence.java	(revision 312)
+++ tmp/org.txm.cooccurrence.core/src/org/txm/cooccurrence/core/functions/Cooccurrence.java	(revision 313)
@@ -48,7 +48,8 @@
 import org.txm.functions.concordances.Concordance;
 import org.txm.functions.concordances.Line;
 import org.txm.index.core.functions.Index;
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
+import org.txm.lexicaltable.core.functions.LexicalTable;
+import org.txm.lexicaltable.core.functions.LexicalTableFactory;
 import org.txm.lexicaltable.core.statsengine.r.data.LexicalTableImpl;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException;
@@ -60,8 +61,9 @@
 import org.txm.searchengine.cqp.corpus.query.Match;
 import org.txm.searchengine.cqp.corpus.query.Query;
 import org.txm.searchengine.cqp.serverException.CqiServerError;
-import org.txm.specificities.core.functions.Specificites;
 import org.txm.specificities.core.functions.SpecificitesResult;
+import org.txm.specificities.core.statsengine.r.function.SpecificitiesImpl;
+import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
 import org.txm.statsengine.core.StatException;
 import org.txm.statsengine.r.core.RWorkspace;
 import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
@@ -198,7 +200,7 @@
 	private HashMap<Integer, String> allsignaturesstr;
 
 	/** The lt. */
-	private LexicalTable lt;
+	private LexicalTableImpl lt;
 
 	/** The keys to string. */
 	private HashMap<String, String> keysToString;
@@ -676,8 +678,8 @@
 		}
 		if (Thread.interrupted()) return false; // stop if interrupted by user
 
-		// ALTER THE INDEX IF A REFERENCE CORPUS IS SET
-		if(referenceCorpus != null && referenceCorpus.length() > 0) {
+		// ALTER THE INDEX IF A REFERENCE CORPUS IS SET -> this change the base frequencies
+		if (referenceCorpus != null && referenceCorpus.length() > 0) {
 			//voc.toTxt(new File("/home/mdecorde/TEMP/before.tsv"), "UTF-8", "\t", "");
 			try {
 				voc.setIsAltered(true);
@@ -774,8 +776,7 @@
 		//			//writer.println("Cols: "+Arrays.toString(colnames));
 		//		} catch(Exception e) {e.printStackTrace();}
 
-		lt = LexicalTableImpl.createLexicalTable(freqs, properties.get(0), rownames, colnames, 1);
-		lt.setCorpus(corpus);
+		lt = new LexicalTableImpl(freqs, rownames, colnames);
 
 		//		if(referenceCorpus != null && referenceCorpus.length() > 0) {
 		//			//lt.removeCol(0, false);
@@ -794,13 +795,13 @@
 	 */
 	public boolean stepGetScores() throws CqiClientException, StatException
 	{
-		SpecificitesResult specif = Specificites.specificites(lt, 1000);
+		SpecificitiesImpl specif = new SpecificitiesImpl(lt);
 		//System.out.println("Specif N part: "+specif.getNbrPart()); //$NON-NLS-1$
 		//System.out.println("Specif N lines number: "+specif.getSpecificitesIndex().length); //$NON-NLS-1$
 		//System.out.println("T specif e: "+(System.currentTimeMillis()- time)); //$NON-NLS-1$
 		//specif.toTxt(new File("~/Bureau/coocresults/specif Cooc")); //$NON-NLS-1$
-		String[] specifrownames = specif.getTypeNames();
-		double[][] scores = specif.getSpecificitesIndex();
+		String[] specifrownames = specif.getRowNames().asStringsArray();
+		double[][] scores = specif.getScores();
 		//System.out.println("Nb specif result: "+specif.getSpecificitesIndex().length);
 
 		int iimax = Math.min(specifrownames.length, scores.length);
Index: tmp/org.txm.specificities.core/src/org/txm/specificities/core/statsengine/r/function/Specificites.java
===================================================================
--- tmp/org.txm.specificities.core/src/org/txm/specificities/core/statsengine/r/function/Specificites.java	(revision 312)
+++ tmp/org.txm.specificities.core/src/org/txm/specificities/core/statsengine/r/function/Specificites.java	(revision 313)
@@ -1,150 +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: 2017-01-24 18:11:42 +0100 (Tue, 24 Jan 2017) $
-// $LastChangedRevision: 3400 $
-// $LastChangedBy: mdecorde $ 
-//
-package org.txm.specificities.core.statsengine.r.function;
-
-import org.rosuda.REngine.REXP;
-import org.rosuda.REngine.REXPMismatchException;
-import org.rosuda.REngine.Rserve.RserveException;
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
-import org.txm.specificities.core.messages.SpecificitiesCoreMessages;
-import org.txm.statsengine.core.StatException;
-import org.txm.statsengine.core.data.QuantitativeDataStructure;
-import org.txm.statsengine.core.data.Vector;
-import org.txm.statsengine.r.core.RWorkspace;
-import org.txm.statsengine.r.core.data.VectorImpl;
-import org.txm.utils.logger.Log;
-
-// TODO: Auto-generated Javadoc
-/**
- * Bridge between the statistical engine and the high-level specificities
- * function {@link org.txm.functions.specificities.Specificities}.
- * 
- * This class contains only one methods; it takes as input low-level object (a
- * {@link QuantitativeDataStructure}) and return a low level object (a
- * <int>double[][]</int> array of specificities index).
- * 
- * @author sloiseau
- * 
- */
-public class Specificites {
-	
-	/** The DEFAUL t_ symbol. */
-	public static final String prefixR = "SpecifResult"; //$NON-NLS-1$
-
-	/**
-	 * Specificites.
-	 *
-	 * @param lexicon the lexicon
-	 * @param subLexicon the sub lexicon
-	 * @return the double[][]
-	 * @throws StatException the stat exception
-	 */
-	public static double[][] specificites(String symbol, Vector lexicon, Vector subLexicon)
-			throws StatException {
-		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
-		try {
-			// System.out.println("lexicon "+lexicon.getLength());
-			//System.out.println(" call specificites.lexicon.new");
-			rw.safeEval("library(textometry)");
-			REXP r = rw.callFunction(
-							"specificities.lexicon.new", new QuantitativeDataStructure[] { lexicon, subLexicon }, symbol); //$NON-NLS-1$
-			// double[] res = RWorkspace.toDouble(r);
-			//System.out.println(" build double matrix");
-			double[][] res;
-			try {
-				res = r.asDoubleMatrix();
-			} catch (REXPMismatchException e) {
-				throw new StatException(SpecificitiesCoreMessages.ComputeError_FAILED_TO_GET_SPECIFICITIES
-						+ e.getMessage(), e);
-			}
-			Log.finest(res.length + SpecificitiesCoreMessages.Specificites_2);
-			return res;
-
-		} catch (Exception e) {
-			System.out.println(e.getLocalizedMessage());
-			org.txm.utils.logger.Log.printStackTrace(e);
-		}
-		return null;
-	}
-
-	/**
-	 * Specificites.
-	 *
-	 * @param table the table
-	 * @param typeFocus the type focus
-	 * @param partFocus the part focus
-	 * @return the double[][]
-	 * @throws StatException the stat exception
-	 */
-	public static double[][] specificites(String symbol, LexicalTable table,
-			String[] typeFocus, String[] partFocus) throws StatException {
-
-		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
-
-		VectorImpl row = null;
-		if (typeFocus != null && typeFocus.length != 0)
-			row = new VectorImpl(typeFocus);
-
-		VectorImpl column = null;
-		if (partFocus != null && partFocus.length != 0)
-			column = new VectorImpl(partFocus);
-		
-		try {
-			rw.safeEval("library(textometry)");
-		} catch (RserveException e1) {
-			// TODO Auto-generated catch block
-			e1.printStackTrace();
-		} catch (REXPMismatchException e1) {
-			// TODO Auto-generated catch block
-			e1.printStackTrace();
-		}
-		REXP r = rw.callFunction("specificities", new QuantitativeDataStructure[] { table, row, column }, symbol); //$NON-NLS-1$
-			
-		double[][] res;
-		try {
-			res = r.asDoubleMatrix();
-		} catch (REXPMismatchException e) {
-			throw new StatException(SpecificitiesCoreMessages.ComputeError_FAILED_TO_GET_SPECIFICITIES + e.getMessage(), e);
-		}
-		Log.finest((res.length * res[0].length) + SpecificitiesCoreMessages.Specificites_2);
-		
-		return res;
-	}
-	
-	/**
-	 * Gets the default symbol.
-	 *
-	 * @param symbol the symbol
-	 * @return the default symbol
-	 */
-	public static double[][] getDefaultSymbol(String symbol)
-	{
-		return null;
-	}
-
-}
Index: tmp/org.txm.specificities.core/src/org/txm/specificities/core/statsengine/r/function/SpecificitiesImpl.java
===================================================================
--- tmp/org.txm.specificities.core/src/org/txm/specificities/core/statsengine/r/function/SpecificitiesImpl.java	(revision 0)
+++ tmp/org.txm.specificities.core/src/org/txm/specificities/core/statsengine/r/function/SpecificitiesImpl.java	(revision 313)
@@ -0,0 +1,157 @@
+// 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: 2017-01-24 18:11:42 +0100 (Tue, 24 Jan 2017) $
+// $LastChangedRevision: 3400 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.specificities.core.statsengine.r.function;
+
+import org.rosuda.REngine.REXP;
+import org.rosuda.REngine.REXPMismatchException;
+import org.rosuda.REngine.Rserve.RserveException;
+import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
+import org.txm.lexicaltable.core.statsengine.r.data.LexicalTableImpl;
+import org.txm.specificities.core.messages.SpecificitiesCoreMessages;
+import org.txm.specificities.core.statsengine.data.ISpecificities;
+import org.txm.statsengine.core.StatException;
+import org.txm.statsengine.core.data.QuantitativeDataStructure;
+import org.txm.statsengine.core.data.Vector;
+import org.txm.statsengine.r.core.RWorkspace;
+import org.txm.statsengine.r.core.data.MatrixImpl;
+import org.txm.statsengine.r.core.data.VectorImpl;
+import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
+import org.txm.utils.logger.Log;
+
+// TODO: Auto-generated Javadoc
+/**
+ * Bridge between the statistical engine and the high-level specificities
+ * function {@link org.txm.functions.specificities.Specificities}.
+ * 
+ * This class contains only one methods; it takes as input low-level object (a
+ * {@link QuantitativeDataStructure}) and return a low level object (a
+ * <int>double[][]</int> array of specificities index).
+ * 
+ * @author sloiseau
+ * 
+ */
+public class SpecificitiesImpl extends MatrixImpl implements ISpecificities {
+
+	protected static int specif_counter = 1;
+	/** The DEFAULT symbol. */
+	public static final String prefixR = "SpecifResult"; //$NON-NLS-1$
+
+	protected double[][] specIndex;
+
+	/**
+	 * With an already computed specificities score matrix
+	 * @param symbol
+	 * @throws RWorkspaceException
+	 */
+	public SpecificitiesImpl(String symbol) throws RWorkspaceException {
+		super(symbol);
+	}
+
+	public SpecificitiesImpl(ILexicalTable lt) throws StatException {
+		super(prefixR+(specif_counter++));
+
+
+		// Create a set of the existing types
+		String[] rownames = lt.getRowNames().asStringsArray();
+		String[] colnames = lt.getColNames().asStringsArray();
+
+		//System.out.println("Av specif ");
+		specIndex = compute(symbol, lt, rownames, colnames);
+	}
+
+	/**
+	 * compute Specificites of subcorpus using the textometry package functions.
+	 *
+	 * @param lexicon the lexicon
+	 * @param subLexicon the sub lexicon
+	 * @return the double[][]
+	 * @throws StatException the stat exception
+	 * @throws REXPMismatchException 
+	 * @throws RserveException 
+	 */
+	public SpecificitiesImpl(Vector lexicon, Vector subLexicon)
+			throws StatException, RserveException, REXPMismatchException {
+		super(prefixR+(specif_counter++));
+
+		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
+		rw.safeEval("library(textometry)");
+		REXP r = rw.callFunction(
+				"specificities.lexicon.new", new QuantitativeDataStructure[] { lexicon, subLexicon }, symbol); //$NON-NLS-1$
+		// double[] res = RWorkspace.toDouble(r);
+		//System.out.println(" build double matrix");
+		specIndex = r.asDoubleMatrix();
+	}
+
+	/**
+	 * compute Specificites of lexical table using the textometry package functions.
+	 *
+	 * @param table the table
+	 * @param typeFocus the type focus
+	 * @param partFocus the part focus
+	 * @return the double[][]
+	 * @throws StatException the stat exception
+	 */
+	protected static double[][] compute(String symbol, ILexicalTable table,
+			String[] typeFocus, String[] partFocus) throws StatException {
+
+		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
+
+		VectorImpl row = null;
+		if (typeFocus != null && typeFocus.length != 0)
+			row = new VectorImpl(typeFocus);
+
+		VectorImpl column = null;
+		if (partFocus != null && partFocus.length != 0)
+			column = new VectorImpl(partFocus);
+
+		try {
+			rw.safeEval("library(textometry)");
+		} catch (RserveException e1) {
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		} catch (REXPMismatchException e1) {
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		}
+		REXP r = rw.callFunction("specificities", new QuantitativeDataStructure[] { table, row, column }, symbol); //$NON-NLS-1$
+
+		double[][] res;
+		try {
+			res = r.asDoubleMatrix();
+		} catch (REXPMismatchException e) {
+			throw new StatException(SpecificitiesCoreMessages.ComputeError_FAILED_TO_GET_SPECIFICITIES + e.getMessage(), e);
+		}
+		Log.finest((res.length * res[0].length) + SpecificitiesCoreMessages.Specificites_2);
+
+		return res;
+	}
+
+	public double[][] getScores() {
+		return specIndex;
+	}
+}

Property changes on: tmp/org.txm.specificities.core/src/org/txm/specificities/core/statsengine/r/function/SpecificitiesImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.specificities.core/src/org/txm/specificities/core/statsengine/data/ISpecificities.java
===================================================================
--- tmp/org.txm.specificities.core/src/org/txm/specificities/core/statsengine/data/ISpecificities.java	(revision 0)
+++ tmp/org.txm.specificities.core/src/org/txm/specificities/core/statsengine/data/ISpecificities.java	(revision 313)
@@ -0,0 +1,49 @@
+// 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: 2016-09-19 10:31:00 +0200 (Mon, 19 Sep 2016) $
+// $LastChangedRevision: 3298 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.specificities.core.statsengine.data;
+
+import org.txm.searchengine.cqp.corpus.Partition;
+import org.txm.searchengine.cqp.corpus.Property;
+import org.txm.statsengine.core.data.ContingencyTable;
+import org.txm.statsengine.core.data.Matrix;
+
+// TODO: Auto-generated Javadoc
+/**
+ * A LexicalTable is a special kind of {@link ContingencyTable} extracted from a
+ * corpora given a {@link Partition} (the columns) and a {@link Property} (the
+ * rows).
+ * 
+ * Can be edited, rows can be deleted cols can be deleted
+ * 
+ * can be exported of imported from/to a file
+ * 
+ * @author sloiseau
+ */
+public interface ISpecificities extends Matrix {
+
+}

Property changes on: tmp/org.txm.specificities.core/src/org/txm/specificities/core/statsengine/data/ISpecificities.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificites.java
===================================================================
--- tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificites.java	(revision 312)
+++ tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificites.java	(revision 313)
@@ -1,217 +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: 2016-11-29 16:47:07 +0100 (Tue, 29 Nov 2016) $
-// $LastChangedRevision: 3349 $
-// $LastChangedBy: mdecorde $ 
-//
-package org.txm.specificities.core.functions;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.txm.lexicaltable.core.functions.LexicalTableFactory;
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
-import org.txm.lexicon.core.corpusengine.cqp.Lexicon;
-import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
-import org.txm.searchengine.cqp.corpus.Corpus;
-import org.txm.searchengine.cqp.corpus.Part;
-import org.txm.searchengine.cqp.corpus.Partition;
-import org.txm.searchengine.cqp.corpus.Property;
-import org.txm.searchengine.cqp.corpus.Subcorpus;
-import org.txm.searchengine.cqp.corpus.query.Focus;
-import org.txm.specificities.core.messages.SpecificitiesCoreMessages;
-import org.txm.statsengine.core.StatException;
-import org.txm.statsengine.core.data.Vector;
-import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
-
-// TODO: Auto-generated Javadoc
-/**
- * High level access to the Specificities.
- * 
- * The methods in this class access the Specificities function through
- * high-level objects (representation of CQP corpus ({@link Corpus},
- * {@link Subcorpus}, {@link Partition}), representation of queries (
- * {@link Focus}, {@link Property}), and lexicon {@link Lexicon})).
- * 
- * @author sloiseau
- * 
- */
-public class Specificites {
-
-	/** The specif_counter. */
-	private static int specif_counter = 1;
-	private static ArrayList<Integer> selectedColIdx;
-
-	/**
-	 * Compute the specificity index for all the cells of a complete lexical
-	 * table, as defined by a {@link Partition} and a {@link Property}.
-	 * 
-	 * This may be used for extracting, for all part, the forms the most or the
-	 * less specif ic.
-	 *
-	 * @param partition the partition
-	 * @param analysisProperty the analysis property
-	 * @param formFocus the form focus
-	 * @param partsFocus the parts focus
-	 * @param Fmin the fmin
-	 * @return the specificites result
-	 * @throws CqiClientException the cqi client exception
-	 * @throws StatException the stat exception
-	 */
-	public static SpecificitesResult specificites(Partition partition, Property analysisProperty,
-			List<Part> partsFocus, int Fmin, int maxScore) throws CqiClientException, StatException {
-		if (partition.getParts().size() < 2) {
-			throw new IllegalArgumentException(SpecificitiesCoreMessages.ComputeError_NEED_AT_LEAST_2_PARTS);
-		}
-		// complication due to Jean-Philippe special interest in usage of Part.
-		List<String> partNamesFocus = new ArrayList<String>();
-		
-		if (partsFocus != null) {
-			partNamesFocus = new ArrayList<String>();
-			for (Part p : partsFocus) {
-				partNamesFocus.add(p.getShortName());
-			}
-		}
-		// System.out.println("get/create lexical table");
-		LexicalTable table = LexicalTableFactory.getLexicalTable(partition, analysisProperty, Fmin);
-		partition.addResult(table);
-
-		// Create a set of the existing types
-		String[] rownames = table.getRowNames().asStringsArray();
-		ArrayList<String> found = new ArrayList<String>(Arrays.asList(rownames));
-
-		String symbol = org.txm.specificities.core.statsengine.r.function.Specificites.prefixR+(specif_counter++);
-		
-		//System.out.println("Av specif ");
-		double[][] specIndex = org.txm.specificities.core.statsengine.r.function.Specificites
-		.specificites(symbol, table, found.toArray(new String[] {}), partNamesFocus.toArray(new String[] {}));
-		//System.out.println("Ap specif ");
-		
-		return new SpecificitesResult(
-				symbol,
-				specIndex,
-				table,
-				found,
-				partNamesFocus,
-				analysisProperty.getName(),
-				maxScore);
-	}
-
-	/**
-	 * Specificites.
-	 *
-	 * @param table the table
-	 * @return the specificites result
-	 * @throws CqiClientException the cqi client exception
-	 * @throws StatException the stat exception
-	 */
-	public static SpecificitesResult specificites(LexicalTable table, int maxScore)
-	throws CqiClientException, StatException {
-		if (table.getNColumns() < 2) {
-			throw new IllegalArgumentException(SpecificitiesCoreMessages.ComputeError_NEED_AT_LEAST_2_PARTS);
-		}
-
-		String[] rownames = table.getRowNames().asStringsArray();
-		String[] colnames = table.getColNames().asStringsArray();
-		String symbol = org.txm.specificities.core.statsengine.r.function.Specificites.prefixR+(specif_counter++);
-
-		double[][] specIndex = org.txm.specificities.core.statsengine.r.function.Specificites.specificites(symbol, table, rownames, colnames);
-
-		if (table.getPartition() != null) {
-			return new SpecificitesResult(symbol, specIndex, table, Arrays
-					.asList(rownames), Arrays.asList(colnames), table.getProperty().getName(), maxScore); 
-		} else {
-			return new SpecificitesResult(symbol, specIndex, table, Arrays
-					.asList(rownames), Arrays.asList(colnames),
-					"TLNONAME: " + table.getProperty().getName(), maxScore); //$NON-NLS-1$
-		}
-	}
-
-	/**
-	 * Specificites.
-	 *
-	 * @param corpus the corpus
-	 * @param subcorpus the subcorpus
-	 * @param property the property
-	 * @return the specificites result
-	 * @throws CqiClientException the cqi client exception
-	 * @throws StatException the stat exception
-	 */
-	public static SpecificitesResult specificites(Corpus corpus,
-			Subcorpus subcorpus, Property property, int maxScore) throws CqiClientException,
-			StatException {
-
-		Lexicon totalFrequencies = corpus.getLexicon(property);
-		Lexicon subFrequencies = subcorpus.getLexicon(property);
-
-		//System.out.println("Send corpus vector");
-		Vector totalFSymbol;
-		Vector subFSymbol;
-		try {
-			totalFSymbol = totalFrequencies.asVector();
-			subFSymbol = subFrequencies.asVector();
-		} catch (StatException e) {
-			throw new RWorkspaceException(e);
-		}
-
-		//System.out.println("compute specifs");
-		String symbol = org.txm.specificities.core.statsengine.r.function.Specificites.prefixR+(specif_counter++);
-		double[][] specIndex = org.txm.specificities.core.statsengine.r.function.Specificites.specificites(symbol, totalFSymbol, subFSymbol);
-
-		//System.out.println("build SpecificitesResult");
-		SpecificitesResult specif =  new SpecificitesResult(symbol, specIndex, totalFrequencies,
-				subFrequencies, property.getName(), maxScore); 
-
-		specif.setCorpus(subcorpus);
-		return specif ;
-	}
-
-	/**
-	 * TODO to be replaced by
-	 * "org.apache.commons.collections.CollectionUtils.subtract" when someone
-	 * figure out where is the eclipse plugin for apache commons collections. SL
-	 *
-	 * @param leftoperande the leftoperande
-	 * @param rightoperande the rightoperande
-	 * @return an array of two sets: the first one contains the element of
-	 * leftoperande not in rightoperande, the second the element of
-	 * leftoperande present in rightoperande.
-	 */
-	private static final Set<String>[] subtract(Set<String> leftoperande,
-			Set<String> rightoperande) {
-		Set<String>[] returned = new HashSet[] { new HashSet<String>(),
-				new HashSet<String>() };
-		for (String s : leftoperande) {
-			if (!rightoperande.contains(s)) {
-				returned[0].add(s);
-			} else {
-				returned[1].add(s);
-			}
-		}
-		return returned;
-	}
-}
Index: tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Chi2.java
===================================================================
--- tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Chi2.java	(revision 312)
+++ tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Chi2.java	(revision 313)
@@ -1,7 +1,8 @@
 package org.txm.specificities.core.functions;
 
 import org.txm.functions.contrasts.Contrast;
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
+import org.txm.lexicaltable.core.functions.LexicalTable;
+import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.Corpus;
 import org.txm.searchengine.cqp.corpus.Partition;
@@ -11,32 +12,33 @@
 import org.txm.statsengine.r.core.RWorkspace;
 
 public class Chi2 extends Contrast {
+	
+	private ILexicalTable itable;
+	
 	public Chi2(Corpus corpus, Subcorpus subcorpus, Property property)
 			throws StatException, CqiClientException {
 		super(corpus, subcorpus, property);
-		// TODO Auto-generated constructor stub
 	}
 
 	public Chi2(Partition partition, Property property, int Fmin)
 			throws StatException, CqiClientException {
 		super(partition, property, Fmin);
-		// TODO Auto-generated constructor stub
 	}
 
 
 	public Chi2(LexicalTable table) {
 		super(table);
-		// TODO Auto-generated constructor stub
 	}
 
 	@Override
 	public boolean compute() throws StatException {
-		colNames = table.getColNames().asStringsArray();
-		rowNames = table.getRowNames().asStringsArray();
-		frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(table.getSymbol());
+		itable = table.getData();
+		colNames = itable.getColNames().asStringsArray();
+		rowNames = itable.getRowNames().asStringsArray();
+		frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(itable.getSymbol());
 		
 		// compute
-		String cmd = "mat <- "+table.getSymbol()+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$
+		String cmd = "mat <- "+itable.getSymbol()+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$
 					" mat2 <- rowSums(mat) %o% colSums(mat) / sum(mat)"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$
 					symbol +" <- (mat - mat2) ^ 2 / mat2"; //$NON-NLS-1$
 		indices = RWorkspace.getRWorkspaceInstance().evalToDouble2D(cmd);
Index: tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/SpecificitesResult.java
===================================================================
--- tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/SpecificitesResult.java	(revision 312)
+++ tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/SpecificitesResult.java	(revision 313)
@@ -34,22 +34,33 @@
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
+import org.rosuda.REngine.REXPMismatchException;
+import org.rosuda.REngine.Rserve.RserveException;
 import org.txm.functions.Function;
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
+import org.txm.lexicaltable.core.functions.LexicalTable;
+import org.txm.lexicaltable.core.functions.LexicalTableFactory;
 import org.txm.lexicon.core.corpusengine.cqp.Lexicon;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.Corpus;
+import org.txm.searchengine.cqp.corpus.Part;
 import org.txm.searchengine.cqp.corpus.Partition;
+import org.txm.searchengine.cqp.corpus.Property;
 import org.txm.searchengine.cqp.corpus.Subcorpus;
 import org.txm.specificities.core.messages.SpecificitiesCoreMessages;
+import org.txm.specificities.core.statsengine.r.function.SpecificitiesImpl;
 import org.txm.statsengine.core.StatException;
 import org.txm.statsengine.core.data.Vector;
 import org.txm.statsengine.core.utils.ArrayIndex;
 import org.txm.statsengine.core.utils.CheckArray;
 import org.txm.statsengine.r.core.RWorkspace;
+import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
 
-// TODO: Auto-generated Javadoc
 /**
  * Hold specificites computation result.
  * 
@@ -61,10 +72,10 @@
 	public static int MAXSPECIF = 1000;
 
 	/** The indices. */
-	private final double[][] indices;
+	private double[][] indices;
 
 	/** The table. */
-	private final LexicalTable table;
+	private LexicalTable table;
 
 	/** The rowindex. */
 	private int[] rowindex = null;
@@ -131,10 +142,10 @@
 	 * @param subLexicon the sub lexicon
 	 * @param name the name
 	 */
-	protected SpecificitesResult(String symbol, double[][] specIndex, Lexicon lexicon, Lexicon subLexicon, String name, int maxScore) {
+	protected void init(String symbol, double[][] specIndex, Lexicon lexicon, Lexicon subLexicon, String name, int maxScore) {
 		
-		super(subLexicon.getCorpus());
-		
+		//super(subLexicon.getCorpus());
+		this.corpus = subLexicon.getCorpus();
 		this.symbol = symbol;
 		this.indices = specIndex;
 
@@ -180,12 +191,11 @@
 	 * @param maxScore if abs(score) > maxScore -> score = +/- maxScore
 	 * @throws StatException the stat exception
 	 */
-	protected SpecificitesResult(String symbol, double[][] specIndex, LexicalTable table,
+	protected void init(String symbol, double[][] specIndex, LexicalTable table,
 			List<String> typeFocus, List<String> partFocus, String name, int maxScore)
 					throws StatException {
 		
-		super(table);
-		
+		this.table = table;
 		this.symbol = symbol;
 
 		if (table == null) {
@@ -297,7 +307,7 @@
 	 * @throws StatException the stat exception
 	 */
 	public int getCorpusSize() throws StatException {
-		return table != null ? table.getTotal() : lexicon.nbrOfToken();
+		return table != null ? table.getData().getTotal() : lexicon.nbrOfToken();
 	}
 
 	/**
@@ -368,7 +378,7 @@
 			//System.out.println("no frequencies");
 			if (table != null) {
 				//System.out.println("FROM TABLE");
-				frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(table.getSymbol());
+				frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(table.getData().getSymbol());
 				
 			} else {// if table == null : subcorpus specif 
 				//System.out.println("FROM LEXICON");
@@ -653,4 +663,94 @@
 	public String getDetails() {
 		return this.getName();
 	}
+	
+	
+	/**
+	 * Compute the specificity index for all the cells of a complete lexical
+	 * table, as defined by a {@link Partition} and a {@link Property}.
+	 * 
+	 * This may be used for extracting, for all part, the forms the most or the
+	 * less specif ic.
+	 *
+	 * @param partition the partition
+	 * @param analysisProperty the analysis property
+	 * @param formFocus the form focus
+	 * @param partsFocus the parts focus
+	 * @param Fmin the fmin
+	 * @return the specificites result
+	 * @throws CqiClientException the cqi client exception
+	 * @throws StatException the stat exception
+	 */
+	public SpecificitesResult(Partition partition, Property analysisProperty, int Fmin, int maxScore) throws CqiClientException, StatException {
+		this(LexicalTableFactory.getLexicalTable(partition, analysisProperty, Fmin), maxScore);
+
+		if (partition.getParts().size() < 2) {
+			throw new IllegalArgumentException(SpecificitiesCoreMessages.ComputeError_NEED_AT_LEAST_2_PARTS);
+		}
+	}
+
+	/**
+	 * Specificites.
+	 *
+	 * @param table the table
+	 * @return the specificites result
+	 * @throws CqiClientException the cqi client exception
+	 * @throws StatException the stat exception
+	 */
+	public SpecificitesResult(LexicalTable table, int maxScore)
+	throws CqiClientException, StatException {
+		if (table.getNColumns() < 2) {
+			throw new IllegalArgumentException(SpecificitiesCoreMessages.ComputeError_NEED_AT_LEAST_2_PARTS);
+		}
+
+		SpecificitiesImpl si = new SpecificitiesImpl(table.getData());
+
+		double[][] specIndex = si.getScores();
+
+		if (table.getPartition() != null) {
+			init(symbol, specIndex, table, Arrays
+					.asList(table.getRowNames().asStringsArray()), Arrays.asList(table.getColNames().asStringsArray()), table.getProperty().getName(), maxScore); 
+		} else {
+			init(si.getSymbol(), specIndex, table, Arrays
+					.asList(table.getRowNames().asStringsArray()), Arrays.asList(table.getColNames().asStringsArray()),
+					"TLNONAME: " + table.getProperty().getName(), maxScore); //$NON-NLS-1$
+		}
+	}
+
+	/**
+	 * Specificites.
+	 *
+	 * @param corpus the corpus
+	 * @param subcorpus the subcorpus
+	 * @param property the property
+	 * @return the specificites result
+	 * @throws CqiClientException the cqi client exception
+	 * @throws StatException the stat exception
+	 * @throws REXPMismatchException 
+	 * @throws RserveException 
+	 */
+	public SpecificitesResult(Corpus corpus,
+			Subcorpus subcorpus, Property property, int maxScore) throws CqiClientException,
+			StatException, RserveException, REXPMismatchException {
+
+		
+		
+		Lexicon totalFrequencies = Lexicon.getLexicon(corpus, property);
+		Lexicon subFrequencies = Lexicon.getLexicon(subcorpus, property);
+
+		//System.out.println("Send corpus vector");
+		Vector totalFSymbol;
+		Vector subFSymbol;
+		try {
+			totalFSymbol = totalFrequencies.asVector();
+			subFSymbol = subFrequencies.asVector();
+		} catch (StatException e) {
+			throw new RWorkspaceException(e);
+		}
+
+		SpecificitiesImpl si = new SpecificitiesImpl(totalFSymbol, subFSymbol);
+		double[][] specIndex = si.getScores();
+
+		init(si.getSymbol(), specIndex, totalFrequencies, subFrequencies, corpus.getName()+"\\"+subcorpus.getName(), maxScore);
+	}
 }
Index: tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificites2.java
===================================================================
--- tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificites2.java	(revision 312)
+++ tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificites2.java	(revision 313)
@@ -1,50 +1,49 @@
 package org.txm.specificities.core.functions;
 
 import org.txm.functions.contrasts.Contrast;
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
+import org.txm.lexicaltable.core.functions.LexicalTable;
+import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.Corpus;
 import org.txm.searchengine.cqp.corpus.Partition;
 import org.txm.searchengine.cqp.corpus.Property;
 import org.txm.searchengine.cqp.corpus.Subcorpus;
+import org.txm.specificities.core.statsengine.r.function.SpecificitiesImpl;
 import org.txm.statsengine.core.StatException;
 import org.txm.statsengine.r.core.RWorkspace;
 
 public class Specificites2 extends Contrast {
-	
+
+	private ILexicalTable itable;
+
 	public Specificites2(Corpus corpus, Subcorpus subcorpus, Property property)
 			throws StatException, CqiClientException {
 		super(corpus, subcorpus, property);
-		// TODO Auto-generated constructor stub
 	}
 
 	public Specificites2(Partition partition, Property property, int Fmin)
 			throws StatException, CqiClientException {
 		super(partition, property, Fmin);
-		// TODO Auto-generated constructor stub
 	}
 
 
 	public Specificites2(LexicalTable table) {
 		super(table);
-		// TODO Auto-generated constructor stub
 	}
 
 	public boolean compute() throws StatException {
-	
-	colNames = table.getColNames().asStringsArray();
-	rowNames = table.getRowNames().asStringsArray();
-	frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(table.getSymbol());
-	
-	// compute
-	indices = org.txm.specificities.core.statsengine.r.function.Specificites.specificites("SYMBOL", table, null, null); //$NON-NLS-1$
-	
-	return true;
-}
+		itable = table.getData();
+		colNames = itable.getColNames().asStringsArray();
+		rowNames = itable.getRowNames().asStringsArray();
+		frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(itable.getSymbol());
 
+		// compute
+		indices = new SpecificitiesImpl(itable).getScores(); //$NON-NLS-1$
+		return true;
+	}
+
 	@Override
 	public String getName() {
-		// TODO Auto-generated method stub
 		return "Specif2"; //$NON-NLS-1$
 	}
 
@@ -63,6 +62,6 @@
 	@Override
 	public void clean() {
 		// TODO Auto-generated method stub
-		
+
 	}
 }
Index: tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/Contrast.java
===================================================================
--- tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/Contrast.java	(revision 312)
+++ tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/Contrast.java	(revision 313)
@@ -9,8 +9,9 @@
 
 import org.txm.chartsengine.r.core.themes.DefaultTheme;
 import org.txm.core.results.TXMResult;
+import org.txm.lexicaltable.core.functions.LexicalTable;
 import org.txm.lexicaltable.core.functions.LexicalTableFactory;
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
+import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
 import org.txm.lexicaltable.core.statsengine.r.data.LexicalTableImpl;
 import org.txm.lexicon.core.corpusengine.cqp.Lexicon;
 //import org.txm.progression.core.functions.Progression;
@@ -28,7 +29,9 @@
 
 public abstract class Contrast extends TXMResult {
 
-	protected String symbol;
+	protected static int no_contrast = 1;
+	
+	protected String symbol; // the R table that stores the freqs + indices
 	protected LexicalTable table;
 
 	protected double[][] indices;
@@ -40,24 +43,17 @@
 			throw new IllegalArgumentException(SpecificitiesCoreMessages.ComputeError_NEED_AT_LEAST_2_PARTS);
 		}
 		table = LexicalTableFactory.getLexicalTable(partition, property, Fmin);
-		
+		symbol = "Contrast_"+this.getClass().getSimpleName()+"_"+(no_contrast++);
 	}
 
 	public Contrast(LexicalTable table) {
 		this.table = table;
+		symbol = "Contrast_"+this.getClass().getSimpleName()+"_"+(no_contrast++);
 	}
 
 	public Contrast(Corpus corpus, Subcorpus subcorpus, Property property) throws StatException, CqiClientException {
-		Lexicon totalFrequencies = corpus.getLexicon(property);
-		Lexicon subFrequencies = subcorpus.getLexicon(property);
-
-		Vector totalFSymbol = totalFrequencies.asVector();
-		Vector subFSymbol = subFrequencies.asVector();
-
-		String symbol = RWorkspace.getRandomSymbol();
-		RWorkspace.getRWorkspaceInstance().eval(symbol + " <-  lexiconsToLexicalTable("+totalFSymbol.getSymbol()+", "+subFSymbol.getSymbol()+");"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-		table = new LexicalTableImpl(symbol);
-		table.setCorpus(corpus);
+		table = new LexicalTable(corpus, subcorpus);
+		symbol = "Contrast_"+this.getClass().getSimpleName()+"_"+(no_contrast++);
 	}
 
 	public abstract boolean compute() throws Exception;
@@ -85,9 +81,11 @@
 	}
 
 	public void reloadValues() throws StatException {
-		colNames = table.getColNames().asStringsArray();
-		rowNames = table.getRowNames().asStringsArray();
-		frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(table.getSymbol());
+		
+		colNames = table.getData().getColNames().asStringsArray();
+		rowNames = table.getData().getRowNames().asStringsArray();
+		frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(table.getData().getSymbol());
+		
 		indices = RWorkspace.getRWorkspaceInstance().evalToDouble2D(symbol);
 	}
 
Index: tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/RelativeFrequency.java
===================================================================
--- tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/RelativeFrequency.java	(revision 312)
+++ tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/RelativeFrequency.java	(revision 313)
@@ -1,7 +1,8 @@
 package org.txm.functions.contrasts;
 
 import org.txm.core.messages.TXMCoreMessages;
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
+import org.txm.lexicaltable.core.functions.LexicalTable;
+import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.Corpus;
 import org.txm.searchengine.cqp.corpus.Partition;
@@ -12,6 +13,8 @@
 
 public class RelativeFrequency extends Contrast {
 	
+	private ILexicalTable itable;
+	
 	public RelativeFrequency(Corpus corpus, Subcorpus subcorpus, Property property)
 			throws StatException, CqiClientException {
 		super(corpus, subcorpus, property);
@@ -31,12 +34,13 @@
 
 	@Override
 	public boolean compute() throws StatException {
-		colNames = table.getColNames().asStringsArray();
-		rowNames = table.getRowNames().asStringsArray();
-		frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(table.getSymbol());
+		itable = table.getData();
+		colNames = itable.getColNames().asStringsArray();
+		rowNames = itable.getRowNames().asStringsArray();
+		frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(itable.getSymbol());
 		
 		// compute
-		String cmd = symbol +" <- 100*"+table.getSymbol()+" / rowSums("+table.getSymbol()+")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+		String cmd = symbol +" <- 100*"+itable.getSymbol()+" / rowSums("+itable.getSymbol()+")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
 		indices = RWorkspace.getRWorkspaceInstance().evalToDouble2D(cmd);
 		return true;
 	}
Index: tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/AbsoluteFrequency.java
===================================================================
--- tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/AbsoluteFrequency.java	(revision 312)
+++ tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/AbsoluteFrequency.java	(revision 313)
@@ -1,7 +1,8 @@
 package org.txm.functions.contrasts;
 
 import org.txm.core.messages.TXMCoreMessages;
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
+import org.txm.lexicaltable.core.functions.LexicalTable;
+import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.Corpus;
 import org.txm.searchengine.cqp.corpus.Partition;
@@ -12,32 +13,32 @@
 
 public class AbsoluteFrequency extends Contrast {
 	
+	private ILexicalTable itable;
+
 	public AbsoluteFrequency(Corpus corpus, Subcorpus subcorpus, Property property)
 			throws StatException, CqiClientException {
 		super(corpus, subcorpus, property);
-		// TODO Auto-generated constructor stub
 	}
 
 	public AbsoluteFrequency(Partition partition, Property property, int Fmin)
 			throws StatException, CqiClientException {
 		super(partition, property, Fmin);
-		// TODO Auto-generated constructor stub
 	}
 
 
 	public AbsoluteFrequency(LexicalTable table) {
 		super(table);
-		// TODO Auto-generated constructor stub
 	}
 
 	@Override
 	public boolean compute() throws StatException {
-		colNames = table.getColNames().asStringsArray();
-		rowNames = table.getRowNames().asStringsArray();
-		frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(table.getSymbol());
+		itable = table.getData();
+		colNames = itable.getColNames().asStringsArray();
+		rowNames = itable.getRowNames().asStringsArray();
+		frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(itable.getSymbol());
 		
 		// compute
-		String cmd = symbol +" <- "+table.getSymbol(); //$NON-NLS-1$
+		String cmd = symbol +" <- "+itable.getSymbol(); //$NON-NLS-1$
 		indices = RWorkspace.getRWorkspaceInstance().evalToDouble2D(cmd);
 		return true;
 	}
Index: tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/Contrasts.java
===================================================================
--- tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/Contrasts.java	(revision 312)
+++ tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/Contrasts.java	(revision 313)
@@ -3,12 +3,13 @@
 import java.util.ArrayList;
 
 import org.txm.core.messages.TXMCoreMessages;
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
+import org.txm.lexicaltable.core.functions.LexicalTable;
 import org.txm.specificities.core.functions.Chi2;
 import org.txm.specificities.core.functions.Specificites2;
 
 public class Contrasts {
 	LexicalTable table;
+	
 	ArrayList<Contrast> mesures = new ArrayList<Contrast>();
 	ArrayList<ContrastMethod> methods;
 	
Index: tmp/org.txm.specificities.core/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.specificities.core/META-INF/MANIFEST.MF	(revision 312)
+++ tmp/org.txm.specificities.core/META-INF/MANIFEST.MF	(revision 313)
@@ -4,15 +4,16 @@
 Bundle-SymbolicName: org.txm.specificities.core;singleton:=true
 Bundle-Version: 1.0.0.qualifier
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Require-Bundle: org.txm.statsengine.core;bundle-version="1.0.0",
+Require-Bundle: org.txm.statsengine.r.core,
+ org.txm.lexicon.core;bundle-version="1.0.0",
+ org.txm.lexicaltable.core;bundle-version="1.0.0",
+ org.txm.statsengine.core;bundle-version="1.0.0",
  org.txm.core;bundle-version="0.7.0",
  org.txm.progression.core;bundle-version="1.0.0",
  org.txm.chartsengine.core;bundle-version="1.0.0",
  org.txm.chartsengine.jfreechart.core;bundle-version="1.0.0",
  org.txm.chartsengine.r.core;bundle-version="1.0.0",
- org.eclipse.core.runtime;bundle-version="3.10.0",
- org.txm.lexicaltable.core;bundle-version="1.0.0",
- org.txm.lexicon.core;bundle-version="1.0.0"
+ org.eclipse.core.runtime;bundle-version="3.10.0"
 Export-Package: org.txm.functions.contrasts,
  org.txm.specificities.core.chartsengine.jfreechart,
  org.txm.specificities.core.chartsengine.r,
Index: tmp/org.txm.statsengine.core/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.statsengine.core/META-INF/MANIFEST.MF	(revision 312)
+++ tmp/org.txm.statsengine.core/META-INF/MANIFEST.MF	(revision 313)
@@ -11,3 +11,4 @@
 Require-Bundle: org.txm.core;bundle-version="0.7.0",
  org.txm.utils;bundle-version="1.0.0"
 Bundle-Vendor: Textometrie.org
+Import-Package: org.eclipse.osgi.util
Index: tmp/org.txm.statsengine.core/src/org/txm/statsengine/core/messages/StatsEngineCoreMessages.java
===================================================================
--- tmp/org.txm.statsengine.core/src/org/txm/statsengine/core/messages/StatsEngineCoreMessages.java	(revision 312)
+++ tmp/org.txm.statsengine.core/src/org/txm/statsengine/core/messages/StatsEngineCoreMessages.java	(revision 313)
@@ -1,8 +1,9 @@
 package org.txm.statsengine.core.messages;
 
+import org.eclipse.osgi.util.NLS;
 import org.txm.utils.messages.Utf8NLS;
 
-public class StatsEngineCoreMessages extends Utf8NLS {
+public class StatsEngineCoreMessages extends NLS {
 
 	private static final String BUNDLE_NAME = "org.txm.statsengine.core.messages.messages"; //$NON-NLS-1$
 
Index: tmp/org.txm.statsengine.core/src/org/txm/statsengine/core/data/QuantitativeDataStructure.java
===================================================================
--- tmp/org.txm.statsengine.core/src/org/txm/statsengine/core/data/QuantitativeDataStructure.java	(revision 312)
+++ tmp/org.txm.statsengine.core/src/org/txm/statsengine/core/data/QuantitativeDataStructure.java	(revision 313)
@@ -27,16 +27,12 @@
 //
 package org.txm.statsengine.core.data;
 
-import org.txm.core.results.ITXMResult;
-
-
-// TODO: Auto-generated Javadoc
 /**
  * The root of all other data structures.
  * 
  * @author sloiseau
  */
-public interface QuantitativeDataStructure extends ITXMResult {
+public interface QuantitativeDataStructure {
 
 	/**
 	 * The symbol is a the name of the data structure in a wrapped statistical
Index: tmp/org.txm.cah.core/src/org/txm/cah/core/functions/CAH.java
===================================================================
--- tmp/org.txm.cah.core/src/org/txm/cah/core/functions/CAH.java	(revision 312)
+++ tmp/org.txm.cah.core/src/org/txm/cah/core/functions/CAH.java	(revision 313)
@@ -35,7 +35,7 @@
 import org.txm.cah.core.messages.CAHCoreMessages;
 import org.txm.core.results.ITXMResult;
 import org.txm.functions.Function;
-import org.txm.lexicaltable.core.statsengine.data.LexicalTable;
+import org.txm.lexicaltable.core.functions.LexicalTable;
 import org.txm.searchengine.cqp.corpus.Corpus;
 import org.txm.searchengine.cqp.corpus.Partition;
 import org.txm.statsengine.r.core.RWorkspace;
@@ -113,7 +113,6 @@
 	protected CA ca;
 	protected LexicalTable table;
 
-
 	/**
 	 * Instantiates a new cAH.
 	 *
@@ -160,7 +159,7 @@
 		this.source = table;
 		this.partition = table.getPartition();
 		this.corpus = table.getCorpus();
-		this.target = table.getSymbol();
+		this.target = table.getData().getSymbol();
 		this.table = table;
 	}
 
Index: tmp/org.txm.lexicon.core/src/org/txm/lexicon/core/corpusengine/cqp/Lexicon.java
===================================================================
--- tmp/org.txm.lexicon.core/src/org/txm/lexicon/core/corpusengine/cqp/Lexicon.java	(revision 312)
+++ tmp/org.txm.lexicon.core/src/org/txm/lexicon/core/corpusengine/cqp/Lexicon.java	(revision 313)
@@ -33,19 +33,26 @@
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Map;
 
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.core.results.ITXMResult;
 import org.txm.functions.Function;
 import org.txm.lexicon.core.messages.LexiconCoreMessages;
-import org.txm.searchengine.cqp.CqpDataProxy;
+import org.txm.searchengine.cqp.ICqiClient;
+import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.corpus.Corpus;
 import org.txm.searchengine.cqp.corpus.CorpusManager;
+import org.txm.searchengine.cqp.corpus.MainCorpus;
 import org.txm.searchengine.cqp.corpus.Property;
 import org.txm.searchengine.cqp.corpus.Subcorpus;
+import org.txm.searchengine.cqp.corpus.query.Query;
 import org.txm.statsengine.core.StatException;
 import org.txm.statsengine.core.data.Vector;
 import org.txm.statsengine.r.core.data.VectorImpl;
+import org.txm.utils.logger.Log;
 
 // TODO: Auto-generated Javadoc
 //  TODO should be put into stat.data package ?
@@ -65,51 +72,130 @@
 	protected static int nolex = 1;
 	
 	/** The freqs. */
-	private final int[] freqs;
+	private int[] freqs;
 	
 	/** The ids. */
-	private final int[] ids;
+	private int[] ids;
 	
 	/** The forms. */
 	private String[] forms;
 	
 	/** The property. */
-	private final Property property;
+	private Property property;
 	
 	/** The number of tokens. */
 	int numberOfTokens = -1;
 
-	/** The cache. */
-	private Map<Property, CqpDataProxy> cache;
-	
 	/** The symbol. */
 	private String symbol;
 	
 	/** The writer. */
 	private OutputStreamWriter writer;
 
+	public Lexicon(Corpus corpus, Property property) throws CqiClientException {
+		if (corpus instanceof MainCorpus) initLexiconWith((MainCorpus)corpus, property);
+		else if (corpus instanceof Subcorpus) initLexiconWith((MainCorpus)corpus, property);
+		else {
+			throw new IllegalArgumentException("Corpus class not managed: "+corpus);
+		}
+	}
+	
 	/**
-	 * Protected on purpose: should be accessed through.
-	 *
-	 * @param corpus the corpus
-	 * @param property the property
-	 * @param freq the freq
-	 * @param ids the ids
-	 * {@link Corpus#getLexicon(Property)} or
-	 * {@link Subcorpus#getLexicon(Property)}.
+	 * Gets the lexicon relative to a given property.
+	 * 
+	 * @param property
+	 *            the property
+	 * 
+	 * @return the lexicon
+	 * 
+	 * @throws CqiClientException
+	 *             the cqi client exception
 	 */
-	public Lexicon(Corpus corpus, Property property, final int[] freq, final int[] ids) {
-		super(corpus);
-		if (freq.length != ids.length)
-			throw new IllegalArgumentException(LexiconCoreMessages.Lexicon_0);
-		this.freqs = freq;
-		this.ids = ids;
-		this.forms = null;
-		this.property = property;
+	protected void initLexiconWith(MainCorpus corpus, Property property) throws CqiClientException {
+		// System.out.println("in "+this.getCqpId()+" look for cached lexicon "+property);
+		
+
+
+		// System.out.println("not found");
+		Log.finest(TXMCoreMessages.LEXICON + corpus.getName());
+		int lexiconSize;
+		try {
+			lexiconSize = CorpusManager.getCorpusManager().getCqiClient()
+					.lexiconSize(property.getQualifiedName());
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		}
+
+		int[] ids = new int[lexiconSize];
+		for (int i = 0; i < ids.length; i++) {
+			ids[i] = i;
+		}
+
+		/*
+		 * String[] forms = null; try { forms =
+		 * CorpusManager.getCorpusManager().
+		 * getCqiClient().id2Str(property.getQualifiedName(), ids); } catch
+		 * (IOException e) { throw new CqiClientException(e); } catch
+		 * (CqiServerError e) { throw new CqiClientException(e); }
+		 */
+
+		int[] freqs;
+		try {
+			freqs = CorpusManager.getCorpusManager().getCqiClient().id2Freq(
+					property.getQualifiedName(), ids);
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		}
+
+		init(corpus, property, freqs, ids);
 	}
+	
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.txm.searchengine.cqp.corpus.Corpus#getLexicon(org.txm
+	 * .searchengine.cqp.corpus.Property)
+	 */
+	protected void initLexiconWith(Subcorpus corpus, Property property) throws CqiClientException {
 
+		//System.out.println("not found");
+		Log.finest(TXMCoreMessages.SUBCORPUS_LEXICON + corpus.getName());
+		long start = System.currentTimeMillis();
+		int[][] fdist = null;
+		Subcorpus tmp = null;
+		try {
+			tmp = corpus.createSubcorpus(new Query("[]"), "S"+corpus.getNextSubcorpusCounter(), true); //$NON-NLS-1$
+			if (tmp != null) {
+				fdist = CorpusManager.getCorpusManager().getCqiClient().fdist1(
+						tmp.getQualifiedCqpId(), 0,
+						ICqiClient.CQI_CONST_FIELD_MATCH, property.getName());
+			
+				corpus.dropSubcorpus(tmp); // drop the subcorpus only if correctly created
+			}
+			//System.out.println("nb lines: "+fdist.length);
+		} catch (Exception e) {
+			throw new CqiClientException(e);
+		} finally {
+			if (tmp != null) {
+				try {corpus.dropSubcorpus(tmp);}
+				catch (Exception e2) {}
+			}
+		}
+		int lexiconSize = fdist.length;
+
+		int[] freqs = new int[lexiconSize];
+		int[] ids = new int[lexiconSize];
+		for (int i = 0; i < fdist.length; i++) {
+			ids[i] = fdist[i][0];
+			freqs[i] = fdist[i][1];
+		}
+
+		init(corpus, property, freqs, ids);
+	}
+	
 	/**
-	 * Protected on purpose: should be accessed through.
+	 * Hack initializer using a map to set forms and frequencies
 	 *
 	 * @param corpus the corpus
 	 * @param property the property
@@ -120,15 +206,37 @@
 	public Lexicon(Corpus corpus, Property property, Map<String, Integer> map) {
 		super(corpus);
 		int size = map.size();
-		freqs = new int[size];
-		forms = map.keySet().toArray(new String[] {});
+		int[] freqs = new int[size];
+		String[] forms = map.keySet().toArray(new String[] {});
 		for (int i = 0; i < forms.length; i++) {
 			freqs[i] = map.get(forms[i]);
 		}
-		this.ids = null;
+
+		this.init(corpus, property, freqs, ids);
+	}
+	
+	/**
+	 * Protected on purpose: should be accessed through others initializer.
+	 *
+	 * @param corpus the corpus
+	 * @param property the property
+	 * @param freq the freq
+	 * @param ids the ids
+	 * {@link Corpus#getLexicon(Property)} or
+	 * {@link Subcorpus#getLexicon(Property)}.
+	 */
+	protected void init(ITXMResult corpus, Property property, int[] freq, int[] ids) {
+		if (freq.length != ids.length)
+			throw new IllegalArgumentException(LexiconCoreMessages.Lexicon_0);
+		this.freqs = freq;
+		this.ids = ids;
+		this.forms = null;
 		this.property = property;
+		this.setParent(corpus);
 	}
 
+
+
 	/**
 	 * The dif ferent types in the lexicon, the type at the index <code>j</code>
 	 * of this array have the frequency at index <code>j</code> in the array
@@ -175,9 +283,7 @@
 				org.txm.utils.logger.Log.printStackTrace(e);
 				return null;
 			}
-		}
-		else
-		{
+		} else {
 			number = Math.min(number, ids.length);
 			if (number <= 0)
 				return new String[0];
@@ -236,8 +342,6 @@
 			// if (freqs[i] != 1) System.out.println(freqs[i]);
 		}
 	}
-
-
 	
 	/**
 	 * Convert the Lexicon into a Vector object.
@@ -290,7 +394,6 @@
 		return property;
 	}
 
-
 	/**
 	 * Dump.
 	 *
@@ -391,7 +494,7 @@
 
 	@Override
 	public boolean delete() {
-		this.getCorpus().dropLexicon(getProperty());
+		//TODO: dropLexicon(getProperty()) or not ?
 		return super.delete();
 	}
 
@@ -443,4 +546,32 @@
 //		}
 		return null;
 	}
+
+	/**
+	 * Find or build a lexicon given a Corpus (MainCorpus or SubCorpus).
+	 * 
+	 * 
+	 * 
+	 * @param corpus
+	 * @param property
+	 * @return a Lexicon. May return null if the lexicon forms or freqs are null.
+	 * @throws CqiClientException
+	 */
+	public static Lexicon getLexicon(Corpus corpus, Property property) throws CqiClientException {
+		ArrayList<ITXMResult> results = corpus.getResults(Lexicon.class);
+		for (ITXMResult result : results) {
+			Lexicon lex = (Lexicon)result;
+			if (lex.getProperty().equals(property)) {
+				return lex;
+			}
+		}
+		
+		Lexicon lex = new Lexicon(corpus, property);
+		if (lex.getForms() != null && lex.getFreq() != null) {
+			corpus.addResult(lex);
+			return lex;
+		} else {
+			return null;
+		}
+	}
 }
Index: tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java	(revision 313)
@@ -509,6 +509,10 @@
 	public static void put(String nodeQualifier, String key, String value) {
 		scope.getNode(nodeQualifier).put(key, value);
 	}
+	
+	public static void putString(String nodeQualifier, String key, String value) {
+		scope.getNode(nodeQualifier).put(key, value);
+	}
 
 	/**
 	 * 
Index: tmp/org.txm.core/src/java/org/txm/core/preferences/TBXPreferences.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/core/preferences/TBXPreferences.java	(revision 0)
+++ tmp/org.txm.core/src/java/org/txm/core/preferences/TBXPreferences.java	(revision 313)
@@ -0,0 +1,125 @@
+package org.txm.core.preferences;
+
+import org.txm.core.messages.TXMCoreMessages;
+import org.txm.utils.logger.Log;
+
+public class TBXPreferences extends TXMPreferences {
+
+	public static String PREFERENCES_NODE = TBXPreferences.class.getCanonicalName();
+	
+	/** The Constants for Toolbox properties. */
+	public static final String LOG_LEVEL = "log_level"; //$NON-NLS-1$
+	public static final String ADD_TECH_LOGS = "log_in_console"; //$NON-NLS-1$
+	public static final String SHOW_TIMINGS = "show_timings"; //$NON-NLS-1$
+	public static final String LOG_DIR = "log_directory"; //$NON-NLS-1$
+	public static final String LOG_IN_FILE = "log_in_file"; //$NON-NLS-1$
+	public static final String EXPERT_USER = "txm_expert_user"; //$NON-NLS-1$
+	public static final String LOG_STACKTRACE = "log_stacktrace"; //$NON-NLS-1$
+
+	/** The Constant CQI_SERVER_HOST. */
+	public static final String CQI_SERVER_HOST = "cqi_server_host"; //$NON-NLS-1$
+
+	/** The Constant CQI_SERVER_PORT. */
+	public static final String CQI_SERVER_PORT = "cqi_server_port"; //$NON-NLS-1$
+
+	/** The Constant CQI_SERVER_LOGIN. */
+	public static final String CQI_SERVER_LOGIN = "cqi_server_login"; //$NON-NLS-1$
+
+	/** The Constant CQI_SERVER_PASSWORD. */
+	public static final String CQI_SERVER_PASSWORD = "cqi_server_password"; //$NON-NLS-1$
+
+	/** The Constant CQI_SERVER_PATH_TO_EXECUTABLE. */
+	public static final String CQI_SERVER_PATH_TO_EXECUTABLE = "cqi_server_path_to_executable"; //$NON-NLS-1$
+
+	public static final String CQI_SERVER_PATH_TO_CQPLIB = "cqi_server_path_to_cqplib"; //$NON-NLS-1$
+
+	/** The Constant CQI_SERVER_PATH_TO_INIT_FILE. */
+	public static final String CQI_SERVER_PATH_TO_INIT_FILE = "cqi_server_path_to_init_file"; //$NON-NLS-1$
+
+	/** The Constant CQI_SERVER_ADDITIONAL_OPTIONS. */
+	public static final String CQI_SERVER_ADDITIONAL_OPTIONS = "cqi_server_additional_options"; //$NON-NLS-1$
+
+	/** The Constant CQI_SERVER_MONITOR_OUTPUT. */
+	public static final String CQI_SERVER_MONITOR_OUTPUT = "cqi_server_monitor_output"; //$NON-NLS-1$
+
+	/** The Constant CQI_SERVER_IS_REMOTE. */
+	public static final String CQI_SERVER_IS_REMOTE = "cqi_server_is_remote"; //$NON-NLS-1$
+
+	/** The Constant CQI_SERVER_MODE. */
+	public static final String CQI_NETWORK_MODE = "cqi_server_mode"; //$NON-NLS-1$
+
+	public static final String CQP_EMPTY_VALUE_CODE = "cqp_empty_value_code";
+
+	/** The Constant SCRIPT_ROOT_DIR. */
+	public static final String SCRIPT_ROOT_DIR = "script_root_dir"; //$NON-NLS-1$
+
+	/** The Constant SCRIPT_CURRENT_DIR. */
+	public static final String SCRIPT_CURRENT_DIR = "script_current_dir"; //$NON-NLS-1$
+
+	/** The Constant UI_LOCALE. */
+	public static final String UI_LOCALE = "ui_locale"; //$NON-NLS-1$
+
+	/** The Constant WORKSPACE_LOCATION. */
+	public static final String WORKSPACE_LOCATION = "workspace_location"; //$NON-NLS-1$
+
+	/** The Constant INSTALL_DIR. */
+	public static final String INSTALL_DIR = "install_dir"; //$NON-NLS-1$
+
+	/** The Constant USER_TXM_HOME. */
+	public static final String USER_TXM_HOME = "user_txm_home"; //$NON-NLS-1$
+
+	/** The Constant TREETAGGER_INSTALL_PATH. */
+	public static final String TREETAGGER_INSTALL_PATH = "treetagger_install_path"; //$NON-NLS-1$
+	/** The Constant TREETAGGER_MODELS_PATH. */
+	public static final String TREETAGGER_MODELS_PATH = "treetagger_models_path"; //$NON-NLS-1$
+	public static final String TREETAGGER_OPTIONS = "treetagger_options"; //$NON-NLS-1$
+	public static final String TREETAGGER_APOSTROPHE = "treetagger_fix_apostrophes"; //$NON-NLS-1$
+
+	public static final String METADATA_ENCODING = "metadata_encoding"; //$NON-NLS-1$
+	public static final String METADATA_COLSEPARATOR = "metadata_colseparator"; //$NON-NLS-1$
+	public static final String METADATA_TXTSEPARATOR = "metadata_txtseparator"; //$NON-NLS-1$
+
+	/** Contains all the parameters keys. */
+	public static final String[] existingKeys = { LOG_LEVEL, LOG_STACKTRACE, ADD_TECH_LOGS, LOG_DIR,
+		LOG_IN_FILE, CQI_SERVER_HOST, CQI_SERVER_PORT, CQI_SERVER_LOGIN,
+		CQI_SERVER_PASSWORD, CQI_SERVER_PATH_TO_EXECUTABLE,CQI_SERVER_PATH_TO_CQPLIB,
+		CQI_SERVER_ADDITIONAL_OPTIONS, CQI_SERVER_MONITOR_OUTPUT,
+		CQI_SERVER_IS_REMOTE, CQI_NETWORK_MODE, CQP_EMPTY_VALUE_CODE, SCRIPT_ROOT_DIR,
+		SCRIPT_CURRENT_DIR, UI_LOCALE, WORKSPACE_LOCATION, INSTALL_DIR,
+		USER_TXM_HOME,
+		//		IS_R_MANDATORY, R_PATH_TO_EXECUTABLE, R_DEBUG, R_REMOTE, R_SERVER_ADDRESS,
+		//		R_PORT, R_USER, R_PASSWORD, R_PACKAGES_PATH, R_RARGS, R_RSERVEARGS, R_DISABLE, R_FILE_TRANSFERT,R_SVG_DEVICE,
+
+		TREETAGGER_INSTALL_PATH, TREETAGGER_MODELS_PATH,TREETAGGER_OPTIONS, TREETAGGER_APOSTROPHE,
+		METADATA_ENCODING, METADATA_COLSEPARATOR,METADATA_TXTSEPARATOR
+
+	};
+
+	public static String getID() {
+		return "org.txm.core";
+	}
+
+	@Override
+	public void initializeDefaultPreferences() {
+		Log.info(TXMCoreMessages.Toolbox_4 + TBXPreferences.getID()); 
+
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.LOG_LEVEL, "OFF"); //$NON-NLS-1$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.ADD_TECH_LOGS, "" + false); //$NON-NLS-1$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.LOG_STACKTRACE, "" + true); //$NON-NLS-1$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.LOG_IN_FILE, "" + false); //$NON-NLS-1$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.CQI_SERVER_ADDITIONAL_OPTIONS, "-b 1000000 -d OFF"); //$NON-NLS-1$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.CQI_SERVER_PORT, "4877"); //$NON-NLS-1$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.CQI_SERVER_HOST, "localhost"); //$NON-NLS-1$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.CQI_SERVER_LOGIN, "anonymous"); //$NON-NLS-1$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.CQI_SERVER_PASSWORD, ""); //$NON-NLS-1$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.CQI_SERVER_IS_REMOTE, "" + false); //$NON-NLS-1$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.CQI_NETWORK_MODE, "false"); //$NON-NLS-1$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.CQP_EMPTY_VALUE_CODE, ""); //$NON-NLS-1$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.UI_LOCALE, "fr"); //$NON-NLS-1$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.TREETAGGER_INSTALL_PATH, System.getProperty("user.home") + "/TXM/treetagger"); //$NON-NLS-1$ //$NON-NLS-2$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.TREETAGGER_MODELS_PATH, TXMPreferences.getString(TBXPreferences.class.getCanonicalName(),TBXPreferences.TREETAGGER_INSTALL_PATH) + "/models"); //$NON-NLS-1$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.TREETAGGER_APOSTROPHE, "false"); //$NON-NLS-1$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.METADATA_ENCODING, "UTF-8"); //$NON-NLS-1$
+		TXMPreferences.putString(TBXPreferences.class.getCanonicalName(),TBXPreferences.METADATA_TXTSEPARATOR, "\""); //$NON-NLS-1$
+	}
+}

Property changes on: tmp/org.txm.core/src/java/org/txm/core/preferences/TBXPreferences.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.core/src/java/org/txm/core/results/ITXMResult.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/core/results/ITXMResult.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/core/results/ITXMResult.java	(revision 313)
@@ -81,7 +81,14 @@
 	 */
 	public void setVisible(boolean visible);
 	
+	/**
+	 * Gets the children results specified by their class.
+	 * @param type
+	 * @return
+	 */
+	public ArrayList<ITXMResult> getResults(Class type);
 	
+	
 	/**
 	 * Gets the children results specified by their class.
 	 * @param type
Index: tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java	(revision 313)
@@ -18,7 +18,6 @@
 // At this moment, an empty list is created for children, to not return null when calling getChildren() 
 public abstract class TXMResult implements ITXMResult, Cloneable {
 	
-	
 	/**
 	 * The weight, essentially used for sorting purpose.
 	 */
@@ -168,7 +167,10 @@
 		return this.getResults(null, onlyVisible);
 	}
 
-	
+	@Override
+	synchronized public ArrayList<ITXMResult> getResults(Class type)	{
+		return TXMResult.getNodes(this.children, type, false);
+	}
 
 	@Override
 	synchronized public ArrayList<ITXMResult> getResults(Class type, boolean onlyVisible)	{
Index: tmp/org.txm.core/src/java/org/txm/Toolbox2.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/Toolbox2.java	(revision 0)
+++ tmp/org.txm.core/src/java/org/txm/Toolbox2.java	(revision 313)
@@ -0,0 +1,142 @@
+// 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: 2017-01-24 18:11:42 +0100 (Tue, 24 Jan 2017) $
+// $LastChangedRevision: 3400 $
+// $LastChangedBy: mdecorde $ 
+//
+
+package org.txm;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.HashSet;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.txm.objects.Workspace;
+import org.txm.utils.logger.Log;
+
+/**
+ * The Class Toolbox. A collection of static methods to initialize the toolbox
+ * 
+ * It initialize its engines Service
+ * 
+ * @author jmague, mdecorde, sjacquot
+ */
+public class Toolbox2 {
+
+	private static HashMap<Class, Engine> engines;
+
+	private static Workspace workspace;
+
+	// script engines : Groovy and more ? Python, etc.
+
+	public static boolean initialize() {
+		return stopEngines() && startsEngines() && stopWorkspace() && startWorkspace();
+	}
+
+	public static boolean shutdown() {
+		boolean ret = stopWorkspace() && stopEngines();
+		
+		engines.clear();
+		
+		return ret;
+	}
+
+	private static boolean startWorkspace() {
+		File xmlproject = new File(System.getProperty("osgi.user.area"), "default.xml");
+		workspace = new Workspace(xmlproject);
+		return workspace.load();
+	}
+
+	private static boolean stopWorkspace() {
+		if (workspace == null) return true;
+
+		boolean ret = workspace.save();
+
+		if (ret) workspace = null;
+
+		return ret;
+	}
+
+	public Engine getEngine(Class c) {
+		if (!engines.containsKey(c)) return null;
+
+		return engines.get(c);
+	}
+
+	private static boolean fetchEngines() {
+
+		IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(Engine.ENGINE_EXTENSION_POINT_ID);
+
+		for(int i = 0; i < contributions.length; i++) {
+			try {
+				Log.info("Registering engine: "+contributions[i].getName());
+				Engine engine = (Engine)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
+				addEngine(engine);
+			}
+			catch(CoreException e) {
+				e.printStackTrace();
+			} 
+		}
+
+		return true;
+	}
+
+	private static boolean startsEngines() {
+		if (engines == null) fetchEngines();
+
+		boolean result = true;
+		for (Class c : engines.keySet()) {
+			Engine e = engines.get(c);
+			Log.info("Start&connect engine: "+e.getClass());
+			result = result && e.start() && e.connect();
+		}
+
+		return true;
+	}
+
+	private static void addEngine(Engine engine) {
+		engines.put(engine.getClass(), engine);
+	}
+
+	private static void removeEngine(Engine engine) {
+		engines.remove(engine.getClass());
+	}
+
+	private static boolean stopEngines() {
+		if (engines == null) return true;
+		if (engines.size() == 0) return true;
+
+		boolean result = true;
+		for (Class c : engines.keySet()) {
+			Engine e = engines.get(c);
+			Log.info("Disconnect&stop engine: "+e.getClass());
+			result = result && e.disconnect() && e.stop();
+		}
+
+		return true;
+	}
+}

Property changes on: tmp/org.txm.core/src/java/org/txm/Toolbox2.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.core/src/java/org/txm/objects/BaseParameters.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/objects/BaseParameters.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/objects/BaseParameters.java	(revision 313)
@@ -18,7 +18,6 @@
 import javax.xml.parsers.ParserConfigurationException;
 
 import org.txm.annotation.repository.SQLKnowledgeRepository;
-import org.txm.importer.xtz.ImportKeys;
 import org.txm.sql.SQLConnection;
 import org.txm.utils.xml.DomUtils;
 import org.txm.utils.logger.Log;
Index: tmp/org.txm.core/src/java/org/txm/objects/Corpus.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/objects/Corpus.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/objects/Corpus.java	(revision 313)
@@ -43,6 +43,7 @@
 import org.txm.annotation.repository.KnowledgeRepository;
 import org.txm.annotation.repository.KnowledgeRepositoryManager;
 import org.txm.core.messages.TXMCoreMessages;
+import org.txm.core.preferences.TBXPreferences;
 import org.txm.functions.ProgressWatcher;
 import org.txm.metadatas.DateMetadata;
 import org.txm.metadatas.Metadata;
@@ -559,7 +560,7 @@
 	 */
 	public File getBaseDirectory()
 	{
-		String txmhome = Toolbox.getParam(Toolbox.USER_TXM_HOME);
+		String txmhome = Toolbox.getParam(TBXPreferences.USER_TXM_HOME);
 		Base base = this.getBase();
 		if (base != null)
 			return base.params.paramFile.getParentFile();
Index: tmp/org.txm.core/src/java/org/txm/searchengine/cqp/MemCqiServer.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/searchengine/cqp/MemCqiServer.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/searchengine/cqp/MemCqiServer.java	(revision 313)
@@ -40,6 +40,7 @@
 import org.apache.commons.lang.StringUtils;
 import org.txm.Toolbox;
 import org.txm.core.messages.TXMCoreMessages;
+import org.txm.core.preferences.TBXPreferences;
 import org.txm.searchengine.cqp.clientExceptions.ServerNotFoundException;
 import org.txm.searchengine.cqp.clientExceptions.UnexpectedAnswerException;
 import org.txm.searchengine.cqp.serverException.CqiCqpErrorNoSuchCorpus;
@@ -149,7 +150,7 @@
 			
 			try {
 				String path = System.getProperty("java.library.path");
-				String libpath = System.getProperty("path.separator")+Toolbox.getParam(Toolbox.CQI_SERVER_PATH_TO_CQPLIB);
+				String libpath = System.getProperty("path.separator")+Toolbox.getParam(TBXPreferences.CQI_SERVER_PATH_TO_CQPLIB);
 				if (!path.contains(libpath)) {
 					path += libpath;
 				}
@@ -451,7 +452,7 @@
 		String[] strings = {"je", "jamais"};
 		int[] strucpos = {0, 1, 2, 3 , 4};
 
-		Toolbox.setParam(Toolbox.CQI_SERVER_PATH_TO_CQPLIB, pathToExecutable);
+		Toolbox.setParam(TBXPreferences.CQI_SERVER_PATH_TO_CQPLIB, pathToExecutable);
 
 		MemCqiServer server = new MemCqiServer(pathToExecutable, pathToRegistry, pathToInitFile, " -b 10000000 -d OFF", false);
 		if (server.start()) System.out.println("Mem Server ok");
Index: tmp/org.txm.core/src/java/org/txm/searchengine/cqp/corpus/Corpus.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/searchengine/cqp/corpus/Corpus.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/searchengine/cqp/corpus/Corpus.java	(revision 313)
@@ -31,16 +31,13 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
-import java.util.Map;
 
 import org.eclipse.osgi.util.NLS;
 import org.txm.core.messages.TXMCoreMessages;
 import org.txm.core.results.ITXMResult;
 import org.txm.functions.selection.SelectionResult;
-import org.txm.lexicon.core.corpusengine.cqp.Lexicon;
 import org.txm.objects.Base;
 import org.txm.objects.TxmObject;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
@@ -49,7 +46,6 @@
 import org.txm.searchengine.cqp.corpus.query.Query;
 import org.txm.searchengine.cqp.corpus.query.QueryPart;
 import org.txm.searchengine.cqp.serverException.CqiServerError;
-import org.txm.statsengine.r.core.RWorkspace;
 import org.txm.utils.logger.Log;
 import org.w3c.dom.Element;
 import org.w3c.dom.NodeList;
@@ -101,12 +97,6 @@
 	/** All partitions that have been created from this corpus. */
 	protected List<Partition> partitions;
 
-	/** The results of textometric computation ran on this corpus. */
-//	private ArrayList<Object> results = new ArrayList<Object>();
-
-	/** An association between name of analysis property and lexical table. */
-	Map<String, Lexicon> lexicons = new HashMap<String, Lexicon>();
-
 	/** All private infos of the corpus. */
 	private String charset = "latin1"; //$NON-NLS-1$
 
@@ -581,21 +571,6 @@
 	}
 
 	/**
-	 * Drop a lexicon from the cache. Return the dropped lexicon, or
-	 * <code>null</code> if no lexicon was existing for this analysis property.
-	 * 
-	 * @param analysisProperty
-	 *            the analysis property
-	 * 
-	 * @return the lexicon
-	 * 
-	 * @author sloiseau
-	 */
-	public Lexicon dropLexicon(Property analysisProperty) {
-		return lexicons.remove(analysisProperty.getName());
-	}
-
-	/**
 	 * Drops a partition.
 	 * 
 	 * @param partition
@@ -737,20 +712,6 @@
 	}
 
 	/**
-	 * Gets the lexicon relative to a given property.
-	 * 
-	 * @param property
-	 *            the property
-	 * 
-	 * @return the lexicon
-	 * 
-	 * @throws CqiClientException
-	 *             the cqi client exception
-	 */
-	public abstract Lexicon getLexicon(Property property)
-			throws CqiClientException;
-
-	/**
 	 * Get the corpus locale using txmcorpus_lang property
 	 * @return
 	 */
@@ -1227,87 +1188,87 @@
 
 	
 	
-	/**
-	 * Send the Corpus indexes to R.
-	 * 
-	 * Only the word properties are send.
-	 * TODO: send structural unit properties too
-	 *
-	 * @return the string
-	 * @throws Exception the exception
-	 */
-	public String SendToR() throws Exception
-	{
-		int initialPosition = 0;
-		if (this.getMatches() != null && this.getMatches().size() > 0)
-			initialPosition = this.getMatches().get(0).getStart();
-		
-		// cols name to export
-		List<Property> props = this.getProperties();
-		String[] colnames = new String[this.getProperties().size()];
+//	/**
+//	 * Send the Corpus indexes to R.
+//	 * 
+//	 * Only the word properties are send.
+//	 * TODO: send structural unit properties too
+//	 *
+//	 * @return the string
+//	 * @throws Exception the exception
+//	 */
+//	public String SendToR() throws Exception
+//	{
+//		int initialPosition = 0;
+//		if (this.getMatches() != null && this.getMatches().size() > 0)
+//			initialPosition = this.getMatches().get(0).getStart();
+//		
+//		// cols name to export
+//		List<Property> props = this.getProperties();
+//		String[] colnames = new String[this.getProperties().size()];
+//
+//		// compute positions list
+//		int length = 0;
+//		for (Match match : getMatches()) { // 1) get number of positions
+//			length += match.getLength();
+//		}
+//		int[] positions = new int[length];
+//		int iPosition = 0;
+//		for (Match match : getMatches()) { // 2) append positions
+//			int p_end = match.getEnd();
+//			for (int p = match.getStart() ; p < p_end ; p++)
+//				positions[iPosition] = p;
+//		}
+//
+//		// 0- create the R object
+//		this.symbol = prefixR + (nocorpus++);
+//		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
+//		rw.eval(symbol +" <- matrix(ncol="+colnames.length+", nrow="+positions.length+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+//
+//		for(int i = 0 ; i < props.size() ; i++) {
+//			Property prop = props.get(i);
+//			colnames[i] = prop.getName();
+//			// send positions to R
+//			int[] idx = CorpusManager.getCorpusManager().getCqiClient().cpos2Id(prop.getQualifiedName(), positions);
+//			rw.addVectorToWorkspace("tmp", idx); //$NON-NLS-1$
+//			//if (initialPosition > 0) rw.eval("tmp <- tmp - "+initialPosition);
+//			//System.out.println("lengths "+prop.getName()+" : idx="+idx.length+" mat "+positions.length);
+//			rw.eval(symbol+"[,"+(i+1)+"] <- tmp"); //$NON-NLS-1$ //$NON-NLS-2$
+//		}
+//
+//		//set matrix col names
+//		rw.addVectorToWorkspace("tmpcol", colnames); //$NON-NLS-1$
+//		rw.eval("colnames("+symbol+") <- tmpcol"); //$NON-NLS-1$ //$NON-NLS-2$
+//
+//		rw.eval(symbol+" <- list(data="+symbol+")"); //$NON-NLS-1$ //$NON-NLS-2$
+//
+//		// create lexicons
+//		for (Property prop : this.getProperties()) {
+//			Lexicon lex = this.getLexicon(prop);
+//			rw.addVectorToWorkspace("tmp", lex.getForms()); //$NON-NLS-1$
+//			rw.eval(symbol+"$lex$"+prop.getName()+" <- tmp"); //$NON-NLS-1$ //$NON-NLS-2$
+//		}
+//		
+//		StructuralUnit text_su = this.getStructuralUnit("text");
+//		if (text_su != null) {
+//			StructuralUnitProperty text_id = text_su.getProperty("id");
+//			if (text_id != null) {
+//				int[] textlimits = this.getTextStartLimits();
+//				rw.addVectorToWorkspace("text_limits", textlimits);
+//				if (initialPosition > 0) rw.eval("text_limits <- text_limits - "+initialPosition);
+//				rw.eval(symbol+"$structs$text$start <- text_limits"); //$NON-NLS-1$ //$NON-NLS-2$
+//				
+//				textlimits = this.getTextEndLimits();
+//				rw.addVectorToWorkspace("text_limits", textlimits);
+//				if (initialPosition > 0) rw.eval("text_limits <- text_limits - "+initialPosition);
+//				//System.out.println("lengths "+prop.getName()+" : idx="+idx.length+" mat "+positions.length);
+//				rw.eval(symbol+"$structs$text$end <- text_limits"); //$NON-NLS-1$ //$NON-NLS-2$
+//			}
+//		}
+//
+//		return symbol;
+//	}
 
-		// compute positions list
-		int length = 0;
-		for (Match match : getMatches()) { // 1) get number of positions
-			length += match.getLength();
-		}
-		int[] positions = new int[length];
-		int iPosition = 0;
-		for (Match match : getMatches()) { // 2) append positions
-			int p_end = match.getEnd();
-			for (int p = match.getStart() ; p < p_end ; p++)
-				positions[iPosition] = p;
-		}
-
-		// 0- create the R object
-		this.symbol = prefixR + (nocorpus++);
-		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
-		rw.eval(symbol +" <- matrix(ncol="+colnames.length+", nrow="+positions.length+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
-		for(int i = 0 ; i < props.size() ; i++) {
-			Property prop = props.get(i);
-			colnames[i] = prop.getName();
-			// send positions to R
-			int[] idx = CorpusManager.getCorpusManager().getCqiClient().cpos2Id(prop.getQualifiedName(), positions);
-			rw.addVectorToWorkspace("tmp", idx); //$NON-NLS-1$
-			//if (initialPosition > 0) rw.eval("tmp <- tmp - "+initialPosition);
-			//System.out.println("lengths "+prop.getName()+" : idx="+idx.length+" mat "+positions.length);
-			rw.eval(symbol+"[,"+(i+1)+"] <- tmp"); //$NON-NLS-1$ //$NON-NLS-2$
-		}
-
-		//set matrix col names
-		rw.addVectorToWorkspace("tmpcol", colnames); //$NON-NLS-1$
-		rw.eval("colnames("+symbol+") <- tmpcol"); //$NON-NLS-1$ //$NON-NLS-2$
-
-		rw.eval(symbol+" <- list(data="+symbol+")"); //$NON-NLS-1$ //$NON-NLS-2$
-
-		// create lexicons
-		for (Property prop : this.getProperties()) {
-			Lexicon lex = this.getLexicon(prop);
-			rw.addVectorToWorkspace("tmp", lex.getForms()); //$NON-NLS-1$
-			rw.eval(symbol+"$lex$"+prop.getName()+" <- tmp"); //$NON-NLS-1$ //$NON-NLS-2$
-		}
-		
-		StructuralUnit text_su = this.getStructuralUnit("text");
-		if (text_su != null) {
-			StructuralUnitProperty text_id = text_su.getProperty("id");
-			if (text_id != null) {
-				int[] textlimits = this.getTextStartLimits();
-				rw.addVectorToWorkspace("text_limits", textlimits);
-				if (initialPosition > 0) rw.eval("text_limits <- text_limits - "+initialPosition);
-				rw.eval(symbol+"$structs$text$start <- text_limits"); //$NON-NLS-1$ //$NON-NLS-2$
-				
-				textlimits = this.getTextEndLimits();
-				rw.addVectorToWorkspace("text_limits", textlimits);
-				if (initialPosition > 0) rw.eval("text_limits <- text_limits - "+initialPosition);
-				//System.out.println("lengths "+prop.getName()+" : idx="+idx.length+" mat "+positions.length);
-				rw.eval(symbol+"$structs$text$end <- text_limits"); //$NON-NLS-1$ //$NON-NLS-2$
-			}
-		}
-
-		return symbol;
-	}
-
 	/**
 	 * set the corpus charset name, to be able to print it well.
 	 *
Index: tmp/org.txm.core/src/java/org/txm/searchengine/cqp/corpus/MainCorpus.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/searchengine/cqp/corpus/MainCorpus.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/searchengine/cqp/corpus/MainCorpus.java	(revision 313)
@@ -44,7 +44,6 @@
 import org.txm.annotation.repository.KnowledgeRepositoryManager;
 import org.txm.core.messages.TXMCoreMessages;
 import org.txm.functions.ProgressWatcher;
-import org.txm.lexicon.core.corpusengine.cqp.Lexicon;
 import org.txm.objects.Base;
 import org.txm.objects.BaseParameters;
 import org.txm.objects.TxmObject;
@@ -55,7 +54,6 @@
 import org.txm.searchengine.cqp.corpus.query.Query;
 import org.txm.searchengine.cqp.serverException.CqiServerError;
 import org.txm.utils.DeleteDir;
-import org.txm.utils.logger.Log;
 
 // TODO: Auto-generated Javadoc
 /**
@@ -112,67 +110,6 @@
 	}
 
 	/**
-	 * Gets the lexicon relative to a given property.
-	 * 
-	 * @param property
-	 *            the property
-	 * 
-	 * @return the lexicon
-	 * 
-	 * @throws CqiClientException
-	 *             the cqi client exception
-	 */
-	@Override
-	public Lexicon getLexicon(Property property) throws CqiClientException {
-		// System.out.println("in "+this.getCqpId()+" look for cached lexicon "+property);
-		if (lexicons.containsKey(property.getName())
-				&& lexicons.get(property.getName()) != null) {
-			Log.finest(TXMCoreMessages.RETURNING_CACHED_LEXICON + this.name);
-			return lexicons.get(property.getName());
-		}
-		// System.out.println("not found");
-		Log.finest(TXMCoreMessages.LEXICON + this.name);
-		long start = System.currentTimeMillis();
-		int lexiconSize;
-		try {
-			lexiconSize = CorpusManager.getCorpusManager().getCqiClient()
-					.lexiconSize(property.getQualifiedName());
-		} catch (Exception e) {
-			throw new CqiClientException(e);
-		}
-
-		int[] ids = new int[lexiconSize];
-		for (int i = 0; i < ids.length; i++) {
-			ids[i] = i;
-		}
-
-		/*
-		 * String[] forms = null; try { forms =
-		 * CorpusManager.getCorpusManager().
-		 * getCqiClient().id2Str(property.getQualifiedName(), ids); } catch
-		 * (IOException e) { throw new CqiClientException(e); } catch
-		 * (CqiServerError e) { throw new CqiClientException(e); }
-		 */
-
-		int[] freqs;
-		try {
-			freqs = CorpusManager.getCorpusManager().getCqiClient().id2Freq(
-					property.getQualifiedName(), ids);
-		} catch (Exception e) {
-			throw new CqiClientException(e);
-		}
-
-		Lexicon lexicon = new Lexicon(this, property, freqs, ids);
-
-		long end = System.currentTimeMillis();
-		Log.finest(TXMCoreMessages.END_SUBCORPUS_LEXICON + this.name + TXMCoreMessages.MainCorpus_1 + (end - start));
-
-		// System.out.println("add in "+this.getCqpId()+"cache "+property.getName());
-		lexicons.put(property.getName(), lexicon);
-		return lexicon;
-	}
-
-	/**
 	 * Export.
 	 *
 	 * @param exportzip the exportzip
Index: tmp/org.txm.core/src/java/org/txm/searchengine/cqp/corpus/Subcorpus.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/searchengine/cqp/corpus/Subcorpus.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/searchengine/cqp/corpus/Subcorpus.java	(revision 313)
@@ -36,7 +36,6 @@
 import org.txm.annotation.repository.KnowledgeRepository;
 import org.txm.core.messages.TXMCoreMessages;
 import org.txm.functions.selection.SelectionResult;
-import org.txm.lexicon.core.corpusengine.cqp.Lexicon;
 import org.txm.objects.Base;
 import org.txm.objects.TxmObject;
 import org.txm.searchengine.cqp.AbstractCqiClient;
@@ -250,64 +249,6 @@
 		return true;
 	}
 
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.txm.searchengine.cqp.corpus.Corpus#getLexicon(org.txm
-	 * .searchengine.cqp.corpus.Property)
-	 */
-	@Override
-	public Lexicon getLexicon(Property property) throws CqiClientException {
-		// System.out.println("in "+this.getCqpId()+" look for cached lexicon "+property);
-		if (lexicons.containsKey(property.getName())
-				&& lexicons.get(property.getName()) != null) {
-			Log.finest(TXMCoreMessages.RETURNING_CACHED_LEXICON + this.name);
-			return lexicons.get(property.getName());
-		}
-		//System.out.println("not found");
-		Log.finest(TXMCoreMessages.SUBCORPUS_LEXICON + this.name);
-		long start = System.currentTimeMillis();
-		int[][] fdist = null;
-		Subcorpus tmp = null;
-		try {
-			tmp = createSubcorpus(new Query("[]"), "S"+getNextSubcorpusCounter(), true); //$NON-NLS-1$
-			if (tmp != null) {
-				fdist = CorpusManager.getCorpusManager().getCqiClient().fdist1(
-						tmp.getQualifiedCqpId(), 0,
-						ICqiClient.CQI_CONST_FIELD_MATCH, property.getName());
-			
-				dropSubcorpus(tmp); // drop the subcorpus only if correctly created
-			}
-			//System.out.println("nb lines: "+fdist.length);
-		} catch (Exception e) {
-			throw new CqiClientException(e);
-		} finally {
-			if (tmp != null) {
-				try {dropSubcorpus(tmp);}
-				catch (Exception e2) {}
-			}
-		}
-		int lexiconSize = fdist.length;
-
-		int[] freqs = new int[lexiconSize];
-		int[] ids = new int[lexiconSize];
-		for (int i = 0; i < fdist.length; i++) {
-			ids[i] = fdist[i][0];
-			freqs[i] = fdist[i][1];
-		}
-
-		Lexicon lexicon = new Lexicon(this, property, freqs, ids);
-
-		long end = System.currentTimeMillis();
-		Log.finest(TXMCoreMessages.END_SUBCORPUS_LEXICON + this.name
-				+ TXMCoreMessages.Subcorpus_1 + (end - start));
-
-		// System.out.println("add in "+this.getCqpId()+"cache "+property.getName());
-		lexicons.put(property.getName(), lexicon);
-		return lexicon;
-	}
-
 	// protected void finalize() throws Throwable {
 	// try {
 	// //
Index: tmp/org.txm.core/src/java/org/txm/importer/AddAttributeInXml.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/importer/AddAttributeInXml.java	(revision 0)
+++ tmp/org.txm.core/src/java/org/txm/importer/AddAttributeInXml.java	(revision 313)
@@ -0,0 +1,132 @@
+package org.txm.importer;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.txm.metadatas.Entry;
+import org.txm.utils.*;
+
+/**
+ * Add a attribute value map in a XML file
+ * Warning: if an attribute already exists its value won't be changed
+ */
+public class AddAttributeInXml extends StaxIdentityParser {
+	File xmlfile;
+	String tag;
+	List<Entry> attributes;
+	HashMap<String, String> attributesMap;
+	boolean result;
+
+//	public AddAttributeInXml(File xmlfile, String tag, List<Pair<String, String>> attributes) throws MalformedURLException, IOException, XMLStreamException
+//	{
+//		super(xmlfile.toURI().toURL());
+//		this.xmlfile = xmlfile;
+//		this.tag = tag;
+//		this.attributes = attributes;
+//	}
+
+	public AddAttributeInXml(File xmlfile, String tag, HashMap<String, String> attributesMap) throws MalformedURLException, IOException, XMLStreamException {
+		super(xmlfile.toURI().toURL());
+		this.xmlfile = xmlfile;
+		this.tag = tag;
+		this.attributesMap = attributesMap;
+	}
+
+	public AddAttributeInXml(File xmlfile, String tag,	ArrayList<org.txm.metadatas.Entry> attributes) throws MalformedURLException, IOException, XMLStreamException {
+		super(xmlfile.toURI().toURL());
+		this.xmlfile = xmlfile;
+		this.tag = tag;
+		this.attributes = attributes;
+	}
+
+	public boolean process(File outfile) throws XMLStreamException, IOException {
+		this.result = false;
+		boolean ret = super.process(outfile);
+		return this.result & ret;
+	}
+
+	/**
+	 * Rewrite the processStartElement() to update/add attributes
+	 * @throws XMLStreamException 
+	 */
+	public void processStartElement() throws XMLStreamException
+	{
+		String prefix = parser.getPrefix();
+		//TODO: uncomment for TXM 0.7.6 and later
+		//			if (INCLUDE == localname && XI == prefix) {
+		//				processingXInclude();
+		//				return;
+		//			}
+
+		if (prefix.length() > 0)
+			writer.writeStartElement(Nscontext.getNamespaceURI(prefix), localname);
+		else
+			writer.writeStartElement(localname);
+
+		for (int i = 0 ; i < parser.getNamespaceCount() ; i++) {
+			writer.writeNamespace(parser.getNamespacePrefix(i), parser.getNamespaceURI(i));
+		}
+
+		HashSet<String> exists = new HashSet<String>();
+		for (int i = 0 ; i < parser.getAttributeCount() ; i++) {
+			exists.add(parser.getAttributeLocalName(i));
+			writer.writeAttribute(parser.getAttributeLocalName(i), parser.getAttributeValue(i));
+		}
+		if (localname == tag && !stopInsertion) { // insert here
+			result = true;;
+			if (attributes != null) {
+				for (Pair<String, String> meta : attributes) {
+					if(stopAtFirst)
+						stopInsertion = true;
+					if(!exists.contains(meta.getFirst())) // I can add the new attribute
+						writer.writeAttribute(meta.getFirst(), meta.getSecond());
+				}
+			} else if (attributesMap != null) {
+				for (String name : attributesMap.keySet()) {
+					if (stopAtFirst)
+						stopInsertion = true;
+					if (!exists.contains(name)) // I can add the new attribute
+						writer.writeAttribute(name, attributesMap.get(name));
+				}
+			}
+		}
+	}
+
+	boolean stopAtFirst = false;
+	boolean stopInsertion = false;
+	public void onlyOneElement() {
+		stopAtFirst = true;
+	}
+
+	public static void main(String[] args)
+	{
+		try {
+			File xmlfile = new File("/home/mdecorde/xml/xmlçàé/essai.xml");
+			File temp = File.createTempFile("temp", ".xml", xmlfile.getParentFile());
+			String tag = "titre";
+			ArrayList<Pair<String, String>> metadatas = new ArrayList<Pair<String, String>>();
+			metadatas.add(new Pair<String, String>("name1", "newvalue1"));
+			metadatas.add(new Pair<String, String>("name2", "value2"));
+			metadatas.add(new Pair<String, String>("name3", "value3"));
+
+//			AddAttributeInXml builder = new AddAttributeInXml(xmlfile, tag, metadatas);
+//			builder.onlyOneElement();
+//			if (builder.process(temp)) {
+//				if (!(xmlfile.delete() && temp.renameTo(xmlfile))) {
+//					System.out.println("Warning can't rename file "+temp+" to "+xmlfile);
+//				}
+//			} else {
+//				System.out.println("Error during process");
+//			}
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
+	}
+}

Property changes on: tmp/org.txm.core/src/java/org/txm/importer/AddAttributeInXml.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.core/src/java/org/txm/importer/PersonalNamespaceContext.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/importer/PersonalNamespaceContext.java	(revision 0)
+++ tmp/org.txm.core/src/java/org/txm/importer/PersonalNamespaceContext.java	(revision 313)
@@ -0,0 +1,117 @@
+// 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: 2016-02-01 09:53:38 +0100 (Mon, 01 Feb 2016) $
+// $LastChangedRevision: 3101 $
+// $LastChangedBy: mdecorde $
+//
+package org.txm.importer;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+
+/**
+ * Instantiates a new personal namespace context.
+ *
+ * @author ayepdieu, mdecorde
+ * 
+ * Do correpondances between namespace and uri
+ */
+public class PersonalNamespaceContext implements NamespaceContext {
+	
+	public static HashMap<String, String> adress2name = new HashMap<String, String>();
+	public static HashMap<String, String> name2adress = new HashMap<String, String>();
+	static {
+		addNamespace("tei", "http://www.tei-c.org/ns/1.0");
+		addNamespace("me", "http://www.menota.org/ns/1.0");
+		addNamespace("bfm", "http://bfm.ens-lsh.fr/ns/1.0");
+		addNamespace("txm", "http://textometrie.org/1.0");
+		addNamespace("xi", "http://www.w3.org/2001/XInclude");
+		addNamespace("fn", "http://www.w3.org/2005/xpath-functions");
+		addNamespace("xhtml", "http://www.w3.org/1999/xhtml");
+		addNamespace("svg", "http://www.w3.org/2000/svg");
+		addNamespace(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI);
+	}
+	/*
+	String TEINS = "http://www.tei-c.org/ns/1.0"
+	String MENS = "http://www.menota.org/ns/1.0";
+	String BFMNS = "http://bfm.ens-lsh.fr/ns/1.0";
+	String TXMNS = "http://textometrie.org/1.0";
+	String XINS = "http://www.w3.org/2001/XInclude";
+	String FNNS = "http://www.w3.org/2005/xpath-functions";
+	String XHTMLNS = "http://www.w3.org/1999/xhtml";
+	String SVGNS = "http://www.w3.org/2000/svg"
+	String XMLNS = "http://www.w3.org/XML/1998/namespace"
+
+	String TEINSNAME = "tei"
+	String MENSNAME = "me";
+	String BFMNSNAME = "bfm";
+	String TXMNSNAME = "txm";
+	String XINSNAME = "xi";
+	String FNNSNAME = "fn";
+	String XHTMLNSNAME = "xhtml";
+	String SVGNSNAME = "svg"
+*/
+	public PersonalNamespaceContext() {
+		super();
+	}
+
+	public static void addNamespace(String name, String address) {
+		adress2name.put(address, name);
+		name2adress.put(name, address);
+	}
+	
+	/* (non-Javadoc)
+	 * @see javax.xml.namespace.NamespaceContext#getNamespaceURI(java.lang.String)
+	 */
+	public String getNamespaceURI(String prefix) {
+		if (!name2adress.containsKey(prefix)) return XMLConstants.NULL_NS_URI;
+		return name2adress.get(prefix);
+	}
+
+	private static String NONE = "";
+	/**
+	 * 
+	 * @param uri the uri
+	 * @return the prefix
+	 */
+	public String getPrefix(String uri) {
+		
+		if (uri == null) return NONE;
+		if (!adress2name.containsKey(uri)) return NONE;
+		return adress2name.get(uri);
+	}
+
+	/**
+	 * This method isn't necessary for XPath processing either.
+	 *
+	 * @param uri the uri
+	 * @return the prefixes
+	 */
+	public Iterator getPrefixes(String uri) {
+		throw new UnsupportedOperationException();
+	}
+}
\ No newline at end of file

Property changes on: tmp/org.txm.core/src/java/org/txm/importer/PersonalNamespaceContext.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.core/src/java/org/txm/importer/ImportKeys.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/importer/ImportKeys.java	(revision 0)
+++ tmp/org.txm.core/src/java/org/txm/importer/ImportKeys.java	(revision 313)
@@ -0,0 +1,16 @@
+package org.txm.importer;
+
+public class ImportKeys {
+
+	public static final String CLEAN = "clean.directories";
+	public static final String TTMODEL = "annotate.model";
+	public static final String TTANNOTATE = "annotate.run";
+	public static final String LANG = "lang";
+	
+	public static final String MULTITHREAD = "multithread";
+	public static final String DEBUG = "debug";
+	public static final String UPDATECORPUS = "corpus.update";
+	
+	public static final String NORMALISEANAVALUES = "normalize.ana.values";
+	public static final String NORMALISEATTRIBUTEVALUES = "normalize.attribute.values";
+}
\ No newline at end of file

Property changes on: tmp/org.txm.core/src/java/org/txm/importer/ImportKeys.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.core/src/java/org/txm/importer/StaxIdentityParser.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/importer/StaxIdentityParser.java	(revision 0)
+++ tmp/org.txm.core/src/java/org/txm/importer/StaxIdentityParser.java	(revision 313)
@@ -0,0 +1,393 @@
+package org.txm.importer;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+public class StaxIdentityParser {
+	/** The input */
+	protected URL inputurl;
+	protected InputStream inputData;
+	protected XMLInputFactory factory;
+	protected XMLStreamReader parser;
+
+	/** The output. */
+	protected XMLOutputFactory outfactory = XMLOutputFactory.newInstance();
+	protected BufferedOutputStream output;
+	protected XMLStreamWriter writer;
+
+	public static String TXMNS = "http://textometrie.org/1.0";
+	public static String TXM = "txm";
+	public static String TEINS = "http://www.tei-c.org/ns/1.0";
+	public static String TEI = "tei";
+	protected static PersonalNamespaceContext Nscontext = new PersonalNamespaceContext();
+
+	//protected StringBuilder currentXPath = new StringBuilder("/")
+	protected String localname;
+	int processingXInclude = 0;
+
+	public StaxIdentityParser(File infile) throws IOException, XMLStreamException {
+		this(infile.toURI().toURL());
+	}
+
+	public StaxIdentityParser(URL inputurl) throws IOException, XMLStreamException {
+		this.inputurl = inputurl;
+		this.inputData = inputurl.openStream();
+		this.factory = XMLInputFactory.newInstance();
+		this.parser = factory.createXMLStreamReader(inputData);
+	}
+
+	protected void before() {
+
+	}
+
+	protected void after() throws XMLStreamException, IOException {
+		factory = null;
+		if (parser !=null) parser.close();
+		writer.flush();
+		if (writer != null) writer.close();
+		if (inputData != null) inputData.close();
+		writer = null;
+		parser = null;
+	}
+
+	protected void closeForError() throws XMLStreamException {
+		parser.close();
+	}
+
+	/**
+	 * Creates the output.
+	 *
+	 * @param outfile the outfile
+	 * @return true, if successful
+	 */
+	private boolean createOutput(File f) {
+		try {
+			if (writer != null) // process from a file
+				writer.close();
+			if (output != null) // process from a file
+				output.close();
+
+			output = new BufferedOutputStream(new FileOutputStream(f), 16*1024);
+
+			writer = outfactory.createXMLStreamWriter(output, "UTF-8");//create a new file
+			writer.setNamespaceContext(Nscontext);
+			return true;
+		} catch (Exception e) {
+			System.out.println("Error: create output of "+f+": "+e);
+			return false;
+		}
+	}
+
+	public boolean process(File outfile) throws XMLStreamException, IOException
+	{
+		if (!createOutput(outfile))
+			return false;
+
+		writer.writeStartDocument("UTF-8", "1.0");
+		writer.writeCharacters("\n");
+		boolean ret = process(writer);
+		if (writer != null) { // process from a file
+			writer.close();
+		}
+		if (output != null) { // process from a file
+			//	output.flush()
+			output.close();
+		}
+
+		if (parser != null) {
+			try {parser.close();} catch(Exception e){System.out.println("parser exep: "+e); return false;}
+		}
+		return ret;
+	}
+
+	public final static String SLASH = "/";
+	public boolean process(XMLStreamWriter awriter) throws XMLStreamException, IOException
+	{
+		this.writer = awriter;
+		//if (processingXInclude == 0) {
+		before(); // if you need to do something before reading the xml
+		//}
+		try {
+			for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {
+				switch (event) {
+				case XMLStreamConstants.NAMESPACE:
+					processNamespace();
+					break;
+				case XMLStreamConstants.START_ELEMENT:
+					localname = parser.getLocalName();
+					//currentXPath.append(SLASH)
+					processStartElement();
+					break;		
+				case XMLStreamConstants.CHARACTERS:
+					processCharacters();
+					break;
+				case XMLStreamConstants.END_ELEMENT:
+					localname = parser.getLocalName();
+					processEndElement();
+					//currentXPath.substring(0, currentXPath.length() - localname.length() -1)
+					break;
+				case XMLStreamConstants.PROCESSING_INSTRUCTION:
+					processProcessingInstruction();
+					break;
+				case XMLStreamConstants.DTD:
+					processDTD();
+					break;
+				case XMLStreamConstants.CDATA:
+					processCDATA();
+					break;
+				case XMLStreamConstants.COMMENT:
+					processComment();
+					break;
+				case XMLStreamConstants.END_DOCUMENT:
+					processEndDocument();
+					break;
+				case XMLStreamConstants.ENTITY_REFERENCE:
+					processEntityReference();
+					break;
+				}
+			}
+		} catch(Exception e) {
+			System.out.println("Unexpected error while parsing file "+inputurl+" : "+e);
+			System.out.println("Location line: "+parser.getLocation().getLineNumber()+" character: "+parser.getLocation().getColumnNumber());
+			org.txm.utils.logger.Log.printStackTrace(e);
+			//e.printStackTrace();
+			if (writer != null) writer.close();
+			if (output != null) output.close();
+			parser.close();
+			return false;
+		}
+		//if (processingXInclude == 0) {
+		after(); // if you need to do something before closing the parser();
+		//}
+		return true;
+	}
+
+	/**
+	 * The start element has already been written
+	 * @param tagname
+	 * @throws XMLStreamException 
+	 * @throws IOException 
+	 */
+	public void goToEnd(String tagname) throws XMLStreamException, IOException {
+		//System.out.println("start gotoend $tagname"
+		int elements = 1;
+		try {
+			for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {
+				//System.out.println("event "+event
+				switch (event) {
+				case XMLStreamConstants.NAMESPACE:
+					processNamespace();
+					break;
+				case XMLStreamConstants.START_ELEMENT:
+					elements++;
+					localname = parser.getLocalName();
+					//currentXPath.append(SLASH)
+					_processStartElement();
+					break;
+				case XMLStreamConstants.CHARACTERS:
+					processCharacters();
+					break;
+				case XMLStreamConstants.PROCESSING_INSTRUCTION:
+					processProcessingInstruction();
+					break;
+				case XMLStreamConstants.DTD:
+					processDTD();
+					break;
+				case XMLStreamConstants.CDATA:
+					processCDATA();
+					break;
+				case XMLStreamConstants.COMMENT:
+					processComment();
+					break;
+				case XMLStreamConstants.END_ELEMENT:
+					elements--;
+					localname = parser.getLocalName();
+					//currentXPath.substring(0, currentXPath.length() - localname.length() -1)
+					writer.writeEndElement();
+					if (elements == 0 && localname == tagname)
+						return;
+					break;
+				case XMLStreamConstants.END_DOCUMENT:
+					processEndDocument();
+					break;
+				case XMLStreamConstants.ENTITY_REFERENCE:
+					processEntityReference();
+					break;
+				}
+			}
+		} catch(Exception e) {
+			System.out.println("Error while parsing file "+inputurl);
+			System.out.println("Location "+parser.getLocation());
+			org.txm.utils.logger.Log.printStackTrace(e);
+			output.close();
+			parser.close();
+			return;
+		}
+	}
+
+	public String getLocation() {
+		if (parser != null)
+			return "Line: "+parser.getLocation().getLineNumber()+" Col: "+parser.getLocation().	getColumnNumber();
+		return null;
+	}
+
+	protected void processNamespace() throws XMLStreamException {
+		writer.writeNamespace(parser.getPrefix(), parser.getNamespaceURI());
+	}
+
+	public static final String INCLUDE = "include";
+	public static final String XI = "xi";
+
+	protected void processStartElement() throws XMLStreamException, IOException
+	{
+		String prefix = parser.getPrefix();
+		if (INCLUDE == localname && XI == prefix) {
+			processXInclude();
+		} else {
+			if (prefix != null && prefix.length() > 0)
+				writer.writeStartElement(Nscontext.getNamespaceURI(prefix), localname);
+			else
+				writer.writeStartElement(localname);
+
+			for (int i = 0 ; i < parser.getNamespaceCount() ; i++) {
+				writer.writeNamespace(parser.getNamespacePrefix(i), parser.getNamespaceURI(i));
+			}
+
+			writeAttributes();
+		}
+	}
+
+	private void _processStartElement() throws XMLStreamException, IOException
+	{
+		String prefix = parser.getPrefix();
+		if (INCLUDE == localname && XI == prefix) {
+			processXInclude();
+		} else {
+			if (prefix != null && prefix.length() > 0)
+				writer.writeStartElement(Nscontext.getNamespaceURI(prefix), localname);
+			else
+				writer.writeStartElement(localname);
+
+			for (int i = 0 ; i < parser.getNamespaceCount() ; i++) {
+				writer.writeNamespace(parser.getNamespacePrefix(i), parser.getNamespaceURI(i));
+			}
+
+			writeAttributes();
+		}
+	}
+
+	protected void writeAttributes() throws XMLStreamException {
+		for (int i = 0 ; i < parser.getAttributeCount() ; i++) {
+			writeAttribute(parser.getAttributePrefix(i), parser.getAttributeLocalName(i), parser.getAttributeValue(i));
+		}
+	}
+
+	protected void writeAttribute(String prefix, String name, String value) throws XMLStreamException {
+		if (prefix != null && prefix.length() > 0)
+			writer.writeAttribute(prefix+":"+name, value);
+		else
+			writer.writeAttribute(name, value);
+	}
+
+	protected void processCharacters() throws XMLStreamException
+	{
+		writer.writeCharacters(parser.getText());
+	}
+
+	protected void processProcessingInstruction() throws XMLStreamException
+	{
+		writer.writeProcessingInstruction(parser.getPITarget(), parser.getPIData());
+	}
+
+	protected void processDTD() throws XMLStreamException
+	{
+		writer.writeDTD(parser.getText());
+	}
+
+	protected void processCDATA() throws XMLStreamException
+	{
+		writer.writeCData(parser.getText())	;
+	}
+
+	protected void processComment() throws XMLStreamException
+	{
+		writer.writeComment(parser.getText());
+	}
+
+	protected void processEndElement() throws XMLStreamException
+	{
+		if (localname == INCLUDE && parser.getPrefix() == XI) {
+			// nothing !!
+		} else {
+			writer.writeEndElement();
+		}
+	}
+
+	protected void processEndDocument() throws XMLStreamException {
+		writer.writeEndDocument();
+	}
+
+	protected void processEntityReference() throws XMLStreamException {
+		writer.writeEntityRef(parser.getLocalName());
+	}
+	/**
+	 * Process the XInclude elements
+	 * @throws IOException 
+	 * @throws XMLStreamException 
+	 */
+	protected void processXInclude() throws XMLStreamException, IOException {
+		String url = parser.getAttributeValue(null, "href"); // relative only
+		File driver = new File(inputurl.getFile());
+		File ref = new File(driver.getParent(), url);
+		if (ref.exists()) {
+			URL includeurl = ref.toURI().toURL();
+			// save variables before killing them
+			System.out.println("process xi include: "+ref);
+			XMLStreamReader parserSave = this.parser; // back up current parser
+			InputStream xiIncludeInputData = includeurl.openStream();
+			XMLStreamReader xiIncludeParser = factory.createXMLStreamReader(xiIncludeInputData);
+			parser = xiIncludeParser;
+			processingXInclude++; // to avoid recalling before & after methods
+			this.process(writer);
+			processingXInclude--; // end of XInclude processing
+			this.parser = parserSave; // restore parser
+		} else {
+			System.out.println("Warning referenced file: $ref does not exists");
+		}
+	}
+
+	public static void main(String[] args)
+	{
+		try {
+			File input = new File("/home/mdecorde/xml/xiinclude/master.xml");
+			File output = new File("/home/mdecorde/xml/xiinclude/merged.xml");
+			if (!(input.exists() && input.canRead())) {
+				System.out.println("cannot found $input");
+				return;
+			}
+			StaxIdentityParser builder;
+
+			builder = new StaxIdentityParser(input.toURI().toURL());
+
+			if (builder.process(output)) {
+				System.out.println("success ? "+ValidateXml.test(output));
+			} else {
+				System.out.println("failure !");
+			}
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+}
\ No newline at end of file

Property changes on: tmp/org.txm.core/src/java/org/txm/importer/StaxIdentityParser.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.core/src/java/org/txm/importer/ResolveXInclude.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/importer/ResolveXInclude.java	(revision 0)
+++ tmp/org.txm.core/src/java/org/txm/importer/ResolveXInclude.java	(revision 313)
@@ -0,0 +1,106 @@
+// 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:$
+// $LastChangedRevision:$
+// $LastChangedBy:$ 
+//
+package org.txm.importer;
+
+import java.io.File;
+import java.io.FileOutputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Document;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ResolveXInclude.
+ */
+class ResolveXInclude {
+	
+	/**
+	 * Resolve.
+	 *
+	 * @param xmlfile the xmlfile
+	 * @param outfile the outfile
+	 * @return true, if successful
+	 * @throws Exception the exception
+	 */
+	public static boolean resolve(File xmlfile, File outfile) throws Exception
+	{
+		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+		//factory.setXIncludeAware(true);
+		factory.setNamespaceAware(true);
+		DocumentBuilder docBuilder = factory.newDocumentBuilder();
+//		if (!docBuilder.isXIncludeAware()) {
+//			throw new IllegalStateException();
+//		}
+		/*docBuilder.setEntityResolver(new EntityResolver() {
+					@Override
+					public InputSource resolveEntity(String publicId, String systemId)
+					throws SAXException, IOException {
+						if (systemId.endsWith("include.txt")) {
+							return new InputSource(includeStream);
+						}
+						return null;
+					}
+				});*/
+		Document doc = docBuilder.parse(xmlfile);
+		// print result
+		Source source = new DOMSource(doc);
+		Result result = new StreamResult(new FileOutputStream(outfile));
+		TransformerFactory transformerFactory = new net.sf.saxon.TransformerFactoryImpl();
+		Transformer transformer;
+
+		transformer = transformerFactory.newTransformer();
+		transformer.transform(source, result);		
+		return true;
+	}
+	
+	/**
+	 * The main method.
+	 *
+	 * @param args the arguments
+	 */
+	public static void main(String[] args)
+	{
+		String userdir= System.getProperty("user.home");
+		File xmlfile = new File(userdir, "xml/queen/queen/Texts/driver.xml");
+		File outfile = new File(userdir, "xml/queen/queen.xml");
+		try {
+			ResolveXInclude.resolve(xmlfile, outfile);
+		} catch (Exception e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			System.out.println("Fail to resolve xinclude");
+		}
+	}
+}

Property changes on: tmp/org.txm.core/src/java/org/txm/importer/ResolveXInclude.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.core/src/java/org/txm/importer/cwb/ReadRegistryFile.groovy
===================================================================
--- tmp/org.txm.core/src/java/org/txm/importer/cwb/ReadRegistryFile.groovy	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/importer/cwb/ReadRegistryFile.groovy	(revision 313)
@@ -1,70 +0,0 @@
-package org.txm.importer.cwb;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-public class ReadRegistryFile {
-	File registryFile;
-	ArrayList<String> pAttributes;
-	ArrayList<String> sAttributes;
-	HashMap<String, ArrayList<String>> sattrs;
-	
-	public ReadRegistryFile(File registryFile) {
-		this.registryFile = registryFile;
-		read();
-	}
-	
-	public void read() {
-		pAttributes = [];
-		sAttributes = [];
-		sattrs = [:]
-		
-		registryFile.eachLine(System.getProperty("file.encoding")) { line ->
-			line = line.trim(); // remove first tab
-
-			if (line.startsWith("ATTRIBUTE ")) {
-				line = line.substring(10)
-				pAttributes << line
-			} else if (line.startsWith("STRUCTURE ")) {
-				line = line.substring(9)
-				line = line.replaceAll("\\#.*", "")
-				line = line.trim()
-				def split = line.split("_", 2);
-				//println split
-				if (split.length == 1) { // sattr decl
-					sattrs[split[0]] = []
-				} else {
-					sattrs[split[0]] << split[1]
-				}
-			}
-		}
-		
-		for (String sattr : sattrs.keySet()) {
-			String tmp = ""+sattr+":0"
-			for (String attr : sattrs[sattr])
-				tmp += "+"+attr
-			sAttributes << tmp
-		}
-	}
-	
-	public ArrayList<String> getPAttributes() {
-		return pAttributes;
-	}
-	
-	public ArrayList<String> getSAttributes() {
-		return sAttributes;
-	}
-	
-	public def getSAttributesMap() {
-		return sattrs;
-	}
-	
-	public static void main(String[] args) {
-		File registry = new File("/home/matt/xml/wtc/discours");
-		ReadRegistryFile reader = new ReadRegistryFile(registry);
-		System.out.println("pAttributes: "+reader.getPAttributes());
-		System.out.println("sAttributes Map: "+reader.getSAttributesMap());
-		System.out.println("sAttributes: "+reader.getSAttributes());
-	}
-}
Index: tmp/org.txm.core/src/java/org/txm/importer/cwb/ReadRegistryFile.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/importer/cwb/ReadRegistryFile.java	(revision 0)
+++ tmp/org.txm.core/src/java/org/txm/importer/cwb/ReadRegistryFile.java	(revision 313)
@@ -0,0 +1,71 @@
+package org.txm.importer.cwb;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.txm.utils.io.IOUtils;
+
+public class ReadRegistryFile {
+	File registryFile;
+	ArrayList<String> pAttributes;
+	ArrayList<String> sAttributes;
+	HashMap<String, ArrayList<String>> sattrs;
+	
+	public ReadRegistryFile(File registryFile) {
+		this.registryFile = registryFile;
+		read();
+	}
+	
+	public void read() {
+		pAttributes = new ArrayList();
+		sAttributes = new ArrayList();
+		sattrs = new HashMap<String, ArrayList<String>>();
+		for (String line : IOUtils.getLines(registryFile, System.getProperty("file.encoding"))) {
+			line = line.trim(); // remove first tab
+
+			if (line.startsWith("ATTRIBUTE ")) {
+				line = line.substring(10);
+				pAttributes.add(line);
+			} else if (line.startsWith("STRUCTURE ")) {
+				line = line.substring(9);
+				line = line.replaceAll("\\#.*", "");
+				line = line.trim();
+				String[] split = line.split("_", 2);
+				//println split
+				if (split.length == 1) { // sattr decl
+					sattrs.put(split[0], new ArrayList<String>());
+				} else {
+					sattrs.get(split[0]).add(split[1]);
+				}
+			}
+		}
+		
+		for (String sattr : sattrs.keySet()) {
+			String tmp = ""+sattr+":0";
+			for (String attr : sattrs.get(sattr))
+				tmp += "+"+attr;
+			sAttributes.add(tmp);
+		}
+	}
+	
+	public ArrayList<String> getPAttributes() {
+		return pAttributes;
+	}
+	
+	public ArrayList<String> getSAttributes() {
+		return sAttributes;
+	}
+	
+	public HashMap<String, ArrayList<String>> getSAttributesMap() {
+		return sattrs;
+	}
+	
+	public static void main(String[] args) {
+		File registry = new File("/home/matt/xml/wtc/discours");
+		ReadRegistryFile reader = new ReadRegistryFile(registry);
+		System.out.println("pAttributes: "+reader.getPAttributes());
+		System.out.println("sAttributes Map: "+reader.getSAttributesMap());
+		System.out.println("sAttributes: "+reader.getSAttributes());
+	}
+}
Index: tmp/org.txm.core/src/java/org/txm/importer/cwb/CwbEncode.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/importer/cwb/CwbEncode.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/importer/cwb/CwbEncode.java	(revision 313)
@@ -37,6 +37,7 @@
 import org.eclipse.osgi.util.NLS;
 import org.txm.Toolbox;
 import org.txm.core.messages.TXMCoreMessages;
+import org.txm.core.preferences.TBXPreferences;
 import org.txm.searchengine.cqp.clientExceptions.ServerNotFoundException;
 import org.txm.stat.utils.ConsoleProgressBar;
 import org.txm.utils.OSDetector;
@@ -176,7 +177,7 @@
 		 */
 
 		// Warning !! for WINDOWS ONLY the "" value does not work with the ProcessBuilder we must set the value to "\"\""
-		String empty_value_code = Toolbox.getParam(Toolbox.CQP_EMPTY_VALUE_CODE);
+		String empty_value_code = Toolbox.getParam(TBXPreferences.CQP_EMPTY_VALUE_CODE);
 		if (OSDetector.isFamilyWindows()) {
 			if (empty_value_code == null) empty_value_code = "\"\"";
 			empty_value_code = empty_value_code.trim();
Index: tmp/org.txm.core/src/java/org/txm/importer/cwb/CwbProcess.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/importer/cwb/CwbProcess.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/importer/cwb/CwbProcess.java	(revision 313)
@@ -37,6 +37,7 @@
 
 import org.apache.commons.lang.StringUtils;
 import org.txm.core.messages.TXMCoreMessages;
+import org.txm.core.preferences.TBXPreferences;
 import org.txm.searchengine.cqp.clientExceptions.ServerNotFoundException;
 import org.txm.utils.logger.Log;
 
@@ -241,7 +242,7 @@
 	 */
 	public static String getCWBLocation()
 	{
-		String cwbLoc = org.txm.Toolbox.getParam(org.txm.Toolbox.CQI_SERVER_PATH_TO_CQPLIB)+File.separator;
+		String cwbLoc = org.txm.Toolbox.getParam(TBXPreferences.CQI_SERVER_PATH_TO_CQPLIB)+File.separator;
 
 		if (!new File(cwbLoc).exists()) {
 			System.out.println(TXMCoreMessages.CwbProcess_5+cwbLoc);
Index: tmp/org.txm.core/src/java/org/txm/importer/ApplyXsl2.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/importer/ApplyXsl2.java	(revision 0)
+++ tmp/org.txm.core/src/java/org/txm/importer/ApplyXsl2.java	(revision 313)
@@ -0,0 +1,577 @@
+// 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.
+
+//
+// This file is part of the TXM platform.
+//
+// The TXM platform is free software: you can redistribute it and/or modif y
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 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: 2011-11-03 17:59:23 +0100 (jeu., 03 nov. 2011) $
+// $LastChangedRevision: 2051 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.importer;
+
+/**
+ * @author mdecorde
+ */
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.logging.Level;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import net.sf.saxon.TransformerFactoryImpl;
+
+import org.txm.stat.utils.ConsoleProgressBar;
+import org.txm.utils.Diff;
+import org.txm.utils.io.FileCopy;
+import org.txm.utils.io.IOUtils;
+import org.txm.utils.logger.Log;
+import org.txm.utils.saxon.SaxonNodeSet;
+
+// TODO: Auto-generated Javadoc
+/**
+ * apply a xsl file to a file : use process(File infile, File outfile, String[]
+ * args) to apply the xslt file loaded by the constructor args =
+ * ["name1","value1","name2",value2, ...]
+ * 
+ * @author mdecorde
+ */
+
+public class ApplyXsl2 {
+
+	//	/** The proc. */
+	//	private Processor proc;
+	//	
+	//	/** The comp. */
+	//	private XsltCompiler comp;
+	//	
+	//	/** The exp. */
+	//	private XsltExecutable exp;
+	//
+	//	/** The source. */
+	//	private XdmNode source;
+	//	
+	//	/** The out. */
+	//	private Serializer out;
+	//	
+	//	/** The trans. */
+	//	private XsltTransformer trans;
+
+	net.sf.saxon.TransformerFactoryImpl tFactory;
+	Transformer transformer;
+	private HashMap<String, Object> params = new HashMap<String, Object>();
+	private File xsltfile;
+	boolean debug = false;
+
+	/**
+	 * initialize with the xslt file.
+	 *
+	 * @param xsltfile the xsltfile
+	 * @throws TransformerConfigurationException 
+	 */
+	public ApplyXsl2(String xsltfile) throws TransformerConfigurationException {
+
+		System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
+
+		this.xsltfile = new File(xsltfile);
+		tFactory = new TransformerFactoryImpl();
+		transformer = tFactory.newTransformer(new StreamSource(this.xsltfile));
+		
+
+		//Log.info("new tFactory: "+tFactory);
+		//Log.info("new transformer: "+transformer);
+	}
+
+	/**
+	 * initialize with the xslt file.
+	 *
+	 * @param xsltfile the xsltfile
+	 * @throws TransformerConfigurationException 
+	 */
+	public ApplyXsl2(File xsltfile) throws TransformerConfigurationException {
+		this.xsltfile = xsltfile;
+
+		System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
+
+		tFactory = new net.sf.saxon.TransformerFactoryImpl();
+		Log.info("new tFactory: "+tFactory);
+		tFactory.getConfiguration().registerExtensionFunction(new SaxonNodeSet());
+		Log.info("ApplyXsl2 from file: "+xsltfile);
+		reload();
+		Log.info("new transformer: "+transformer);
+	}
+
+	/**
+	 * Set a xslt param.
+	 *
+	 * @param name the name
+	 * @param value the value
+	 * @return true, if successful
+	 */
+	public boolean setParams(HashMap<String, String> params) {
+		boolean b = true;
+		for (String k : params.keySet()) b = b & setParam(k, params.get(k));
+		return b;
+	}
+	
+	public void setDebug(boolean d) {
+		this.debug = d;
+	}
+	
+	/**
+	 * Set a xslt param.
+	 *
+	 * @param name the name
+	 * @param value the value
+	 * @return true, if successful
+	 */
+	public boolean setParam(String name, Object value) {
+		if (transformer != null) {
+			transformer.setParameter(name, value);
+			params.put(name, value);
+			return true;
+		} else
+			return false;
+	}
+
+	/**
+	 * Set a xslt param.
+	 *
+	 * @param name the name
+	 * @param value the value
+	 * @return true, if successful
+	 */
+	@Deprecated
+	public boolean SetParam(String name, Object value) {
+		if (transformer != null) {
+			transformer.setParameter(name, value);
+			params.put(name, value);
+			return true;
+		} else
+			return false;
+	}
+	public boolean resetParams() {
+		if (transformer != null) {
+			transformer.reset();
+			params.clear();
+		} else
+			return false;
+		return true;
+	}
+
+	/**
+	 * Force java to clean memory after processing a xslt. If not we might catch
+	 * a JavaHeapspace Exception
+	 * @throws TransformerConfigurationException 
+	 * 
+	 */
+	private void cleanMemory() throws TransformerConfigurationException {
+		reload();
+		for (String name : params.keySet()) { // reload parameters
+			transformer.setParameter(name, params.get(name));
+		}
+	}
+
+	private boolean reload() throws TransformerConfigurationException {
+		//try {
+			transformer = null;
+			transformer = tFactory.newTransformer(new StreamSource(xsltfile));
+//		} catch (TransformerConfigurationException e) {
+//			org.txm.utils.logger.Log.printStackTrace(e);
+//			Log.severe("Error while reloading transformer: "+e);
+//			System.out.println("Error while reloading transformer: "+e);
+//			return false;
+//		}
+		return true;
+	}
+
+	/**
+	 * Process files with xslt args.
+	 *
+	 * @param xmlinfile file to be processed
+	 * @param xmloutfile output file
+	 * @param args xslt args ["arg1","arg1value","arg2","arg2value"...]
+	 * @return true, if successful
+	 * @throws TransformerException 
+	 * @throws FileNotFoundException 
+	 */
+
+	public boolean process(String xmlinfile, String xmloutfile, String[] args) throws Exception {
+		File infile = new File(xmlinfile);
+		File outfile = new File(xmloutfile);
+		
+		//System.out.println(xmlinfile+" Params: "+Arrays.toString(args));
+		for (int i = 0; i < args.length; i = i + 2) {
+			if (!this.setParam(args[i], args[i + 1]))
+				return false;
+		}
+
+		transformer.transform(new StreamSource(xmlinfile), new StreamResult(new BufferedOutputStream(new FileOutputStream(xmloutfile))));
+		cleanMemory(); // save memory
+		// System.out.println("Done");
+		return true;
+	}
+
+	/**
+	 * Process files without xslt args.
+	 *
+	 * @param xmlinfile the xmlinfile
+	 * @param xmloutfile the xmloutfile
+	 * @return true, if successful
+	 * @throws TransformerException 
+	 * @throws IOException 
+	 */
+	public boolean process(File xmlinfile, File xmloutfile) throws TransformerException, IOException {
+		
+		// bufferize result in a String
+		StringWriter strWriter = new StringWriter();
+		StreamResult out = new StreamResult(strWriter);
+		
+		File tmp_dir = null;
+		File inputfile_copy = null;
+		
+		if (debug) {
+			//FIXME: old version
+			//File inputfile_copy = new File("/tmp", xmlinfile.getName());
+			//FIXME: new version
+			tmp_dir = new File(xmlinfile.getParentFile().getAbsolutePath() + "/tmp");
+			tmp_dir.mkdirs();
+			tmp_dir.deleteOnExit();
+			
+			inputfile_copy = new File(tmp_dir, xmlinfile.getName());
+			
+			System.out.println("copying inputfile to: "+inputfile_copy.getAbsolutePath());
+			//FIXME: old version
+			//inputfile_copy.delete();
+			//FIXME: new version
+			inputfile_copy.deleteOnExit();
+			FileCopy.copy(xmlinfile, inputfile_copy);
+			
+		}
+
+		transformer.transform(new StreamSource(xmlinfile), out);
+
+		// then write the result in the result file
+		if (xmloutfile != null) {
+			BufferedWriter w = new BufferedWriter(new FileWriter(xmloutfile));
+			w.write(strWriter.toString());
+			w.close();
+			
+			if (debug && inputfile_copy != null) {
+				//FIXME: old version
+				//File inputfile_copy = new File("/tmp", xmlinfile.getName());
+				
+				String s = Diff.diffFile(inputfile_copy, xmloutfile);
+				if (s.length() > 0) { // for ultra debug?
+					System.out.println("Result "+xmlinfile.getName()+" VS "+ xmloutfile.getName()+" diff="+s);
+				} else {
+					System.out.println("Warning: no diff between "+inputfile_copy+" and "+ xmloutfile);
+				}
+			}
+		}
+
+		cleanMemory();
+		return true;
+	}
+
+	/**
+	 * Transform files and select files : nor hidden and nor technical (DTD, XSL, etc.)
+	 * 
+	 * @param xslFile
+	 * @param srcdir
+	 * @param outdir
+	 * @return
+	 * @throws TransformerException
+	 * @throws IOException 
+	 */
+	public static boolean processImportSources(File xslFile, File srcdir, File outdir) throws TransformerException, IOException
+	{
+		HashMap<String, Object> params = new HashMap<String, Object>();
+		return processImportSources(xslFile, srcdir, outdir, params);
+	}
+
+	/**
+	 * Transform files and select files : nor hidden and nor technical (DTD, XSL, etc.)
+	 * 
+	 * @param xslFile
+	 * @param srcdir
+	 * @param outdir
+	 * @param params XSL parameters
+	 * @return
+	 * @throws TransformerException
+	 * @throws IOException 
+	 */
+	public static boolean processImportSources(File xslFile, File srcdir, File outdir, HashMap<String, Object> params) throws TransformerException, IOException
+	{
+		return processImportSources(xslFile, srcdir, outdir, params, false);
+	}
+
+	public static File[] listFiles(File srcdir) {
+		File[] files = srcdir.listFiles(new FileFilter() {
+			@Override
+			public boolean accept(File f) {
+				String name = f.getName();
+				if (f.isHidden() || f.isDirectory()) return false;
+				if (name.endsWith(".properties")) return false;
+				if (name.equals("import.xml")) return false;
+				if (name.endsWith(".csv")) return false;
+				if (name.endsWith(".dtd")) return false;
+				if (name.endsWith(".xsl")) return false;
+				if (name.endsWith("~")) return false;
+				if (name.endsWith(".bak")) return false;
+				if (name.startsWith(".")) return false;
+				return true;
+			}
+		});
+		return files;
+	}
+	
+	/**
+	 * Transform files and select files : nor hidden and nor technical (DTD, XSL, etc.)
+	 * 
+	 * @param xslFile
+	 * @param srcdir
+	 * @param outdir
+	 * @param params XSL parameters
+	 * @return
+	 * @throws TransformerException
+	 * @throws IOException 
+	 */
+	public static boolean processImportSources(File xslFile, File srcdir, File outdir, HashMap<String, Object> params, boolean deleteOutput) throws TransformerException, IOException
+	{
+		outdir.mkdir();
+		if (xslFile.exists()) {
+			ApplyXsl2 builder = new ApplyXsl2(xslFile);
+			boolean debug = Log.getLevel().intValue() < Level.WARNING.intValue();
+			if (debug) {
+				builder.setDebug(true);
+				System.out.println("Debug mode enabled.");
+			}
+			if (!params.containsKey("output-directory"))
+				params.put("output-directory", outdir.getAbsoluteFile().toURI().toString());
+			
+			for (String name : params.keySet())
+				builder.setParam(name, params.get(name));
+			
+			File[] files = listFiles(srcdir); // get files XSL compatible
+			if (files == null) return false;
+			
+			System.out.println("-- Applying "+xslFile+" XSL to "+files.length+" files with parameters: "+params+" on directory "+srcdir+" result written in "+outdir);
+
+			ConsoleProgressBar cpb = new ConsoleProgressBar(files.length);
+			for (File f : files) {
+				String name = f.getName();
+
+				cpb.tick();
+				File outfile = new File(outdir, name);
+				
+				if (!f.getAbsolutePath().equals(outfile.getAbsolutePath()) && f.lastModified() <= outfile.lastModified()) {
+					if (debug) System.out.println("skipped: "+f);
+					continue; // input file is older than output file
+				}
+				
+				if (deleteOutput) outfile = null;
+
+				if (!builder.process(f, outfile)) {
+					System.out.println("Failed to process file "+ f);
+					if (outfile != null) outfile.delete();
+				}
+			}
+			System.out.println("");
+			return true;
+		} else {
+			System.out.println("XSL file does not exists: "+ xslFile);
+		}
+		return false;
+	}
+
+	/**
+	 * Transform files and select files : nor hidden and nor technical (DTD, XSL, etc.)
+	 * 
+	 * Apply one XSL, XML files are replaced 
+	 * 
+	 * @param xslFile
+	 * @param srcdir
+	 * @param outdir
+	 * @param params XSL parameters
+	 * @return
+	 * @throws TransformerException
+	 * @throws IOException 
+	 */
+	public static boolean processImportSources(File xslFile, File[] files, HashMap<String, Object> params) throws TransformerException, IOException
+	{
+		if (xslFile.exists()) {
+			ApplyXsl2 builder = new ApplyXsl2(xslFile);
+			for(String name : params.keySet())
+				builder.setParam(name, params.get(name));
+
+			if (files == null) return false;
+			
+			System.out.println("-- Applying "+xslFile+" XSL to "+files.length+" files with parameters: "+params);
+			
+			ConsoleProgressBar cpb = new ConsoleProgressBar(files.length);
+
+			for (File f : files) {
+				String name = f.getName();
+				if (f.isHidden() || f.isDirectory()) continue;
+				if (name.endsWith(".properties")) continue;
+				if (name.equals("import.xml")) continue;
+				if (name.endsWith(".csv")) continue;
+				if (name.endsWith(".dtd")) continue;
+				if (name.endsWith(".xsl")) continue;
+				if (name.endsWith("~"))	continue;
+				if (name.startsWith(".")) continue;
+				
+				if (!ValidateXml.test(f)) {
+					System.out.println("src file "+f+", is not XML valid");
+					return false;
+				}
+				cpb.tick();
+				
+				if (!builder.process(f, f)) {
+					System.out.println("Failed with file "+ f);
+				}
+			}
+			System.out.println("");
+			return true;
+		} else {
+			System.out.println("XSL file does not exists: "+ xslFile);
+		}
+		return false;
+	}
+
+	/** 
+	 * Apply the XSL listed in the xslDirectory. Files are replaced
+	 * 
+	 * @param filesToProcess
+	 * @param xslDirectory
+	 * @param xslParams
+	 * @return
+	 * @throws TransformerException
+	 * @throws IOException
+	 */
+	public static boolean processWithMultipleXSL(File[] filesToProcess, File xslDirectory, HashMap<String, Object> xslParams) throws TransformerException, IOException {
+		if (xslDirectory.exists()) {
+			File[] xslFiles = xslDirectory.listFiles();
+			Arrays.sort(xslFiles);
+			return processWithMultipleXSL(filesToProcess, xslFiles, xslParams);
+		} else {
+			System.out.println("Nothing to do.");
+		}
+		return true;
+	}
+
+	/** 
+	 * Apply the XSL list. Files are replaced
+	 * 
+	 * @param filesToProcess
+	 * @param xslDirectory
+	 * @param xslParams
+	 * @return
+	 * @throws TransformerException
+	 * @throws IOException
+	 */
+	public static boolean processWithMultipleXSL(File[] filesToProcess, File[] xslFiles, HashMap<String, Object> xslParams) throws TransformerException, IOException {
+
+		Arrays.sort(xslFiles);
+		for (File xslFile : xslFiles) {
+			if (xslFile.isDirectory() || xslFile.isHidden() || !xslFile.getName().endsWith(".xsl")) continue;
+			
+			if (processImportSources(xslFile, filesToProcess, xslParams)) {
+				System.out.println("");
+			} else {
+				return false;
+			}
+		}
+
+		return true;
+	}
+
+	/**
+	 * The main method.
+	 *
+	 * @param args the arguments
+	 * @throws TransformerException 
+	 * @throws FileNotFoundException 
+	 */
+	public static void main(String[] args) throws Exception {
+		//String xslfile = "/home/mdecorde/TXM/xsl/breakByMilestone.xsl";
+		String xslfile = "G:/Feuilles de style/filtre-frantext-query-export4txm.xsl";
+		File xslFile = new File(xslfile);
+		ApplyXsl2 a = new ApplyXsl2(xslFile);
+
+		//File srcdirectory = new File("/home/mdecorde/TXM/corpora/transcribertest/HTML");
+		File srcdirectory = new File("C:/Documents and Settings/alavrent/xml/applyxsl");
+		assert(srcdirectory.exists());
+		assert(srcdirectory.isDirectory());
+		assert(srcdirectory.canRead());
+		assert(srcdirectory.canExecute());
+
+		File[] files = srcdirectory.listFiles();
+		System.out.println("process : "+srcdirectory+"/*");
+		System.out.println("with : "+xslfile);
+		long bigstart = System.currentTimeMillis();
+		for (File infile : files) {
+			if (infile.canRead() && infile.getName().endsWith(".xml")) {
+				File outfile = new File(infile.getAbsolutePath()+".out.xml");
+				long start = System.currentTimeMillis();
+				System.out.println("Process : "+infile.getName()+ " >> ");
+				//String[] params = {"pbval1",""+1,"pbval2",""+2};
+				a.process(infile,outfile); // no parameters
+				//a.process( infile.getAbsolutePath() ,outfile,params);
+				System.out.println("Done : "+(System.currentTimeMillis()-start)+"ms");
+			}
+		}
+		System.out.println("Total time : "+(System.currentTimeMillis()-bigstart)+"ms");
+	}
+}

Property changes on: tmp/org.txm.core/src/java/org/txm/importer/ApplyXsl2.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.core/src/java/org/txm/importer/EncodingConverter.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/importer/EncodingConverter.java	(revision 0)
+++ tmp/org.txm.core/src/java/org/txm/importer/EncodingConverter.java	(revision 313)
@@ -0,0 +1,215 @@
+// 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: 2014-09-15 10:51:15 +0200 (Mon, 15 Sep 2014) $
+// $LastChangedRevision: 2836 $
+// $LastChangedBy: mdecorde $ 
+//
+package org.txm.importer;
+
+import java.io.*;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Node;
+
+// TODO: Auto-generated Javadoc
+/**
+ * change the encoding of a file.
+ *
+ * @author mdecorde
+ */
+public class EncodingConverter {
+
+	/**
+	 * Instantiates a new encoding converter.
+	 *
+	 * @param in the in
+	 * @param out the out
+	 * @param in_encoding the in_encoding
+	 * @param out_encoding the out_encoding
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public EncodingConverter(File in, File out, String in_encoding,
+			String out_encoding) throws IOException {
+		int c;
+		InputStreamReader ist = new InputStreamReader(new FileInputStream(in),
+				in_encoding);
+		OutputStreamWriter ost = new OutputStreamWriter(new FileOutputStream(
+				out), out_encoding);
+
+		while ((c = ist.read()) != -1)
+			ost.write(c);
+
+		ist.close();
+		ost.close();
+	}
+
+	/**
+	 * out encoding is UTF-8.
+	 *
+	 * @param in the in
+	 * @param in_encoding the in_encoding
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public EncodingConverter(File in, String in_encoding) throws IOException {
+		String out_encoding = "UTF-8";
+
+		File out = new File("tempencodingconverter");
+		int c;
+		InputStreamReader ist = new InputStreamReader(new FileInputStream(in),
+				in_encoding);
+		OutputStreamWriter ost = new OutputStreamWriter(new FileOutputStream(
+				out), out_encoding);
+		while ((c = ist.read()) != -1)
+			ost.write(c);
+
+		ist.close();
+		ost.close();
+
+		in.delete();
+		out.renameTo(in);
+	}
+
+	/**
+	 * Instantiates a new encoding converter.
+	 *
+	 * @param in : will be replaced
+	 * @param in_encoding the in_encoding
+	 * @param out_encoding the out_encoding
+	 * @throws IOException Signals that an I/O exception has occurred.
+	 */
+	public EncodingConverter(File in, String in_encoding, String out_encoding)
+			throws IOException {
+		File out = new File("tempencodingconverter");
+		int c;
+		InputStreamReader ist = new InputStreamReader(new FileInputStream(in),
+				in_encoding);
+		OutputStreamWriter ost = new OutputStreamWriter(new FileOutputStream(
+				out), out_encoding);
+		while ((c = ist.read()) != -1)
+			ost.write(c);
+
+		ist.close();
+		ost.close();
+
+		in.delete();
+		out.renameTo(in);
+	}
+	
+	/**
+	 * Convert xml.
+	 *
+	 * @param infile the infile
+	 * @param outfile the outfile
+	 * @param encoding the encoding
+	 * @return true, if successful
+	 */
+	public static boolean convertXML(File infile, File outfile, String encoding)
+	{
+		try {
+			DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+			Node doc = builder.parse(infile);
+			// Création de la source DOM
+			Source source = new DOMSource(doc);
+			
+			// Création du fichier de sortie
+			Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outfile), "UTF-8")); 
+			Result resultat = new StreamResult(writer);
+			
+			// Configuration du transformer
+			TransformerFactory fabrique = new net.sf.saxon.TransformerFactoryImpl();
+			
+			Transformer transformer = fabrique.newTransformer();
+			transformer.setOutputProperty(OutputKeys.INDENT, "yes"); 
+			transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+			transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); 
+			
+			// Transformation
+			transformer.transform(source, resultat);
+			writer.close();
+			doc = null;
+			return true;
+		} catch (Exception e) {
+			org.txm.utils.logger.Log.printStackTrace(e);
+			return false;
+		}
+	}
+
+	/**
+	 * The main method.
+	 *
+	 * @param args the arguments
+	 */
+	public static void main(String[] args) {
+		File infile = new File("C:\\Documents and Settings\\mdecorde\\xml\\minicedre\\int1.trs");
+		File outfile = new File("C:\\Documents and Settings\\mdecorde\\xml\\minicedre\\int1utf8.trs");
+		EncodingConverter.convertXML(infile, outfile, "UTF-8");
+		/*List<File> files = new ArrayList<File>();
+		LinkedList<File> filefiles = new LinkedList<File>();
+
+		File racine = new File(
+				"~/workspace/org.txm.rcpapplication");
+		String extension = ".properties";
+		String prefix = "messages";
+
+		while (racine != null) {
+			if (racine.exists())
+				for (File f : racine.listFiles()) {
+					// System.out.println("scan file "+f);
+					if (f.isDirectory()) {
+						if (!f.getName().equals(".svn"))
+							filefiles.add(f);
+					} else if (f.isFile()) {
+						if (f.getName().endsWith(extension)
+								&& f.getName().startsWith(prefix))
+							files.add(f);
+					}
+				}
+
+			if (filefiles.size() > 0)
+				racine = filefiles.pop();
+			else
+				racine = null;
+		}
+
+		System.out.println(files);
+
+		for (File f : files) {
+			System.out.println("convert " + f);
+			try {
+				new EncodingConverter(f, "iso-8859-1", "utf-8");
+			} catch (IOException e) {
+				org.txm.utils.logger.Log.printStackTrace(e);
+			}
+		}*/
+	}
+
+}

Property changes on: tmp/org.txm.core/src/java/org/txm/importer/EncodingConverter.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.core/src/java/org/txm/metadatas/Metadatas.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/metadatas/Metadatas.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/metadatas/Metadatas.java	(revision 313)
@@ -32,8 +32,10 @@
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
+import java.net.MalformedURLException;
 import java.nio.charset.Charset;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -44,6 +46,7 @@
 
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.OutputKeys;
 import javax.xml.transform.Result;
@@ -59,7 +62,7 @@
 import javax.xml.xpath.XPathFactory;
 
 import org.txm.importer.AddAttributeInXml;
-import org.txm.importer.graal.PersonalNamespaceContext;
+import org.txm.importer.PersonalNamespaceContext;
 import org.txm.utils.AsciiUtils;
 import org.txm.utils.CsvReader;
 import org.txm.utils.Pair;
@@ -410,8 +413,11 @@
 	 * @param infile the infile
 	 * @param outfile the outfile
 	 * @return true, if successful
+	 * @throws XMLStreamException 
+	 * @throws IOException 
+	 * @throws MalformedURLException 
 	 */
-	public boolean injectMetadatasInXmlTXM(File infile, File outfile)
+	public boolean injectMetadatasInXmlTXM(File infile, File outfile) throws MalformedURLException, IOException, XMLStreamException
 	{
 		return injectMetadatasInXml(infile, outfile,"text", "tei");
 	}
@@ -423,8 +429,11 @@
 	 * @param outfile the outfile
 	 * @param tag the tag
 	 * @return true, if successful
+	 * @throws XMLStreamException 
+	 * @throws IOException 
+	 * @throws MalformedURLException 
 	 */
-	public boolean injectMetadatasInXml(File infile, File outfile, String tag)
+	public boolean injectMetadatasInXml(File infile, File outfile, String tag) throws MalformedURLException, IOException, XMLStreamException
 	{
 		return injectMetadatasInXml(infile, outfile,tag, null);
 	}
@@ -437,8 +446,11 @@
 	 * @param tag the tag
 	 * @param namespace the namespace
 	 * @return true, if successful
+	 * @throws XMLStreamException 
+	 * @throws IOException 
+	 * @throws MalformedURLException 
 	 */
-	public boolean injectMetadatasInXml(File infile, File outfile, String tag, String namespace)
+	public boolean injectMetadatasInXml(File infile, File outfile, String tag, String namespace) throws MalformedURLException, IOException, XMLStreamException
 	{
 		String key = infile.getName();
 		if(key.lastIndexOf(".") > 0)
Index: tmp/org.txm.core/src/java/org/txm/Toolbox.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/Toolbox.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/Toolbox.java	(revision 313)
@@ -34,16 +34,12 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Properties;
-import java.util.TreeMap;
 import java.util.logging.Level;
 
 import org.apache.commons.lang.StringUtils;
 import org.txm.core.messages.TXMCoreMessages;
+import org.txm.core.preferences.TBXPreferences;
+import org.txm.core.preferences.TXMPreferences;
 import org.txm.core.results.ITXMResult;
 import org.txm.importer.cwb.PatchCwbRegistry;
 import org.txm.objects.Base;
@@ -60,7 +56,6 @@
 import org.txm.searchengine.cqp.corpus.MainCorpus;
 import org.txm.searchengine.cqp.corpus.Partition;
 import org.txm.statsengine.r.core.RStatsEngine;
-import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
 import org.txm.utils.OSDetector;
 import org.txm.utils.Sh;
 import org.txm.utils.logger.Log;
@@ -73,7 +68,7 @@
  * @author jmague, mdecorde, sjacquot
  */
 public class Toolbox {
-
+/*
 	public static boolean useNetCQi = false;
 
 	/** The TXMHOME. */
@@ -91,9 +86,6 @@
 	/** The state workspace. */
 	private static boolean stateWorkspace = false;
 
-	/** The properties. */
-	private static Properties properties = new Properties();
-
 	/** The workspace. */
 	public static Workspace workspace;
 
@@ -103,8 +95,6 @@
 	/** The CQI client. */
 	private static AbstractCqiClient cqiClient;
 
-
-
 	/**
 	 * Sets the CQI server.
 	 *
@@ -141,139 +131,14 @@
 		return cqiServer;
 	}
 
-	/** The Constants for Toolbox properties. */
-	public static final String LOG_LEVEL = "log_level"; //$NON-NLS-1$
-	public static final String ADD_TECH_LOGS = "log_in_console"; //$NON-NLS-1$
-	public static final String SHOW_TIMINGS = "show_timings"; //$NON-NLS-1$
-	public static final String LOG_DIR = "log_directory"; //$NON-NLS-1$
-	public static final String LOG_IN_FILE = "log_in_file"; //$NON-NLS-1$
-	public static final String EXPERT_USER = "txm_expert_user"; //$NON-NLS-1$
-	public static final String LOG_STACKTRACE = "log_stacktrace"; //$NON-NLS-1$
-
-	/** The Constant CQI_SERVER_HOST. */
-	public static final String CQI_SERVER_HOST = "cqi_server_host"; //$NON-NLS-1$
-
-	/** The Constant CQI_SERVER_PORT. */
-	public static final String CQI_SERVER_PORT = "cqi_server_port"; //$NON-NLS-1$
-
-	/** The Constant CQI_SERVER_LOGIN. */
-	public static final String CQI_SERVER_LOGIN = "cqi_server_login"; //$NON-NLS-1$
-
-	/** The Constant CQI_SERVER_PASSWORD. */
-	public static final String CQI_SERVER_PASSWORD = "cqi_server_password"; //$NON-NLS-1$
-
-	/** The Constant CQI_SERVER_PATH_TO_EXECUTABLE. */
-	public static final String CQI_SERVER_PATH_TO_EXECUTABLE = "cqi_server_path_to_executable"; //$NON-NLS-1$
-
-	public static final String CQI_SERVER_PATH_TO_CQPLIB = "cqi_server_path_to_cqplib"; //$NON-NLS-1$
-
-	/** The Constant CQI_SERVER_PATH_TO_INIT_FILE. */
-	public static final String CQI_SERVER_PATH_TO_INIT_FILE = "cqi_server_path_to_init_file"; //$NON-NLS-1$
-
-	/** The Constant CQI_SERVER_ADDITIONAL_OPTIONS. */
-	public static final String CQI_SERVER_ADDITIONAL_OPTIONS = "cqi_server_additional_options"; //$NON-NLS-1$
-
-	/** The Constant CQI_SERVER_MONITOR_OUTPUT. */
-	public static final String CQI_SERVER_MONITOR_OUTPUT = "cqi_server_monitor_output"; //$NON-NLS-1$
-
-	/** The Constant CQI_SERVER_IS_REMOTE. */
-	public static final String CQI_SERVER_IS_REMOTE = "cqi_server_is_remote"; //$NON-NLS-1$
-
-	/** The Constant CQI_SERVER_MODE. */
-	public static final String CQI_NETWORK_MODE = "cqi_server_mode"; //$NON-NLS-1$
-
-	public static final String CQP_EMPTY_VALUE_CODE = "cqp_empty_value_code";
-
-
-	
-	/** The Constant SCRIPT_ROOT_DIR. */
-	public static final String SCRIPT_ROOT_DIR = "script_root_dir"; //$NON-NLS-1$
-
-	/** The Constant SCRIPT_CURRENT_DIR. */
-	public static final String SCRIPT_CURRENT_DIR = "script_current_dir"; //$NON-NLS-1$
-
-	/** The Constant UI_LOCALE. */
-	public static final String UI_LOCALE = "ui_locale"; //$NON-NLS-1$
-
-	/** The Constant WORKSPACE_LOCATION. */
-	public static final String WORKSPACE_LOCATION = "workspace_location"; //$NON-NLS-1$
-
-	/** The Constant INSTALL_DIR. */
-	public static final String INSTALL_DIR = "install_dir"; //$NON-NLS-1$
-
-	/** The Constant USER_TXM_HOME. */
-	public static final String USER_TXM_HOME = "user_txm_home"; //$NON-NLS-1$
-
-//	/** The Constant R_REMOTE. */
-//	public static final String IS_R_MANDATORY = "is_r_mandatory"; //$NON-NLS-1$
-//
-//	/** The Constant R_PATH_TO_EXECUTABLE. */
-//	public static final String R_PATH_TO_EXECUTABLE = "r_path_to_executable"; //$NON-NLS-1$
-//
-//	/** The Constant R_REMOTE. */
-//	public static final String R_REMOTE = "r_remote"; //$NON-NLS-1$
-//	public static final String R_DEBUG = "r_debug"; //$NON-NLS-1$
-//
-//	/** The Constant R_SERVER_ADDRESS. */
-//	public static final String R_SERVER_ADDRESS = "r_server_adress"; //$NON-NLS-1$
-//
-//	/** The Constant R_PORT. */
-//	public static final String R_PORT = "r_port"; //$NON-NLS-1$
-//
-//	/** The Constant R_USER. */
-//	public static final String R_USER = "r_user"; //$NON-NLS-1$
-//
-//	/** The Constant R_PASSWORD. */
-//	public static final String R_PASSWORD = "r_password"; //$NON-NLS-1$
-//
-//	/** The Constant R_PACKAGES_PATH. */
-//	public static final String R_PACKAGES_PATH = "r_packages_path"; //$NON-NLS-1$
-//
-//	public static final String R_RARGS = "r_rargs"; //$NON-NLS-1$
-//	public static final String R_RSERVEARGS = "r_rserveargs"; //$NON-NLS-1$
-//
-//	/** The Constant R_DISABLE. */
-//	public static final String R_DISABLE = "r_disable"; //$NON-NLS-1$
-//
-//	/** The Constant R_FILE_TRANSFERT. */
-//	public static final String R_FILE_TRANSFERT = "r_file_transfert"; //$NON-NLS-1$
-//	public static final String R_SVG_DEVICE = "r_svg_device"; //$NON-NLS-1$
-
-	/** The Constant TREETAGGER_INSTALL_PATH. */
-	public static final String TREETAGGER_INSTALL_PATH = "treetagger_install_path"; //$NON-NLS-1$
-	/** The Constant TREETAGGER_MODELS_PATH. */
-	public static final String TREETAGGER_MODELS_PATH = "treetagger_models_path"; //$NON-NLS-1$
-	public static final String TREETAGGER_OPTIONS = "treetagger_options"; //$NON-NLS-1$
-	public static final String TREETAGGER_APOSTROPHE = "treetagger_fix_apostrophes"; //$NON-NLS-1$
-
-	public static final String METADATA_ENCODING = "metadata_encoding"; //$NON-NLS-1$
-	public static final String METADATA_COLSEPARATOR = "metadata_colseparator"; //$NON-NLS-1$
-	public static final String METADATA_TXTSEPARATOR = "metadata_txtseparator"; //$NON-NLS-1$
-
 	private static boolean initializing = false;
 
+	private static boolean useNetCQi;
+
 	public static boolean isInitializing() {
 		return initializing;
 	}
 
-	/** Contains all the parameters keys. */
-	public static final String[] existingKeys = { LOG_LEVEL, LOG_STACKTRACE, ADD_TECH_LOGS, LOG_DIR,
-		LOG_IN_FILE, CQI_SERVER_HOST, CQI_SERVER_PORT, CQI_SERVER_LOGIN,
-		CQI_SERVER_PASSWORD, CQI_SERVER_PATH_TO_EXECUTABLE,CQI_SERVER_PATH_TO_CQPLIB,
-		CQI_SERVER_ADDITIONAL_OPTIONS, CQI_SERVER_MONITOR_OUTPUT,
-		CQI_SERVER_IS_REMOTE, CQI_NETWORK_MODE, CQP_EMPTY_VALUE_CODE, SCRIPT_ROOT_DIR,
-		SCRIPT_CURRENT_DIR, UI_LOCALE, WORKSPACE_LOCATION, INSTALL_DIR,
-		USER_TXM_HOME,
-//		IS_R_MANDATORY, R_PATH_TO_EXECUTABLE, R_DEBUG, R_REMOTE, R_SERVER_ADDRESS,
-//		R_PORT, R_USER, R_PASSWORD, R_PACKAGES_PATH, R_RARGS, R_RSERVEARGS, R_DISABLE, R_FILE_TRANSFERT,R_SVG_DEVICE,
-		
-		TREETAGGER_INSTALL_PATH, TREETAGGER_MODELS_PATH,TREETAGGER_OPTIONS, TREETAGGER_APOSTROPHE,
-		METADATA_ENCODING, METADATA_COLSEPARATOR,METADATA_TXTSEPARATOR
-
-	};
-
-
-
 	/**
 	 * Initializes the toolbox with the parameters read in the file
 	 * textometrie.properties found in the user home directory
@@ -302,28 +167,6 @@
 	}
 
 	/**
-	 * Initializes the toolbox with the parameters read in the file
-	 * textometrie.properties found in the user home directory. Web version :
-	 * check if the Toolbox is already initialized
-	 *
-	 * @return true, if successful
-	 * @throws FileNotFoundException the file not found exception
-	 * @throws IOException Signals that an I/O exception has occurred.
-	 */
-	public static boolean initialise() throws Exception {
-		initializing = true;
-		if (!isInitialized()) {
-			state = true;
-			boolean ret = initialize();
-			initializing = false;
-			return ret;
-		}
-
-		initializing = false;
-		return true;
-	}
-
-	/**
 	 * initialize the toolbox from a UTF-8 file
 	 * 
 	 * key1=value1 key2=value2.
@@ -360,7 +203,7 @@
 	public static boolean initialize(File file, String encoding) throws Exception {
 		initializing = true;
 		//System.out.println("Reading properties from file: " + file.getAbsolutePath());
-		Properties properties = new Properties();
+		//Properties properties = new Properties();
 		try {
 			BufferedReader input = new BufferedReader(new InputStreamReader(
 					new FileInputStream(file), encoding));
@@ -368,27 +211,21 @@
 			while (line != null) {
 				String[] split = line.split("="); //$NON-NLS-1$
 				if (split.length == 2) {
-					properties.put(split[0], split[1]);
+					TXMPreferences.put(TBXPreferences.PREFERENCES_NODE, split[0], split[1]);
 				} else if (split.length > 2) {
 					String[] subsplit = new String[split.length - 1];
 					System.arraycopy(split, 1, subsplit, 0, split.length - 1);
-					properties.put(split[0], StringUtils.join(subsplit, "=")); //$NON-NLS-1$
+					TXMPreferences.put(TBXPreferences.PREFERENCES_NODE, split[0], StringUtils.join(subsplit, "="));
 				}
 				line = input.readLine();
 			}
 			input.close();
-		} catch (UnsupportedEncodingException e) {
+		} catch (Exception e) {
 			initializing = false;
 			System.err.println(e);
-		} catch (FileNotFoundException e) {
-			initializing = false;
-			System.err.println(e);
 			throw e;
-		} catch (IOException e) {
-			initializing = false;
-			throw e;
 		}
-		return initialize(properties);
+		return initialize(TBXPreferences.class);
 	}
 
 	/**
@@ -398,140 +235,32 @@
 	 * @return true, if successful
 	 * @throws Exception 
 	 */
-	public static boolean initialize(Properties props) throws Exception {
+	public static boolean initialize(Class preferencesStore) throws Exception {
 		initializing = true;
 
 		try {
-			Log.info(TXMCoreMessages.Toolbox_4 + props.toString()); 
+			Log.info(TXMCoreMessages.Toolbox_4 + TBXPreferences.getID()); 
 
-			// Create default values for initialization
-			if (props.getProperty(INSTALL_DIR) == null)
-				props.setProperty(INSTALL_DIR, TXMINSTALL); 
-			else
-				TXMINSTALL = props.getProperty(INSTALL_DIR);
 
-			if (props.getProperty(USER_TXM_HOME) == null)
-				props.setProperty(USER_TXM_HOME, TXMHOME); 
-			else
-				TXMHOME = props.getProperty(USER_TXM_HOME);
+			TXMINSTALL = TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.INSTALL_DIR);
 
-			if (props.getProperty(LOG_LEVEL) == null)
-				props.setProperty(LOG_LEVEL, "OFF"); //$NON-NLS-1$
-			if (props.getProperty(ADD_TECH_LOGS) == null)
-				props.setProperty(ADD_TECH_LOGS, "" + false); //$NON-NLS-1$
+			TXMHOME = TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.USER_TXM_HOME);
 
-			if (props.getProperty(LOG_STACKTRACE) == null)
-				props.setProperty(LOG_STACKTRACE, "" + true); //$NON-NLS-1$
-			if (props.getProperty(LOG_IN_FILE) == null)
-				props.setProperty(LOG_IN_FILE, "" + false); //$NON-NLS-1$
-
-			if (props.getProperty(CQI_SERVER_PATH_TO_EXECUTABLE) == null)
-				props.setProperty(CQI_SERVER_PATH_TO_EXECUTABLE, TXMINSTALL
-						+ "/cwb/bin/cqpserver"); //$NON-NLS-1$
-			if (props.getProperty(CQI_SERVER_PATH_TO_INIT_FILE) == null)
-				props.setProperty(CQI_SERVER_PATH_TO_INIT_FILE, TXMINSTALL
-						+ "/cwb/cqpserver.init"); //$NON-NLS-1$
-			if (props.getProperty(CQI_SERVER_ADDITIONAL_OPTIONS) == null)
-				props.setProperty(CQI_SERVER_ADDITIONAL_OPTIONS, "-b 1000000 -d OFF"); //$NON-NLS-1$
-			if (props.getProperty(CQI_SERVER_PORT) == null)
-				props.setProperty(CQI_SERVER_PORT, "4877"); //$NON-NLS-1$
-			if (props.getProperty(CQI_SERVER_HOST) == null)
-				props.setProperty(CQI_SERVER_HOST, "localhost"); //$NON-NLS-1$
-			if (props.getProperty(CQI_SERVER_LOGIN) == null)
-				props.setProperty(CQI_SERVER_LOGIN, "anonymous"); //$NON-NLS-1$
-			if (props.getProperty(CQI_SERVER_PASSWORD) == null)
-				props.setProperty(CQI_SERVER_PASSWORD, ""); //$NON-NLS-1$
-			if (props.getProperty(CQI_SERVER_IS_REMOTE) == null)
-				props.setProperty(CQI_SERVER_IS_REMOTE, "" + false); //$NON-NLS-1$
-			if (props.getProperty(CQI_NETWORK_MODE) == null) {
-				props.setProperty(CQI_NETWORK_MODE, "false"); //$NON-NLS-1$
-			}
-			if (props.getProperty(CQP_EMPTY_VALUE_CODE) == null)
-				props.setProperty(CQP_EMPTY_VALUE_CODE, ""); //$NON-NLS-1$
-			if (props.getProperty(SCRIPT_ROOT_DIR) == null)
-				props.setProperty(SCRIPT_ROOT_DIR,
-						new File(TXMHOME, "scripts").getAbsolutePath()); //$NON-NLS-1$
-			if (props.getProperty(SCRIPT_CURRENT_DIR) == null)
-				props.setProperty(SCRIPT_CURRENT_DIR,
-						new File(TXMHOME, "scripts").getAbsolutePath()); //$NON-NLS-1$
-			if (props.getProperty(UI_LOCALE) == null)
-				props.setProperty(UI_LOCALE, "fr"); //$NON-NLS-1$
-			if (props.getProperty(WORKSPACE_LOCATION) == null)
-				props.setProperty(WORKSPACE_LOCATION, new File(TXMHOME, "workspaces/default.xml").getAbsolutePath()); //$NON-NLS-1$ 
-
-//			if (props.getProperty(IS_R_MANDATORY) == null)
-//				props.setProperty(IS_R_MANDATORY, "" + false); //$NON-NLS-1$
-//			if (props.getProperty(R_PATH_TO_EXECUTABLE) == null) {
-//				props.setProperty(R_PATH_TO_EXECUTABLE, ""); //$NON-NLS-1$
-//			}
-//			if (props.getProperty(R_SERVER_ADDRESS) == null)
-//				props.setProperty(R_SERVER_ADDRESS, "127.0.0.1"); //$NON-NLS-1$
-//			if (props.getProperty(R_PACKAGES_PATH) == null)
-//				props.setProperty(R_PACKAGES_PATH, ""); //$NON-NLS-1$
-//			if (props.getProperty(R_REMOTE) == null)
-//				props.setProperty(R_REMOTE, "" + false); //$NON-NLS-1$
-//			if (props.getProperty(R_DISABLE) == null)
-//				props.setProperty(R_DISABLE, "" + false); //$NON-NLS-1$
-//			if (props.getProperty(R_DEBUG) == null || props.getProperty(R_DEBUG).length() == 0)
-//				props.setProperty(R_DEBUG, "" + false); //$NON-NLS-1$
-//			if (props.getProperty(R_PORT) == null || props.getProperty(R_PORT).length() == 0)
-//				props.setProperty(R_PORT, "6311"); //$NON-NLS-1$
-//			if (props.getProperty(R_USER) == null)
-//				props.setProperty(R_USER, ""); //$NON-NLS-1$
-//			if (props.getProperty(R_PASSWORD) == null)
-//				props.setProperty(R_PASSWORD, ""); //$NON-NLS-1$
-//			if (props.getProperty(R_RARGS) == null)
-//				props.setProperty(R_RARGS, ""); //$NON-NLS-1$
-//			if (props.getProperty(R_RSERVEARGS) == null)
-//				props.setProperty(R_RSERVEARGS, ""); //$NON-NLS-1$
-//			if (props.getProperty(R_FILE_TRANSFERT) == null)
-//				props.setProperty(R_FILE_TRANSFERT, "false"); //$NON-NLS-1$
-//			if (props.getProperty(R_SVG_DEVICE) == null) {
-//				props.setProperty(R_SVG_DEVICE, "svg"); //$NON-NLS-1$
-//			}
-
-			if (props.getProperty(TREETAGGER_INSTALL_PATH) == null
-					|| props.getProperty(TREETAGGER_INSTALL_PATH).equals("")) //$NON-NLS-1$
-				props.setProperty(TREETAGGER_INSTALL_PATH, System
-						.getProperty("user.home") + "/TXM/treetagger"); //$NON-NLS-1$ //$NON-NLS-2$
-			if (props.getProperty(TREETAGGER_MODELS_PATH) == null
-					|| props.getProperty(TREETAGGER_MODELS_PATH).equals("")) //$NON-NLS-1$
-				props.setProperty(TREETAGGER_MODELS_PATH, props
-						.getProperty(TREETAGGER_INSTALL_PATH) + "/models"); //$NON-NLS-1$
-			if (props.getProperty(TREETAGGER_APOSTROPHE) == null
-					|| props.getProperty(TREETAGGER_APOSTROPHE).equals("")) //$NON-NLS-1$
-				props.setProperty(TREETAGGER_APOSTROPHE, "false"); //$NON-NLS-1$
-
-			if (props.getProperty(METADATA_COLSEPARATOR) == null || props.getProperty(METADATA_COLSEPARATOR).length() == 0)
-				props.setProperty(METADATA_COLSEPARATOR, ","); //$NON-NLS-1$
-			if (props.getProperty(METADATA_ENCODING) == null || props.getProperty(METADATA_ENCODING).length() == 0)
-				props.setProperty(METADATA_ENCODING, "UTF-8"); //$NON-NLS-1$
-			if (props.getProperty(METADATA_TXTSEPARATOR) == null)
-				props.setProperty(METADATA_TXTSEPARATOR, "\""); //$NON-NLS-1$
-
-			properties = props;
-
 			// initialize workspace : list of corpus loaded in TXM
 			stateWorkspace = startWorkspace();
 
 			Log.warning("Initializing logger");
-			Log.setLevel(Level.parse(props.getProperty(LOG_LEVEL)));
-			//System.out.println("log_in_file: "+props.getProperty(LOG_FILE));
-			Log.setPrintInConsole(Boolean.parseBoolean(props.getProperty(ADD_TECH_LOGS)));
-			//System.out.println("LOG in file: "+props.getProperty(LOG_IN_FILE)+ " -> "+Boolean.parseBoolean(props.getProperty(LOG_IN_FILE)));
-			if(props.getProperty(LOG_DIR) != null)
-				Log.setPrintInFile(Boolean.parseBoolean(props.getProperty(LOG_IN_FILE)), new File(props.getProperty(LOG_DIR)));
-			else
-				Log.setPrintInFile(Boolean.parseBoolean(props.getProperty(LOG_IN_FILE)));
+			Log.setLevel(Level.parse(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.LOG_LEVEL)));
 
-			useNetCQi = Boolean.parseBoolean(props.getProperty(CQI_NETWORK_MODE));
-			//System.out.println("CQI MODE NETWORK : "+useNetCQi);
+			Log.setPrintInConsole(Boolean.parseBoolean(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.ADD_TECH_LOGS)));
 
-			Log.info(TXMCoreMessages.Toolbox_8 + checkInexistantParameterKey(props)); 
-			Log.info(TXMCoreMessages.Toolbox_9 + getSortedPropertiesAsString()); 
+			if(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.LOG_DIR) != null)
+				Log.setPrintInFile(Boolean.parseBoolean(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.LOG_IN_FILE)), new File(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.LOG_DIR)));
+			else
+				Log.setPrintInFile(Boolean.parseBoolean(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.LOG_IN_FILE)));
 
-			// start engines then the workspace
-			//System.out.println("REMOTE CQP: "+props.getProperty(CQI_SERVER_IS_REMOTE));
+			useNetCQi = Boolean.parseBoolean(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_NETWORK_MODE));
+
 			Log.warning("Killing CQP and RServe process if any");
 			processKiller();
 
@@ -549,23 +278,6 @@
 	}
 
 	/**
-	 * find the keys not used by the Toolbox.
-	 *
-	 * @param p the p
-	 * @return the list
-	 */
-	public static List<String> checkInexistantParameterKey(Properties p) {
-		List<String> existingkeys = Arrays.asList(existingKeys);
-		List<String> missingkeys = new ArrayList<String>();
-		for (Object key : p.keySet()) {
-			String skey = key.toString();
-			if (!existingkeys.contains(skey))
-				missingkeys.add(skey);
-		}
-		return missingkeys;
-	}
-
-	/**
 	 * if searchengine or statengine or workspace is not ready then the toolbox
 	 * is not ready.
 	 *
@@ -579,6 +291,7 @@
 		return state;
 	}
 
+	/*
 	/**
 	 * start the workspace, creates a new one if WORKSPACE_LOCATION is wrong.
 	 *
@@ -587,12 +300,12 @@
 	private static boolean startWorkspace() {
 		try {
 			System.out.print(TXMCoreMessages.Toolbox_workspace_init);
-			String txmhome = getParam(USER_TXM_HOME);
+			String txmhome = TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.USER_TXM_HOME);
 			if (txmhome.length() == 0) {
 				stateWorkspace = false;
 				return false;
 			}
-			String location = properties.getProperty(WORKSPACE_LOCATION);
+			String location = TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.WORKSPACE_LOCATION);
 			
 			System.out.println("Toolbox.startWorkspace(): workspace location = " + location);
 			
@@ -638,7 +351,7 @@
 			 */
 
 		} catch (Exception e) {
-			System.err.println(TXMCoreMessages.Toolbox_workspace_init_failed + properties.getProperty(WORKSPACE_LOCATION)); 
+			System.err.println(TXMCoreMessages.Toolbox_workspace_init_failed + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.WORKSPACE_LOCATION)); 
 			Log.severe(TXMCoreMessages.Toolbox_15 + Log.toString(e));
 			Log.printStackTrace(e);
 			stateWorkspace = false;
@@ -662,12 +375,11 @@
 		}
 
 		boolean cqiserverok = false;
-		boolean remote = Boolean.parseBoolean(properties
-				.getProperty(Toolbox.CQI_SERVER_IS_REMOTE));
+		boolean remote = Boolean.parseBoolean(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_IS_REMOTE));
 		stateSearchEngine = false;
 		// test if must-have properties for CWB are set
 
-		String exec_path = properties.getProperty(CQI_SERVER_PATH_TO_EXECUTABLE);
+		String exec_path = TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PATH_TO_EXECUTABLE);
 		String reg_path = ""; // new way that concats registry of loaded corpus
 		String path_separator = System.getProperty("path.separator");
 		for (Base b : workspace.getProject("default").getBases()) {
@@ -693,7 +405,7 @@
 		}
 		if (reg_path.length() > 0) reg_path = reg_path.substring(path_separator.length()); // remove first path_separator
 		//System.out.println("REGPATH="+reg_path);
-		String init_path = properties.getProperty(CQI_SERVER_PATH_TO_INIT_FILE);
+		String init_path = TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PATH_TO_INIT_FILE);
 
 
 		if (!remote) {
@@ -707,10 +419,9 @@
 						Toolbox.cqiServer = new MemCqiServer(exec_path,
 								reg_path, 
 								init_path, 
-								properties.getProperty(CQI_SERVER_ADDITIONAL_OPTIONS)
-								+ " -P " + properties.getProperty(CQI_SERVER_PORT), //$NON-NLS-1$
-								Boolean.parseBoolean(properties
-										.getProperty(CQI_SERVER_MONITOR_OUTPUT)));
+								TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_ADDITIONAL_OPTIONS)
+								+ " -P " + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PORT), //$NON-NLS-1$
+								Boolean.parseBoolean(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_MONITOR_OUTPUT)));
 					} catch (Exception e) {
 						// TODO Auto-generated catch block
 						org.txm.utils.logger.Log.printStackTrace(e);
@@ -719,10 +430,9 @@
 					Toolbox.cqiServer = new NetCqiServer(exec_path,
 							reg_path, 
 							init_path, 
-							properties.getProperty(CQI_SERVER_ADDITIONAL_OPTIONS)
-							+ " -P " + properties.getProperty(CQI_SERVER_PORT), //$NON-NLS-1$
-							Boolean.parseBoolean(properties
-									.getProperty(CQI_SERVER_MONITOR_OUTPUT)));
+							TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_ADDITIONAL_OPTIONS)
+							+ " -P " + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PORT), //$NON-NLS-1$
+							Boolean.parseBoolean(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_MONITOR_OUTPUT)));
 				}
 				if (Toolbox.cqiServer != null)
 					cqiserverok = Toolbox.cqiServer.start();
@@ -740,22 +450,22 @@
 						cqiserverok = false;
 					}
 				} else {
-					int port = Integer.parseInt(properties.getProperty(CQI_SERVER_PORT));
-					String host = properties.getProperty(CQI_SERVER_HOST);
+					int port = Integer.parseInt(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PORT));
+					String host = TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_HOST);
 					cqiClient = new NetCqiClient(host, port);
 				}
 			}
 		} catch (NumberFormatException e1) {
-			Log.severe(TXMCoreMessages.Toolbox_wrong_port + properties.getProperty(CQI_SERVER_PORT)); 
+			Log.severe(TXMCoreMessages.Toolbox_wrong_port + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PORT)); 
 		} catch (ServerNotFoundException e1) {
-			Log.severe(TXMCoreMessages.Error_CONNECTION_FAILED + properties.getProperty(CQI_SERVER_HOST) + TXMCoreMessages.Toolbox_27 + properties.getProperty(CQI_SERVER_PORT)); 
+			Log.severe(TXMCoreMessages.Error_CONNECTION_FAILED + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_HOST) + TXMCoreMessages.Toolbox_27 + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PORT)); 
 		}
 
 		// try connecting to the CWB server
 		try {
 			if (cqiserverok) {
-				String login = properties.getProperty(CQI_SERVER_LOGIN);
-				String password = properties.getProperty(CQI_SERVER_PASSWORD);
+				String login = TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_LOGIN);
+				String password = TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PASSWORD);
 				stateSearchEngine = cqiClient.connect(login, password);
 			}
 		} catch (Exception e1) {
@@ -764,7 +474,10 @@
 
 		if (stateSearchEngine == false) {
 			System.out.println(TXMCoreMessages.Toolbox_29); 
-			System.out.println(TXMCoreMessages.Toolbox_30 + properties.getProperty(CQI_SERVER_LOGIN) + " " + properties.getProperty(CQI_SERVER_PASSWORD) + properties.getProperty(CQI_SERVER_HOST) + " " + Integer.parseInt(properties.getProperty(CQI_SERVER_PORT))); //$NON-NLS-1$ //$NON-NLS-2$
+			System.out.println(TXMCoreMessages.Toolbox_30 + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_LOGIN) 
+					+ " " + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PASSWORD) 
+					+ TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_HOST) 
+					+ " " + Integer.parseInt(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PORT))); //$NON-NLS-1$ //$NON-NLS-2$
 			if (cqiServer != null)
 				System.out.println(TXMCoreMessages.Toolbox_33 + cqiServer.getLastCmdLine());
 		} else {
@@ -807,7 +520,7 @@
 	 * kill cqpserver process.
 	 */
 	private static void killSearchEngine() {
-		if ("false".equals(getParam(CQI_SERVER_IS_REMOTE))) //$NON-NLS-1$
+		if ("false".equals(TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_IS_REMOTE))) //$NON-NLS-1$
 			// Windows OS
 			if (OSDetector.isFamilyWindows()) {
 				try {
@@ -840,23 +553,23 @@
 			}
 		// Mac, Linux
 			else {
-				String cmd = TXMCoreMessages.Toolbox_37 + getParam(CQI_SERVER_PORT) + TXMCoreMessages.Toolbox_38;
+				String cmd = TXMCoreMessages.Toolbox_37 + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PORT) + TXMCoreMessages.Toolbox_38;
 				try {
 					//Process p = Runtime.getRuntime().exec("killall -9 cqpserver"); //$NON-NLS-1$
 					// System.out.println("kill `ps aux | grep cqpserver | awk '/-P "
-					// + getParam(CQI_SERVER_PORT) + "/ {print $2}'`");
+					// + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, CQI_SERVER_PORT) + "/ {print $2}'`");
 					// String[] args =
 					// {"kill","`ps aux | grep cqpserver | awk '/-P " +
-					// getParam(CQI_SERVER_PORT) + "/ {print $2}'`"};
+					// TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, CQI_SERVER_PORT) + "/ {print $2}'`"};
 					// System.out.println("before Sh constructor");
 					Sh sh = new Sh(""); //$NON-NLS-1$
 					// System.out.println("after Sh constructor");
 					// System.out.println("EXECUTE SH : "+"kill `ps aux | grep cqpserver | awk '/-P "
-					// + getParam(CQI_SERVER_PORT) + "/ {print $2}'`");
+					// + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, CQI_SERVER_PORT) + "/ {print $2}'`");
 					sh.setIsc(cmd);
 					sh.sh();
 					// Runtime.getRuntime().exec("sh kill `ps aux | grep cqpserver | awk '/-P "
-					// + getParam(CQI_SERVER_PORT) + "/ {print $2}'`");
+					// + TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, CQI_SERVER_PORT) + "/ {print $2}'`");
 
 				} catch (Exception e) {
 					Log.severe(TXMCoreMessages.Toolbox_39+cmd+TXMCoreMessages.Toolbox_40+Log.toString(e));
@@ -1035,71 +748,11 @@
 	 */
 	public static boolean restart() throws Exception {
 		Toolbox.shutdown();
-		Toolbox.initialize(properties);
+		Toolbox.initialize(TBXPreferences.class);
 		return checkState();
 	}
 
 	/**
-	 * Update the toolbox properties.
-	 *
-	 * @param props the props
-	 */
-	public static void updateProperties(Properties props) {
-		for (Object okey : props.keySet()) {
-			String key = (String) okey;
-			//System.out.println("maj TBX prop "+key+" with "+props.get(key));
-
-			if (props.get(key) == null) {
-				Log.severe(TXMCoreMessages.Toolbox_2 + key);
-			}
-			else	{
-				properties.put(key, props.get(key));
-			}
-		}
-		Log.setLevel(Level.parse(getParam(LOG_LEVEL)));
-		Log.info(TXMCoreMessages.Toolbox_11 + getSortedPropertiesAsString());
-	}
-
-	/**
-	 * Shut the toolbox down. Web version : change the toolbox state
-	 *
-	 * @throws RWorkspaceException the r workspace exception
-	 */
-	public static void shutdoweb() throws RWorkspaceException {
-		if (isInitialized()) {
-			shutdown();
-			state = false;
-		}
-	}
-
-	/**
-	 * get the string value of a toolbox's parameter
-	 * 
-	 * ex : Toolbox.getParam(Toolbox.R_Path_To_EXECUTABLE)
-	 *
-	 * @param key the key
-	 * @return the param
-	 */
-	public static String getParam(String key) {
-		if (properties != null)
-			return properties.getProperty(key);
-		else
-			return "ERROR WHILE GETTING TXM PARAM"; //$NON-NLS-1$
-	}
-
-	/**
-	 * set the string value of a toolbox's parameter
-	 * 
-	 * ex : Toolbox.setParam(Toolbox.R_Path_To_EXECUTABLE,"")
-	 *
-	 * @param key the key
-	 * @param value the value
-	 */
-	public static void setParam(String key, Object value) {
-		properties.setProperty(key, value.toString());
-	}
-
-	/**
 	 * test if searchEngine and statEngine and Workspace are initialized.
 	 *
 	 * @return true, if is initialized
@@ -1118,6 +771,17 @@
 	}
 
 	/**
+	 * Use TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, key) instead
+	 * 
+	 * @param key
+	 * @return
+	 */
+	@Deprecated
+	public static String getParam(String key) {
+		return TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, key);
+	}
+	
+	/**
 	 * test if StatEngine is initialized.
 	 *
 	 * @return true, if is initialized
@@ -1126,15 +790,6 @@
 		return RStatsEngine.isStarted();
 	}
 
-	/**
-	 * return all the properties of the toolbox.
-	 *
-	 * @return the properties
-	 */
-	public static Properties getProperties() {
-		return properties;
-	}
-
 	/* (non-Javadoc)
 	 * @see java.lang.Object#finalize()
 	 */
@@ -1146,15 +801,18 @@
 			super.finalize();
 		}
 	}
-
-	
-	
-	
 	/**
-	 * Returns a string representation of sorted properties.
+	 * use TBXPreferences.setString(key, value) instead
+	 * 
+	 * @param key
+	 * @param value
 	 */
-	public static String getSortedPropertiesAsString()	{
-		TreeMap treeMap = new TreeMap(properties);
-		return treeMap.toString();
+	@Deprecated
+	public static void setParam(String key, String value) {
+		TXMPreferences.putString(TBXPreferences.PREFERENCES_NODE, key, value);
 	}
+
+	public static void preferencesUpdated() {
+		// TODO Auto-generated method stub
+	}
 }
Index: tmp/org.txm.core/src/java/org/txm/StandaloneTest.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/StandaloneTest.java	(revision 0)
+++ tmp/org.txm.core/src/java/org/txm/StandaloneTest.java	(revision 313)
@@ -0,0 +1,53 @@
+package org.txm;
+
+import java.util.ServiceLoader;
+
+import org.eclipse.core.internal.runtime.Activator;
+import org.eclipse.core.internal.runtime.InternalPlatform;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+import org.osgi.util.tracker.ServiceTracker;
+import org.txm.core.preferences.TBXPreferences;
+
+public class StandaloneTest {
+	
+	public static void main(String[] args) {
+		
+		try {
+			
+			//Load the framwork factory
+	        ServiceLoader loader = ServiceLoader.load( FrameworkFactory.class );
+	        System.out.println("ServiceLoader= "+loader);
+	        
+	        FrameworkFactory factory = ( FrameworkFactory ) loader.iterator( ).next( );
+	        System.out.println("FrameworkFactory= "+loader);
+	        
+	        // Create a new instance of the framework
+	        Framework framework = factory.newFramework( null );
+	        System.out.println("Framework="+framework);
+	        framework.init( );
+	        framework.start( );
+	        
+	        BundleContext bc = framework.getBundleContext();
+	        System.out.println("BundleContext: "+bc);
+	        
+	        Filter filter = bc.createFilter("(objectClass=*ServiceTasks)");
+	        System.out.println("Filter: "+filter);
+	        
+	        ServiceTracker serviceTaskTracker = new ServiceTracker(bc, filter, null);
+	        System.out.println("ServiceTracker: "+serviceTaskTracker);
+	        
+	        InternalPlatform.getDefault().start(bc);
+	        System.out.println("context started");
+	        
+	     //   Activator.getDefault().start(bc); 
+			
+			Toolbox.initialize(TBXPreferences.class);
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+}

Property changes on: tmp/org.txm.core/src/java/org/txm/StandaloneTest.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.core/src/java/org/txm/functions/summary/Summary.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/functions/summary/Summary.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/functions/summary/Summary.java	(revision 313)
@@ -2,6 +2,7 @@
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 
 import org.txm.Toolbox;
 import org.txm.core.messages.TXMCoreMessages;
@@ -17,8 +18,6 @@
 import org.txm.searchengine.cqp.corpus.query.Query;
 import org.txm.searchengine.cqp.serverException.CqiServerError;
 
-import cern.colt.Arrays;
-
 public class Summary extends TXMResult  {
 	MainCorpus corpus;
 	TreeNode treenodes = new TreeNode("root"); //$NON-NLS-1$
Index: tmp/org.txm.core/src/java/org/txm/annotation/conversion/CorpusRuledConvertion.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/annotation/conversion/CorpusRuledConvertion.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/annotation/conversion/CorpusRuledConvertion.java	(revision 313)
@@ -7,8 +7,11 @@
 import java.util.LinkedHashMap;
 import java.util.regex.Pattern;
 
+import javax.xml.stream.XMLStreamException;
+
 import org.apache.commons.lang.StringUtils;
 import org.txm.Toolbox;
+import org.txm.core.preferences.TBXPreferences;
 import org.txm.searchengine.cqp.corpus.MainCorpus;
 import org.txm.stat.utils.ConsoleProgressBar;
 import org.txm.utils.io.IOUtils;
@@ -46,7 +49,7 @@
 		this.rules = rules;
 	}
 
-	public boolean process(MainCorpus corpus) {
+	public boolean process(MainCorpus corpus) throws XMLStreamException, IOException {
 		File binaryCorpusDirectory = corpus.getBaseDirectory();
 		File txmDirectory = new File(binaryCorpusDirectory, "txm");
 		if (!txmDirectory.exists()) {
@@ -91,7 +94,7 @@
 					}
 					if (errors.size() > 10) {
 						try {
-							File errorFile = new File(Toolbox.getParam(Toolbox.USER_TXM_HOME), "errors.txt");
+							File errorFile = new File(Toolbox.getParam(TBXPreferences.USER_TXM_HOME), "errors.txt");
 							IOUtils.write(errorFile, StringUtils.join(errors, "\t"));
 							System.out.println("More errors, see "+errorFile.getAbsolutePath());
 						} catch (Exception e) {
Index: tmp/org.txm.core/src/java/org/txm/annotation/conversion/XMLTXMFileRuledConversion.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/annotation/conversion/XMLTXMFileRuledConversion.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/annotation/conversion/XMLTXMFileRuledConversion.java	(revision 313)
@@ -1,6 +1,7 @@
 package org.txm.annotation.conversion;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.regex.Pattern;
@@ -20,7 +21,7 @@
 	public static final String ABANDON = "abandon";
 	HashSet<String> noMatchValues = new HashSet<String>();
 	
-	public XMLTXMFileRuledConversion(File infile, LinkedHashMap<Pattern, String> rules, String oldType, String newType, String mode) {
+	public XMLTXMFileRuledConversion(File infile, LinkedHashMap<Pattern, String> rules, String oldType, String newType, String mode) throws IOException, XMLStreamException {
 		super(infile);
 		this.rules = rules;
 		this.oldType = oldType;
@@ -41,7 +42,7 @@
 	private Object mode;
 
 	@Override
-	public void processStartElement() {
+	public void processStartElement() throws XMLStreamException, IOException {
 		if (!inW) super.processStartElement(); // don't write W content
 
 		if (localname.equals("w")) {
@@ -66,14 +67,14 @@
 	}
 
 	@Override
-	public void processCharacters() {
+	public void processCharacters() throws XMLStreamException {
 		if (inW && inAna) typeValue+=parser.getText();
 		else if (inW && inForm) formValue+=parser.getText();
 		else super.processCharacters();
 	}
 
 	@Override
-	public void processEndElement() {
+	public void processEndElement() throws XMLStreamException {
 		if (localname.equals("w")) {
 			inW = false;
 
@@ -154,6 +155,7 @@
 	}
 
 	public static void main(String args[]) {
+		try {
 		File xmlFile = new File("/home/mdecorde/TXM/corpora/XTZTEXTUALPLANS/txm/XTZTEXTUALPLANS/test.xml");
 		File tmpFile = new File("/home/mdecorde/TXM/corpora/XTZTEXTUALPLANS/txm/XTZTEXTUALPLANS/test-o.xml");
 		String oldType = "type";
@@ -165,5 +167,8 @@
 		rules.put(Pattern.compile("y.*"), "YMULTIWORD");
 		XMLTXMFileRuledConversion converter = new XMLTXMFileRuledConversion(xmlFile, rules, oldType, newType, ABANDON);
 		System.out.println(converter.process(tmpFile));
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
 	}
 }
Index: tmp/org.txm.core/src/java/org/txm/annotation/AnnotationSyMoGIHWriter.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/annotation/AnnotationSyMoGIHWriter.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/annotation/AnnotationSyMoGIHWriter.java	(revision 313)
@@ -61,9 +61,10 @@
 	 * @param annotationsToAddByEndPos
 	 * @param corpus_start_position
 	 * @param debug
-	 * @throws MalformedURLException
+	 * @throws XMLStreamException 
+	 * @throws IOException 
 	 */
-	public AnnotationSyMoGIHWriter(String textid, File xmlFile, File xmlStandOffDirectory, List<AnnotationType> types, boolean debug) throws MalformedURLException {
+	public AnnotationSyMoGIHWriter(String textid, File xmlFile, File xmlStandOffDirectory, List<AnnotationType> types, boolean debug) throws IOException, XMLStreamException {
 		super(xmlFile.toURI().toURL()); // init reader and writer
 		this.textid = textid;
 		this.filename = xmlFile.getName();
@@ -112,7 +113,7 @@
       </text>
  </TEI>*/
 
-	protected void processStartElement() {
+	protected void processStartElement() throws XMLStreamException, IOException {
 		//<coac author="gazelledess" ref="CoAc397" start="5" end="5">
 
 		/*if(localname.startsWith("actr")){
@@ -284,7 +285,7 @@
 		}
 	}
 
-	protected void processEndElement() {
+	protected void processEndElement() throws XMLStreamException {
 		boolean foundAnnot = false;
 		if (types.contains(localname) && parser.getPrefix().equals("txm")) { // skip annotation end element
 			//System.out.println(" END "+ localname);
@@ -347,6 +348,7 @@
 	}
 
 	public static void main(String strs[]){
+		try {
 		File xmlFile = new File("/home/mdecorde/TXM/corpora/TDM80J/txm/TDM80J", "tdm80j.xml");
 		File outfile = new File(xmlFile.getParentFile(), "tdm80j-tei.xml");
 
@@ -361,5 +363,8 @@
 			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
 	}
 }
\ No newline at end of file
Index: tmp/org.txm.core/src/java/org/txm/annotation/AnnotationWriter.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/annotation/AnnotationWriter.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/annotation/AnnotationWriter.java	(revision 313)
@@ -11,11 +11,14 @@
 import java.util.List;
 import java.util.logging.Level;
 
+import javax.xml.stream.XMLStreamException;
+
 import org.apache.commons.lang.StringUtils;
 import org.txm.Toolbox;
 import org.txm.annotation.repository.AnnotationEffect;
 import org.txm.annotation.repository.AnnotationType;
 import org.txm.annotation.repository.KnowledgeRepository;
+import org.txm.core.preferences.TBXPreferences;
 import org.txm.importer.ValidateXml;
 import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
 import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException;
@@ -54,8 +57,9 @@
 	 * @throws CqiServerError
 	 * @throws CqiClientException
 	 * @throws InvalidCqpIdException
+	 * @throws XMLStreamException 
 	 */
-	protected boolean writeTextAnnotationToSyMoGIH(String textid, File currentXMLFile, File currentXMLStandoffFile, File xmlStandOffDirectory) throws IOException, CqiServerError, CqiClientException, InvalidCqpIdException{
+	protected boolean writeTextAnnotationToSyMoGIH(String textid, File currentXMLFile, File currentXMLStandoffFile, File xmlStandOffDirectory) throws IOException, CqiServerError, CqiClientException, InvalidCqpIdException, XMLStreamException{
 		System.out.println("  text="+textid);
 		boolean show_debug = Log.getLevel().intValue() < Level.WARNING.intValue();
 		
@@ -84,13 +88,14 @@
 	 * @throws CqiServerError
 	 * @throws CqiClientException
 	 * @throws InvalidCqpIdException
+	 * @throws XMLStreamException 
 	 */
-	public boolean writeAnnotationsInStandoff(File resultZipFile) throws IOException, CqiServerError, CqiClientException, InvalidCqpIdException{
+	public boolean writeAnnotationsInStandoff(File resultZipFile) throws IOException, CqiServerError, CqiClientException, InvalidCqpIdException, XMLStreamException{
 		
 		List<String> textsIds = corpus.getTextsID();
 		System.out.println("Exporting annotations of "+StringUtils.join(textsIds, ", ")+".");
 
-		File resultDirectory = new File(Toolbox.getParam(Toolbox.USER_TXM_HOME), "results/"+corpus.getName()+"_annotations");
+		File resultDirectory = new File(Toolbox.getParam(TBXPreferences.USER_TXM_HOME), "results/"+corpus.getName()+"_annotations");
 		DeleteDir.deleteDirectory(resultDirectory);
 		resultDirectory.mkdirs();
 		if (!(resultDirectory.exists() && resultDirectory.canWrite())) {
@@ -130,8 +135,9 @@
 	 * @throws CqiServerError
 	 * @throws CqiClientException
 	 * @throws InvalidCqpIdException
+	 * @throws XMLStreamException 
 	 */
-	public boolean writeAnnotations(List<Annotation> allCorpusAnnotations) throws IOException, CqiServerError, CqiClientException, InvalidCqpIdException{
+	public boolean writeAnnotations(List<Annotation> allCorpusAnnotations) throws IOException, CqiServerError, CqiClientException, InvalidCqpIdException, XMLStreamException{
 		//MainCorpus corpus = CorpusManager.getCorpusManager().getCorpus(c.getName());
 		System.out.println("Saving "+allCorpusAnnotations.size()+"annotations...");
 
@@ -229,7 +235,7 @@
 	//writeAnnotationInStandoffFile(currentXMLStandoffFile, allAnnotations, annotator, tmpXMLTXMDirectory, previousXMLTXMDirectory))
 	
 	protected boolean writeAnnotationsInFile(File xmlFile, int text_start_position, 
-			ArrayList<Annotation> segmentAnnotations, ArrayList<Annotation> tokenAnnotations, File tmpXMLTXMDirectory, File previousXMLTXMDirectory) throws CqiClientException, IOException, CqiServerError, InvalidCqpIdException{
+			ArrayList<Annotation> segmentAnnotations, ArrayList<Annotation> tokenAnnotations, File tmpXMLTXMDirectory, File previousXMLTXMDirectory) throws CqiClientException, IOException, CqiServerError, InvalidCqpIdException, XMLStreamException{
 		System.out.println("Writing annotations for text "+xmlFile+" segment annotations="+segmentAnnotations.size()+" token annotations="+tokenAnnotations.size());
 		System.out.println(segmentAnnotations);
 		System.out.println(tokenAnnotations);
Index: tmp/org.txm.core/src/java/org/txm/annotation/AnnotationInjector.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/annotation/AnnotationInjector.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/annotation/AnnotationInjector.java	(revision 313)
@@ -65,9 +65,10 @@
 	 * @param annotationsToAddByEndPos
 	 * @param corpus_start_position
 	 * @param debug
-	 * @throws MalformedURLException
+	 * @throws XMLStreamException 
+	 * @throws IOException 
 	 */
-	public AnnotationInjector(File xmlFile, List<Annotation> segmentAnnotations, ArrayList<Annotation> tokenAnnotations, int corpus_start_position, boolean debug) throws MalformedURLException {
+	public AnnotationInjector(File xmlFile, List<Annotation> segmentAnnotations, ArrayList<Annotation> tokenAnnotations, int corpus_start_position, boolean debug) throws IOException, XMLStreamException {
 		super(xmlFile.toURI().toURL()); // init reader and writer
 
 		this.user = System.getProperty("user.name");
@@ -140,7 +141,7 @@
 	boolean mustChangeAnaValue = false;
 	boolean inAna = false;
 
-	protected void processStartElement() {
+	protected void processStartElement() throws XMLStreamException, IOException {
 		
 		currentStartAnnotations = annotationsToAddByStartPos.get(position_counter);
 		currentEndAnnotations = annotationsToAddByEndPos.get(position_counter);
@@ -317,7 +318,7 @@
 	}
 
 	@Override
-	public void processCharacters() {
+	public void processCharacters() throws XMLStreamException {
 		//System.out.println("processCharaters inAna="+inAna+" mustChangeAnaValue="+mustChangeAnaValue);
 		if (inAna && mustChangeAnaValue) {
 			// nothing content is already written
@@ -327,7 +328,7 @@
 		}
 	}
 
-	protected void processEndElement() {
+	protected void processEndElement() throws XMLStreamException {
 		// currentEndAnnotations =
 		// annotationsToAddByEndPos.get(position_counter); // annotation to end
 		previousEndAnnotations = annotationsToAddByEndPos.get(position_counter - 1); // existing
@@ -613,7 +614,7 @@
 	static int UPDATEDELETEADD6 = 17;
 	static int ADDDELETE2 = 18;
 
-	public static void main2(String args[]) throws IOException {
+	public static void main2(String args[]) throws IOException, XMLStreamException {
 		File xmlFile = null;
 		int corpus_start_position = 10;
 
@@ -728,6 +729,7 @@
 	}
 
 	public static void main(String[] args) {
+		try {
 		File xmlFile = new File("/home/mdecorde/TXM/corpora/TDM80J/txm/TDM80J/tdm80j.xml");
 		File outfile = new File("/home/mdecorde/TXM/corpora/TDM80J/txm/TDM80J/tdm80j-annot.xml");
 
@@ -743,12 +745,12 @@
 		for (int p : positions) tokenAnnotations.add(new Annotation("frlemma", "de", p, p+5));
 		
 		AnnotationInjector ai;
-		try {
+		
 			ai = new AnnotationInjector(xmlFile, segmentAnnotations, tokenAnnotations, 0, true);
 			System.out.println("start processing...");
 			ai.process(outfile);
 			System.out.println("Done.");
-		} catch (MalformedURLException e) {
+		} catch (Exception e) {
 			e.printStackTrace();
 		}
 	}
Index: tmp/org.txm.core/src/java/org/txm/annotation/repository/KnowledgeRepositoryManager.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/annotation/repository/KnowledgeRepositoryManager.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/annotation/repository/KnowledgeRepositoryManager.java	(revision 313)
@@ -7,6 +7,7 @@
 import org.apache.commons.io.FileUtils;
 import org.txm.Toolbox;
 import org.txm.annotation.DatabasePersistenceManager;
+import org.txm.core.preferences.TBXPreferences;
 import org.txm.objects.BaseParameters;
 import org.txm.sql.SQLConnection;
 import org.txm.utils.logger.Log;
@@ -98,7 +99,7 @@
 	
 	public static KnowledgeRepository getKnowledgeRepository(String name) {
 		KnowledgeRepository kr = null;
-		File krconf = new File(Toolbox.getParam(Toolbox.USER_TXM_HOME),"repositories/"+name+"/conf.xml");
+		File krconf = new File(Toolbox.getParam(TBXPreferences.USER_TXM_HOME),"repositories/"+name+"/conf.xml");
 		if (repositories.containsKey(name)) {
 			kr = repositories.get(name);
 		} else {
@@ -123,7 +124,7 @@
 	 */
 	public static KnowledgeRepository getKnowledgeRepository(String name, org.txm.objects.Corpus corpus) {
 		KnowledgeRepository kr = null;
-		File krconf = new File(Toolbox.getParam(Toolbox.USER_TXM_HOME),"repositories/"+name+"/conf.xml");
+		File krconf = new File(Toolbox.getParam(TBXPreferences.USER_TXM_HOME),"repositories/"+name+"/conf.xml");
 		if (repositories.containsKey(name)) {
 			kr = repositories.get(name);
 		} else {
@@ -214,7 +215,7 @@
 	public static String generateLocalURLPage(String krname, String name, String id) {
 	
 		KnowledgeRepository kr = getKnowledgeRepository(krname);
-		String path = Toolbox.getParam(Toolbox.USER_TXM_HOME)+"/repositories/"+krname;
+		String path = Toolbox.getParam(TBXPreferences.USER_TXM_HOME)+"/repositories/"+krname;
 		//File htmlTemplateFile = new File(path+"/template.html");
 		File newHtmlFile = null;
 		String htmlString;
Index: tmp/org.txm.core/src/java/org/txm/annotation/repository/LocalKnowledgeRepository.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/annotation/repository/LocalKnowledgeRepository.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/annotation/repository/LocalKnowledgeRepository.java	(revision 313)
@@ -7,6 +7,7 @@
 
 import org.txm.Toolbox;
 import org.txm.annotation.DatabasePersistenceManager;
+import org.txm.core.preferences.TBXPreferences;
 import org.txm.sql.SQLConnection;
 
 public class LocalKnowledgeRepository extends KnowledgeRepository {
@@ -26,7 +27,7 @@
 
 		String path = accessProperties.get(SQLConnection.SQL_ADDRESS);
 		if (path == null || path.trim().length() == 0) { // no address, forge one 
-			path = Toolbox.getParam(Toolbox.USER_TXM_HOME)+"/repositories/"+getName();
+			path = Toolbox.getParam(TBXPreferences.USER_TXM_HOME)+"/repositories/"+getName();
 			System.out.println("No address given to build values. No values created");
 			return true;
 		}
Index: tmp/org.txm.core/src/java/org/txm/annotation/repository/KnowledgeRepository.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/annotation/repository/KnowledgeRepository.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/annotation/repository/KnowledgeRepository.java	(revision 313)
@@ -13,6 +13,7 @@
 import org.eclipse.persistence.jpa.PersistenceProvider;
 import org.txm.Toolbox;
 import org.txm.annotation.DatabasePersistenceManager;
+import org.txm.core.preferences.TBXPreferences;
 import org.txm.utils.logger.Log;
 
 public abstract class KnowledgeRepository  { //extends Vector<AnnotationType>
@@ -62,7 +63,7 @@
 	 * @return
 	 */
 	public EntityManager initializeEntityManager(){
-		this.dbPath = Toolbox.getParam(Toolbox.USER_TXM_HOME)+"/repositories/"+name;
+		this.dbPath = Toolbox.getParam(TBXPreferences.USER_TXM_HOME)+"/repositories/"+name;
 		//System.out.println("KnowledgeRepository.initializeEntityManager [DB @ "+dbPath+"]");
 		EntityManagerFactory emf;
 		HashMap<String, Object> properties = new HashMap<String, Object>();
Index: tmp/org.txm.core/src/java/org/txm/annotation/PropertiesRecoder.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/annotation/PropertiesRecoder.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/annotation/PropertiesRecoder.java	(revision 313)
@@ -1,6 +1,7 @@
 package org.txm.annotation;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
@@ -10,8 +11,8 @@
 import org.txm.importer.StaxIdentityParser;
 
 public class PropertiesRecoder extends StaxIdentityParser {
-	
-	public PropertiesRecoder(File xmlFile, HashSet<String> fromProperties, HashSet<String> toProperties) {
+
+	public PropertiesRecoder(File xmlFile, HashSet<String> fromProperties, HashSet<String> toProperties) throws IOException, XMLStreamException {
 		super(xmlFile);
 	}
 	boolean startW = false, startAna = false;
@@ -19,9 +20,9 @@
 	String[] currentAnaValues = {"","",""};
 	StringBuilder anaValue = new StringBuilder();
 	String EMPTY = "";
-	
+
 	@Override
-	public void processStartElement() {
+	public void processStartElement() throws XMLStreamException, IOException {
 		if (localname.equals("w")) {
 			startW = true;
 			anaValues.clear();
@@ -45,21 +46,21 @@
 			super.processStartElement();
 		}
 	}
-	
+
 	@Override
-	public void processCharacters() {
+	public void processCharacters() throws XMLStreamException {
 		if (startAna) {
 			anaValue.append(parser.getText());
 		} else {
 			super.processCharacters();
 		}
 	};
-	
+
 	@Override
-	public void processEndElement() {
+	public void processEndElement() throws XMLStreamException {
 		if (localname.equals("w")) {
 			startW = false;
-			
+
 			for (String[] values : anaValues) {
 				try {
 					writer.writeStartElement("txm:ana");
@@ -72,7 +73,7 @@
 					e.printStackTrace();
 				}
 			}
-			
+
 			super.processEndElement();
 		} else if (localname.equals("ana")) {
 			if (startW) {
@@ -84,14 +85,18 @@
 			super.processEndElement();
 		}
 	}
-	
+
 	public static void main(String args[]) {
-		File xmlFile = new File("/home/mdecorde/TEMP/test.xml");
-		File outfile = new File("/home/mdecorde/TEMP/test-o.xml");
-		HashSet<String> fromProperties = new HashSet<String>();
-		HashSet<String> toProperties = new HashSet<String>();
-		
-		PropertiesRecoder recoder = new PropertiesRecoder(xmlFile, fromProperties, toProperties);
-		System.out.println("Result: "+recoder.process(outfile));
+		try {
+			File xmlFile = new File("/home/mdecorde/TEMP/test.xml");
+			File outfile = new File("/home/mdecorde/TEMP/test-o.xml");
+			HashSet<String> fromProperties = new HashSet<String>();
+			HashSet<String> toProperties = new HashSet<String>();
+
+			PropertiesRecoder recoder = new PropertiesRecoder(xmlFile, fromProperties, toProperties);
+			System.out.println("Result: "+recoder.process(outfile));
+		} catch(Exception e) {
+			e.printStackTrace();
+		}
 	}
 }
Index: tmp/org.txm.core/src/java/org/txm/test/TestConcordance.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/test/TestConcordance.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/txm/test/TestConcordance.java	(revision 313)
@@ -1,126 +0,0 @@
-package org.txm.test;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.txm.functions.ReferencePattern;
-import org.txm.functions.concordances.Concordance;
-import org.txm.functions.concordances.comparators.LexicographicKeywordComparator;
-import org.txm.functions.concordances.comparators.LexicographicLeftContextComparator;
-import org.txm.functions.concordances.comparators.LexicographicRightContextComparator;
-import org.txm.functions.concordances.comparators.LineComparator;
-import org.txm.functions.concordances.comparators.NullComparator;
-import org.txm.functions.concordances.comparators.PropertiesReferenceComparator;
-import org.txm.searchengine.cqp.corpus.Corpus;
-import org.txm.searchengine.cqp.corpus.CorpusManager;
-import org.txm.searchengine.cqp.corpus.Property;
-import org.txm.searchengine.cqp.corpus.query.Query;
-
-/**
- * Test class for the concordances
- * 
- * @author mdecorde
- *
- */
-public class TestConcordance {
-	/**
-	 * the corpus name to use
-	 */
-	static String CORPUS = "DISCOURS"; //$NON-NLS-1$
-	
-	public static boolean allTests(File outdir) {
-		TestConcordance tester = new TestConcordance();
-		return tester.test1(outdir);
-	}
-	
-	/**
-	 * First test
-	 * @param outdir : the out folder
-	 */
-	public boolean test1(File outdir) {
-		return test(new File(outdir, TestConcordance.class.getName()+"_test1.csv"), CORPUS, null, "je", //$NON-NLS-1$ //$NON-NLS-2$
-				Arrays.asList("word"), Arrays.asList("word"),Arrays.asList("word"),  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-				Arrays.asList("word"), Arrays.asList("word"),Arrays.asList("word"),  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-				Arrays.asList("text_id", "text_loc"), Arrays.asList("text_id"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-				10, 40, null);
-	}
-	
-	private boolean test(File outfile, String corpusname, String subcorpusname, String queryString,
-			List<String> leftCSortPropertiesString, List<String> rightCSortPropertiesString, List<String> keywordSortPropertiesString,
-			List<String> leftCViewPropertiesString, List<String> rightCViewPropertiesString, List<String> keywordViewPropertiesString,
-			List<String> refPatternsString, List<String> refAnalysePatternString, int leftContextSize, int rightContextSize, String sortBy) {
-		try {
-			Corpus corpus = CorpusManager.getCorpusManager().getCorpus(corpusname);
-			if (subcorpusname != null) {
-				corpus = corpus.getSubcorpusByName(subcorpusname);
-			}
-			Query query = new Query(Query.fixQuery(queryString));
-			
-			List<Property> leftCSortProperties = new ArrayList<Property>();
-			for (String p : leftCSortPropertiesString) leftCSortProperties.add(corpus.getProperty(p));
-			
-			List<Property> rightCSortProperties =  new ArrayList<Property>();
-			for (String p : rightCSortPropertiesString) rightCSortProperties.add(corpus.getProperty(p));
-			
-			List<Property> keywordSortProperties =  new ArrayList<Property>();
-			for (String p : keywordSortPropertiesString) keywordSortProperties.add(corpus.getProperty(p));
-			
-			List<Property> leftCViewProperties = new ArrayList<Property>();
-			for (String p : leftCViewPropertiesString) leftCViewProperties.add(corpus.getProperty(p));
-			
-			List<Property> rightCViewProperties =  new ArrayList<Property>();
-			for (String p : rightCViewPropertiesString) rightCViewProperties.add(corpus.getProperty(p));
-			
-			List<Property> keywordViewProperties =  new ArrayList<Property>();
-			for (String p : keywordViewPropertiesString) keywordViewProperties.add(corpus.getProperty(p));
-
-			ArrayList<Property> refPatterns = new ArrayList<Property>();
-			for (String p : refPatternsString) {
-				String[] split = p.split("_",2); //$NON-NLS-1$
-				if (split != null && split[0].length() > 0 && split[1].length() > 0) {
-					refPatterns.add(corpus.getStructuralUnit(split[0]).getProperty(split[1]));
-				} else {
-					refPatterns.add(corpus.getProperty(p));
-				}
-			}
-			ReferencePattern referencePattern = new ReferencePattern(refPatterns);
-			
-			refPatterns = new ArrayList<Property>();
-			for (String p : refAnalysePatternString) {
-				String[] split = p.split("_",2); //$NON-NLS-1$
-				if (split != null && split[0].length() > 0 && split[1].length() > 0) {
-					refPatterns.add(corpus.getStructuralUnit(split[0]).getProperty(split[1]));
-				} else {
-					refPatterns.add(corpus.getProperty(p));
-				}
-			}
-			ReferencePattern refAnalysePattern = new ReferencePattern(refPatterns);
-
-
-			Concordance conc = new Concordance(corpus, query,
-					leftCSortProperties, rightCSortProperties, keywordSortProperties,
-					leftCViewProperties, rightCViewProperties, keywordViewProperties,
-					referencePattern, refAnalysePattern, 
-					leftContextSize, rightContextSize);
-			conc.getLines(0, conc.getNLines());
-			
-			if (sortBy != null) {
-				LineComparator comparator;
-				if ("null".equals(sortBy)) comparator = new NullComparator(); //$NON-NLS-1$
-				else if ("lexicographic".equals(sortBy)) comparator = new LexicographicKeywordComparator(); //$NON-NLS-1$
-				else if ("leftcontext".equals(sortBy)) comparator = new LexicographicLeftContextComparator(); //$NON-NLS-1$
-				else if ("rightcontext".equals(sortBy)) comparator = new LexicographicRightContextComparator(); //$NON-NLS-1$
-				else if ("reference".equals(sortBy)) comparator = new PropertiesReferenceComparator(); //$NON-NLS-1$
-				else comparator = new NullComparator();
-				conc.sort(comparator);
-			}
-			conc.toTxt(outfile, "UTF-8", "\t", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-		} catch (Exception e) {
-			org.txm.utils.logger.Log.printStackTrace(e);
-			return false;
-		}
-		return true;
-	}
-}
Index: tmp/org.txm.core/src/java/org/txm/MemEngine.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/MemEngine.java	(revision 0)
+++ tmp/org.txm.core/src/java/org/txm/MemEngine.java	(revision 313)
@@ -0,0 +1,25 @@
+package org.txm;
+
+/**
+ * Abstract class of an Engine that does not needs third application/server to work (eg. CQPlib)
+ * 
+ * @author mdecorde
+ *
+ */
+public abstract class MemEngine extends Engine {
+
+	@Override
+	public boolean isDistant() {
+		return false;
+	}
+
+	@Override
+	public boolean connect() {
+		return true;
+	}
+
+	@Override
+	public boolean disconnect() {
+		return false;
+	}
+}

Property changes on: tmp/org.txm.core/src/java/org/txm/MemEngine.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.core/src/java/org/txm/Engine.java
===================================================================
--- tmp/org.txm.core/src/java/org/txm/Engine.java	(revision 0)
+++ tmp/org.txm.core/src/java/org/txm/Engine.java	(revision 313)
@@ -0,0 +1,83 @@
+package org.txm;
+
+/**
+ * Extension point for an Engine. It is a service that may be used by TXM commands
+ * 
+ * The Toolbox manages the services life-cycle 
+ * 
+ * @author mdecorde
+ *
+ */
+public abstract class Engine {
+	
+	public static final String ENGINE_EXTENSION_POINT_ID = "org.txm.engine";
+	
+	/**
+	 * if the method returns false then the Toolbox is not initialized
+	 * 
+	 * @return 
+	 */
+	public abstract boolean isMandatory(); // for now the Toolbox has no mandatory engine request
+	
+	/**
+	 * if the method returns false, the TBX does not need to call start and stop methods
+	 * @return
+	 */
+	public abstract boolean isDistant();
+	
+	/**
+	 * called to now if the Engine may be used
+	 * 
+	 * @return
+	 */
+	public abstract boolean isReady();
+	
+	/**
+	 * Initialize the Engine, optional if the Engine is distant
+	 * @return
+	 */
+	public abstract boolean start();
+	
+	/**
+	 * Called to start a session in the Engine
+	 * @return
+	 */
+	public abstract boolean connect();
+	
+	/**
+	 * Called to end a session in the Engine
+	 * @return
+	 */
+	public abstract boolean disconnect();
+	
+	/**
+	 * Close the Engine, optional if the Engine is distant
+	 * @return
+	 */
+	public abstract boolean stop();
+	
+	/**
+	 * Shortcut method to restart an Engine
+	 * 
+	 * @return
+	 */
+	public boolean restart() {
+		return disconnect() && stop() && start();
+	}
+	
+	/**
+	 * Shortcut to restart a session with the Engine
+	 * @return
+	 */
+	public boolean reconnect() {
+		return disconnect() && connect();
+	}
+	
+	/**
+	 * Shortcut to restart and reconnect to an engine
+	 * @return
+	 */
+	public boolean restartAndReconnect() {
+		return disconnect() && stop() && start() && connect();
+	}
+}

Property changes on: tmp/org.txm.core/src/java/org/txm/Engine.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.core/src/java/org/kohsuke/args4j/spi/MultiValueFieldSetter.java
===================================================================
--- tmp/org.txm.core/src/java/org/kohsuke/args4j/spi/MultiValueFieldSetter.java	(revision 312)
+++ tmp/org.txm.core/src/java/org/kohsuke/args4j/spi/MultiValueFieldSetter.java	(revision 313)
@@ -58,11 +58,11 @@
 
     private void doAddValue(Object bean, Object value) throws IllegalAccessException {
         Object o = f.get(bean);
-        if(o==null) {
-            o = new ArrayList();
+        if (o==null) {
+            o = new ArrayList<Object>();
             f.set(bean,o);
         }
-        if(!(o instanceof List))
+        if (!(o instanceof List))
             throw new IllegalAnnotationError(Messages.ILLEGAL_LIST.format(f));
 
         ((List)o).add(value);
Index: tmp/org.txm.core/build.properties
===================================================================
--- tmp/org.txm.core/build.properties	(revision 312)
+++ tmp/org.txm.core/build.properties	(revision 313)
@@ -5,7 +5,6 @@
                lib/antlr-2.7.7.jar,\
                lib/asm-analysis-2.2.3.jar,\
                lib/asm-tree-2.2.3.jar,\
-               lib/colt-1.2.0.jar,\
                lib/concurrent-1.3.4.jar,\
                lib/dom4j-1.6.1.jar,\
                lib/forms-1.0.7.jar,\
@@ -17,14 +16,11 @@
                lib/looks-2.0.1.jar,\
                lib/macSpecific.jar,\
                lib/quaqua.jar,\
-               lib/REngine.jar,\
-               lib/RserveEngine.jar,\
                lib/rtfCleaner.jar,\
                lib/swing-layout-1.0.3.jar,\
                .,\
                lib/juniversalchardet-1.0.3.jar,\
                lib/textcat-1.0.1.jar,\
-               lib/saxon9he.jar,\
                lib/jtidy-r938.jar,\
                lib/json-20090211.jar,\
                lib/juh-3.2.1.jar,\
@@ -49,7 +45,6 @@
                bin/org/kohsuke/,\
                bin/org/txm/functions/,\
                bin/org/txm/images/,\
-               bin/org/txm/renderer/,\
                bin/org/txm/searchengine/,\
                bin/org/txm/xml/,\
                bin/org/txm/css/,\
@@ -60,7 +55,6 @@
                bin/org/txm/package.html,\
                bin/org/txm/sql/,\
                bin/org/txm/stat/,\
-               bin/org/txm/tbx/,\
                bin/org/txm/tests/,\
                bin/org/txm/ts/,\
                bin/org/txm/utils/
Index: tmp/org.txm.core/plugin.xml
===================================================================
--- tmp/org.txm.core/plugin.xml	(revision 312)
+++ tmp/org.txm.core/plugin.xml	(revision 313)
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?eclipse version="3.4"?>
 <plugin>
+   <extension-point id="org.txm.engine" name="Engine" schema="schema/engine.exsd"/>
 
 </plugin>
Index: tmp/org.txm.core/schema/engine.exsd
===================================================================
--- tmp/org.txm.core/schema/engine.exsd	(revision 0)
+++ tmp/org.txm.core/schema/engine.exsd	(revision 313)
@@ -0,0 +1,119 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.txm.core" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="org.txm.core" id="org.txm.engine" name="Engine"/>
+      </appinfo>
+      <documentation>
+         A service with a start, connect, disconnect and stop lifecycle
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <choice minOccurs="1" maxOccurs="unbounded">
+            <element ref="Engine"/>
+         </choice>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="Engine">
+      <complexType>
+         <attribute name="class" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn="org.txm.Engine:"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="description" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>

Property changes on: tmp/org.txm.core/schema/engine.exsd
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Index: tmp/org.txm.core/.classpath
===================================================================
--- tmp/org.txm.core/.classpath	(revision 312)
+++ tmp/org.txm.core/.classpath	(revision 313)
@@ -38,7 +38,6 @@
 	<classpathentry kind="src" path="src/java"/>
 	<classpathentry kind="src" path="test"/>
 	<classpathentry exported="true" kind="lib" path="bin/" sourcepath="src/java"/>
-	<classpathentry excluding="org/txm/importer/graal/xsl/" kind="src" path="src/groovy"/>
 	<classpathentry kind="src" path="res"/>
 	<classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
 	<classpathentry exported="true" kind="lib" path="lib/hsqldb.jar"/>
Index: tmp/org.txm.core/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.core/META-INF/MANIFEST.MF	(revision 312)
+++ tmp/org.txm.core/META-INF/MANIFEST.MF	(revision 313)
@@ -4,17 +4,16 @@
 Bundle-SymbolicName: org.txm.core;singleton:=true
 Bundle-Version: 0.7.0.qualifier
 Bundle-Activator: org.txm.toolbox.Activator
-Require-Bundle: org.eclipse.core.runtime,
- org.txm.statsengine.r.core;bundle-version="1.0.0";visibility:=reexport,
+Require-Bundle: org.txm.utils;bundle-version="1.0.0";visibility:=reexport,
+ org.eclipse.core.runtime,
  org.eclipse.osgi.util;bundle-version="3.2.0",
- org.txm.lexicon.core;bundle-version="1.0.0",
  org.eclipse.core.net,
  org.eclipse.osgi,
  org.txm.libs.groovy-all;bundle-version="1.0.0",
  org.eclipse.persistence.jpa;bundle-version="2.6.0",
  javax.persistence;bundle-version="2.1.0",
  org.eclipse.persistence.jpa.jpql;bundle-version="2.6.0",
- org.txm.utils;bundle-version="1.0.0";visibility:=reexport
+ org.txm.statsengine.r.core;bundle-version="1.0.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Export-Package: EDU.oswego.cs.dl.util.concurrent,
  EDU.oswego.cs.dl.util.concurrent.misc,
@@ -71,24 +70,6 @@
  com.jgoodies.looks.plastic,
  com.jgoodies.looks.plastic.theme,
  com.jgoodies.looks.windows,
- filters.BuildXmlLiturgie,
- filters.Concatenator,
- filters.CutHeader,
- filters.EliminateWhiteSpaces,
- filters.FusionHeader,
- filters.FusionXmlHeaderBody,
- filters.MinimalFilter,
- filters.OneOpenTagPerLine,
- filters.OneTagPerLine,
- filters.ProcessEnclitics,
- filters.ProcessQuotes,
- filters.RegexFilter,
- filters.ReunitBrokenTags,
- filters.ReunitBrokenWords,
- filters.TagSentences,
- filters.Tokeniser,
- filters.WordInternalElement,
- filters.eliminateNAttributes,
  jline,
  junit.extensions,
  junit.framework,
@@ -253,97 +234,33 @@
  org.txm.annotation.repository,
  org.txm.annotation.storage.temporary,
  org.txm.annotation.temporary,
- org.txm.ant,
  org.txm.core.messages,
  org.txm.core.preferences,
  org.txm.core.results,
  org.txm.core.results.comparators,
- org.txm.export,
- org.txm.export.conll2009,
- org.txm.export.ts,
  org.txm.functions,
- org.txm.functions.concordances,
- org.txm.functions.concordances.comparators,
  org.txm.functions.diagnostic,
  org.txm.functions.internal,
- org.txm.functions.mesures,
  org.txm.functions.parabrowser,
  org.txm.functions.parallelcontexts,
  org.txm.functions.preview,
- org.txm.functions.referencer,
  org.txm.functions.selection,
  org.txm.functions.summary,
  org.txm.importer,
- org.txm.importer.RGAQCJ,
- org.txm.importer.alceste,
- org.txm.importer.bfm,
- org.txm.importer.bvh,
- org.txm.importer.corptef,
  org.txm.importer.cwb,
- org.txm.importer.discours,
- org.txm.importer.doc,
- org.txm.importer.factiva,
  org.txm.importer.filters,
- org.txm.importer.fleurs,
- org.txm.importer.frantext,
- org.txm.importer.graal,
- org.txm.importer.hyperbase,
- org.txm.importer.hyperprince,
- org.txm.importer.lasla,
- org.txm.importer.limsi,
- org.txm.importer.perrault,
- org.txm.importer.quick,
  org.txm.importer.scripting,
- org.txm.importer.teicmc,
- org.txm.importer.tmx,
- org.txm.importer.transcriber,
- org.txm.importer.wtc,
- org.txm.importer.xml,
- org.txm.importer.xmltxm,
- org.txm.importer.xmltxmpara,
- org.txm.importer.xtz,
- org.txm.macro.annotation,
- org.txm.macro.commands,
- org.txm.macro.cqp,
- org.txm.macro.csv,
- org.txm.macro.edition,
- org.txm.macro.misc,
- org.txm.macro.r,
- org.txm.macro.stats,
- org.txm.macro.text,
- org.txm.macro.transcription,
- org.txm.macro.txt,
- org.txm.macro.xml,
- org.txm.macro.xsl,
- org.txm.macroproto,
- org.txm.macroproto.edition,
- org.txm.macroproto.export,
- org.txm.macroproto.importer,
- org.txm.macroproto.partition,
- org.txm.macroproto.txt,
  org.txm.metadatas,
  org.txm.objects,
- org.txm.scripts,
- org.txm.scripts.clix,
- org.txm.scripts.i18n,
- org.txm.scripts.teitxm,
- org.txm.scripts.tigersearch,
  org.txm.searchengine.cqp,
  org.txm.searchengine.cqp.clientExceptions,
  org.txm.searchengine.cqp.corpus,
  org.txm.searchengine.cqp.corpus.query,
  org.txm.searchengine.cqp.serverException,
- org.txm.setup,
  org.txm.sql,
  org.txm.stat.utils,
- org.txm.svn,
- org.txm.sw,
- org.txm.tal,
- org.txm.tal.melt,
- org.txm.tal.stanford,
  org.txm.test,
  org.txm.tests,
- org.txm.tokenizer,
  org.txm.toolbox,
  org.txm.utils,
  org.w3c.tidy,
Index: tmp/org.txm.core.tests/META-INF/MANIFEST.MF
===================================================================
--- tmp/org.txm.core.tests/META-INF/MANIFEST.MF	(revision 312)
+++ tmp/org.txm.core.tests/META-INF/MANIFEST.MF	(revision 313)
@@ -7,5 +7,19 @@
 Require-Bundle: org.txm.lexicon.core,
  org.eclipse.core.runtime;bundle-version="3.10.0",
  org.txm.core;bundle-version="0.7.0",
- CQP;bundle-version="1.1.0",
- org.txm.statsengine.r.core
+ org.txm.statsengine.r.core,
+ org.txm.ca.core;bundle-version="1.0.0",
+ org.txm.cah.core;bundle-version="1.0.0",
+ org.txm.chartsengine.core;bundle-version="1.0.0",
+ org.txm.chartsengine.jfreechart.core;bundle-version="1.0.0",
+ org.txm.chartsengine.r.core;bundle-version="1.0.0",
+ org.txm.concordance.core;bundle-version="1.0.0",
+ org.txm.cooccurrence.core;bundle-version="1.0.0",
+ org.txm.index.core;bundle-version="1.0.0",
+ org.txm.lexicaltable.core;bundle-version="1.0.0",
+ org.txm.partition.core;bundle-version="1.0.0",
+ org.txm.progression.core;bundle-version="1.0.0",
+ org.txm.specificities.core;bundle-version="1.0.0",
+ org.txm.referencer.core;bundle-version="1.0.0",
+ org.txm.textsbalance.core;bundle-version="1.0.0",
+ org.txm.wordcloud.core;bundle-version="1.0.0"
Index: tmp/org.txm.core.tests/src/org/txm/core/tests/manual/ToolBoxTesterRCPApplication.java
===================================================================
--- tmp/org.txm.core.tests/src/org/txm/core/tests/manual/ToolBoxTesterRCPApplication.java	(revision 312)
+++ tmp/org.txm.core.tests/src/org/txm/core/tests/manual/ToolBoxTesterRCPApplication.java	(revision 313)
@@ -80,7 +80,7 @@
 			System.out.println("**************************************************");
 			System.out.println("** Lexicon tests");
 			System.out.println("**************************************************");
-			Lexicon lex1 = corpus.getLexicon(word);
+			Lexicon lex1 = Lexicon.getLexicon(corpus, word);
 			System.out.println("Details: " + lex1.getDetails());
 			
 			//FIXME: end of tests
