Révision 403

tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesTableLabelProvider.java (revision 403)
58 58
	public SpecificitiesTableLabelProvider() {
59 59
		//this.partindexes = partindexes;
60 60
		//showPValues = "true".equals(Toolbox.getParam(SpecificitiesPreferencePage.SPECIF_PVALUES)); //$NON-NLS-1$
61
		this.format = TXMPreferences.getString(SpecificitiesPreferences.PREFERENCES_NODE, SpecificitiesPreferences.FORMAT);
61
		this.format = TXMPreferences.getString(SpecificitiesPreferences.FORMAT, SpecificitiesPreferences.PREFERENCES_NODE);
62 62
		if (format == null || format.trim().length() == 0) format = "%,.1f"; //$NON-NLS-1$
63 63
	}
64 64

  
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/handlers/ComputeSpecifities.java (revision 403)
43 43
import org.txm.core.preferences.TXMPreferences;
44 44
import org.txm.lexicaltable.core.functions.LexicalTable;
45 45
import org.txm.lexicaltable.core.preferences.LexicalTablePreferences;
46
import org.txm.rcp.editors.TXMEditorPart;
47
import org.txm.rcp.editors.TXMResultEditorInput;
46 48
import org.txm.rcp.handlers.BaseAbstractHandler;
47 49
import org.txm.rcp.JobsTimer;
48 50
import org.txm.rcp.Messages;
......
112 114
			return null;
113 115
		}
114 116
		Object s = selection.getFirstElement();
115
		final int maxScore = TXMPreferences.getInt(SpecificitiesPreferences.PREFERENCES_NODE, SpecificitiesPreferences.MAX_SCORE);
117
		final int maxScore = TXMPreferences.getInt(SpecificitiesPreferences.MAX_SCORE, SpecificitiesPreferences.PREFERENCES_NODE);
116 118
		if(s instanceof Partition) {
117 119
			final Partition partition = (Partition) selection.getFirstElement();
118
			final int Fmin = TXMPreferences.getInt(LexicalTablePreferences.PREFERENCES_NODE, LexicalTablePreferences.F_MIN);
120
			final int Fmin = TXMPreferences.getInt(LexicalTablePreferences.F_MIN, LexicalTablePreferences.PREFERENCES_NODE);
119 121

  
120 122
			final ComputeSpecificitiesDialog d = new ComputeSpecificitiesDialog(window.getShell(), partition, false);
121 123
			int code = d.open();
......
350 352
		else if(s instanceof SpecificitesResult) {
351 353
			SpecificitesResult specifRes = (SpecificitesResult) s;
352 354
			Partition partition = null;
353
			IEditorInput editorInput = null;
355
			TXMResultEditorInput editorInput = null;
354 356

  
355 357
			if(specifRes.getLexicalTable() != null) {
356 358
				if(specifRes.getLexicalTable().getPartition() != null) {
......
365 367
				editorInput = new SpecificitiesResultEditorInput(specifRes, specifRes.getCorpus());
366 368
			}
367 369

  
368
			IWorkbenchPage page = window.getActivePage();
369
			try {
370
				page.openEditor(editorInput, SpecificitiesTableEditor.ID);
371
			}
372
			catch(PartInitException e) {
373
				System.err.println(Messages.CorporaView_5 + e);
374
			}
370
			TXMEditorPart.openEditor(editorInput, SpecificitiesTableEditor.ID);
375 371
		}
376 372

  
377 373
		return null;
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/handlers/ComputeSpecifictiesBarChart.java (revision 403)
87 87
			specificitiesResult.setSelectedSpecificitiesIndex(specificteIndices);
88 88

  
89 89
			// Create and open the chart editor
90
			final ChartEditorPart editor = SWTChartsComponentsProvider.getCurrent().openEditor(specificitiesResult, SpecificitiesPreferences.PREFERENCES_NODE);
90
			final ChartEditorPart editor = SWTChartsComponentsProvider.getCurrent().openEditor(specificitiesResult);
91 91
			editor.getEditorInput().setAlwaysRecreateEditor(true);
92 92

  
93 93
			
......
98 98
				final ToolItem groupBarsByLines = new ToolItem(toolBar, SWT.CHECK);
99 99
				groupBarsByLines.setToolTipText(SpecificitiesUIMessages.SpecificitiesPreferencePage_4);
100 100
				groupBarsByLines.setImage(IImageKeys.getImage(ComputeSpecifities.class, "icons/silk_group_bars_by_lines.png"));
101
				groupBarsByLines.setSelection(TXMPreferences.getBoolean(SpecificitiesPreferences.PREFERENCES_NODE, editor.getResultData(), SpecificitiesPreferences.CHART_TRANSPOSE));
101
				groupBarsByLines.setSelection(specificitiesResult.getBooleanParameterValue(SpecificitiesPreferences.CHART_TRANSPOSE));
102 102
				groupBarsByLines.addSelectionListener(new SelectionListener() {
103 103
					
104 104
					@Override
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Chi2.java (revision 403)
1
package org.txm.specificities.core.functions;
2

  
3
import org.txm.functions.contrasts.Contrast;
4
import org.txm.lexicaltable.core.functions.LexicalTable;
5
import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
6
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
7
import org.txm.searchengine.cqp.corpus.Corpus;
8
import org.txm.searchengine.cqp.corpus.Partition;
9
import org.txm.searchengine.cqp.corpus.Property;
10
import org.txm.searchengine.cqp.corpus.Subcorpus;
11
import org.txm.statsengine.core.StatException;
12
import org.txm.statsengine.r.core.RWorkspace;
13

  
14
public class Chi2 extends Contrast {
15
	
16
	private ILexicalTable itable;
17
	
18
	public Chi2(Corpus corpus, Subcorpus subcorpus, Property property)
19
			throws StatException, CqiClientException {
20
		super(corpus, subcorpus, property);
21
	}
22

  
23
	public Chi2(Partition partition, Property property, int Fmin)
24
			throws StatException, CqiClientException {
25
		super(partition, property, Fmin);
26
	}
27

  
28

  
29
	public Chi2(LexicalTable table) {
30
		super(table);
31
	}
32

  
33
	@Override
34
	public boolean compute() throws StatException {
35
		itable = table.getData();
36
		colNames = itable.getColNames().asStringsArray();
37
		rowNames = itable.getRowNames().asStringsArray();
38
		frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(itable.getSymbol());
39
		
40
		// compute
41
		String cmd = "mat <- "+itable.getSymbol()+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$
42
					" mat2 <- rowSums(mat) %o% colSums(mat) / sum(mat)"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$
43
					symbol +" <- (mat - mat2) ^ 2 / mat2"; //$NON-NLS-1$
44
		indices = RWorkspace.getRWorkspaceInstance().evalToDouble2D(cmd);
45
		return true;
46
	}
47

  
48
	@Override
49
	public String getName() {
50
		return "Chi2"; //$NON-NLS-1$
51
	}
52

  
53
	@Override
54
	public String getSimpleName() {
55
		// TODO Auto-generated method stub
56
		return null;
57
	}
58

  
59
	@Override
60
	public String getDetails() {
61
		// TODO Auto-generated method stub
62
		return null;
63
	}
64

  
65
	@Override
66
	public void clean() {
67
		// TODO Auto-generated method stub
68
		
69
	}
70
}
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/SpecificitesException.java (revision 403)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
25
// $LastChangedRevision: 2386 $
26
// $LastChangedBy: mdecorde $ 
27
//
28
package org.txm.specificities.core.functions;
29

  
30
// TODO: Auto-generated Javadoc
31
/**
32
 * The Class SpecificitesException.
33
 *
34
 * @author sloiseau
35
 */
36
public class SpecificitesException extends Exception {
37

  
38
	/** The Constant serialVersionUID. */
39
	private static final long serialVersionUID = 4206288552541531386L;
40

  
41
	/**
42
	 * Instantiates a new specificites exception.
43
	 */
44
	public SpecificitesException() {
45
		super();
46
		// TODO Auto-generated constructor stub
47
	}
48

  
49
	/**
50
	 * Instantiates a new specificites exception.
51
	 *
52
	 * @param arg0 the arg0
53
	 * @param arg1 the arg1
54
	 */
55
	public SpecificitesException(String arg0, Throwable arg1) {
56
		super(arg0, arg1);
57
		// TODO Auto-generated constructor stub
58
	}
59

  
60
	/**
61
	 * Instantiates a new specificites exception.
62
	 *
63
	 * @param arg0 the arg0
64
	 */
65
	public SpecificitesException(String arg0) {
66
		super(arg0);
67
		// TODO Auto-generated constructor stub
68
	}
69

  
70
	/**
71
	 * Instantiates a new specificites exception.
72
	 *
73
	 * @param arg0 the arg0
74
	 */
75
	public SpecificitesException(Throwable arg0) {
76
		super(arg0);
77
		// TODO Auto-generated constructor stub
78
	}
79
}
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificites2.java (revision 403)
1
package org.txm.specificities.core.functions;
2

  
3
import org.txm.functions.contrasts.Contrast;
4
import org.txm.lexicaltable.core.functions.LexicalTable;
5
import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
6
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
7
import org.txm.searchengine.cqp.corpus.Corpus;
8
import org.txm.searchengine.cqp.corpus.Partition;
9
import org.txm.searchengine.cqp.corpus.Property;
10
import org.txm.searchengine.cqp.corpus.Subcorpus;
11
import org.txm.specificities.core.statsengine.r.function.SpecificitiesImpl;
12
import org.txm.statsengine.core.StatException;
13
import org.txm.statsengine.r.core.RWorkspace;
14

  
15
public class Specificites2 extends Contrast {
16

  
17
	private ILexicalTable itable;
18

  
19
	public Specificites2(Corpus corpus, Subcorpus subcorpus, Property property)
20
			throws StatException, CqiClientException {
21
		super(corpus, subcorpus, property);
22
	}
23

  
24
	public Specificites2(Partition partition, Property property, int Fmin)
25
			throws StatException, CqiClientException {
26
		super(partition, property, Fmin);
27
	}
28

  
29

  
30
	public Specificites2(LexicalTable table) {
31
		super(table);
32
	}
33

  
34
	public boolean compute() throws StatException {
35
		itable = table.getData();
36
		colNames = itable.getColNames().asStringsArray();
37
		rowNames = itable.getRowNames().asStringsArray();
38
		frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(itable.getSymbol());
39

  
40
		// compute
41
		indices = new SpecificitiesImpl(itable).getScores(); //$NON-NLS-1$
42
		return true;
43
	}
44

  
45
	@Override
46
	public String getName() {
47
		return "Specif2"; //$NON-NLS-1$
48
	}
49

  
50
	@Override
51
	public String getSimpleName() {
52
		// TODO Auto-generated method stub
53
		return null;
54
	}
55

  
56
	@Override
57
	public String getDetails() {
58
		// TODO Auto-generated method stub
59
		return null;
60
	}
61

  
62
	@Override
63
	public void clean() {
64
		// TODO Auto-generated method stub
65

  
66
	}
67
}
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/SpecificitesResult.java (revision 403)
39 39

  
40 40
import org.rosuda.REngine.REXPMismatchException;
41 41
import org.rosuda.REngine.Rserve.RserveException;
42
import org.txm.functions.Function;
42
import org.txm.functions.TXMCommand;
43 43
import org.txm.lexicaltable.core.functions.LexicalTable;
44 44
import org.txm.lexicaltable.core.functions.LexicalTableFactory;
45 45
import org.txm.lexicon.core.corpusengine.cqp.Lexicon;
......
63 63
 * @author sloiseau
64 64
 * 
65 65
 */
66
public class SpecificitesResult extends Function  {
66
public class SpecificitesResult extends TXMCommand  {
67 67

  
68 68
	public static int MAXSPECIF = 1000;
69 69

  
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/___SpecificitesException.java (revision 403)
1
// Copyright © 2010-2013 ENS de Lyon.
2
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of
3
// Lyon 2, University of Franche-Comté, University of Nice
4
// Sophia Antipolis, University of Paris 3.
5
// 
6
// The TXM platform is free software: you can redistribute it
7
// and/or modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation,
9
// either version 2 of the License, or (at your option) any
10
// later version.
11
// 
12
// The TXM platform is distributed in the hope that it will be
13
// useful, but WITHOUT ANY WARRANTY; without even the implied
14
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15
// PURPOSE. See the GNU General Public License for more
16
// details.
17
// 
18
// You should have received a copy of the GNU General
19
// Public License along with the TXM platform. If not, see
20
// http://www.gnu.org/licenses.
21
// 
22
// 
23
// 
24
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $
25
// $LastChangedRevision: 2386 $
26
// $LastChangedBy: mdecorde $ 
27
//
28
package org.txm.specificities.core.functions;
29

  
30
// TODO: Auto-generated Javadoc
31
/**
32
 * The Class SpecificitesException.
33
 *
34
 * @author sloiseau
35
 */
36
//FIXME: not used?
37
public class ___SpecificitesException extends Exception {
38

  
39
	/** The Constant serialVersionUID. */
40
	private static final long serialVersionUID = 4206288552541531386L;
41

  
42
	/**
43
	 * Instantiates a new specificites exception.
44
	 */
45
	public ___SpecificitesException() {
46
		super();
47
		// TODO Auto-generated constructor stub
48
	}
49

  
50
	/**
51
	 * Instantiates a new specificites exception.
52
	 *
53
	 * @param arg0 the arg0
54
	 * @param arg1 the arg1
55
	 */
56
	public ___SpecificitesException(String arg0, Throwable arg1) {
57
		super(arg0, arg1);
58
		// TODO Auto-generated constructor stub
59
	}
60

  
61
	/**
62
	 * Instantiates a new specificites exception.
63
	 *
64
	 * @param arg0 the arg0
65
	 */
66
	public ___SpecificitesException(String arg0) {
67
		super(arg0);
68
		// TODO Auto-generated constructor stub
69
	}
70

  
71
	/**
72
	 * Instantiates a new specificites exception.
73
	 *
74
	 * @param arg0 the arg0
75
	 */
76
	public ___SpecificitesException(Throwable arg0) {
77
		super(arg0);
78
		// TODO Auto-generated constructor stub
79
	}
80
}
0 81

  
tmp/org.txm.specificities.core/src/org/txm/specificities/core/chartsengine/jfreechart/JFCSpecificitiesBarChartCreator.java (revision 403)
17 17
import org.txm.chartsengine.jfreechart.core.themes.base.ExtendedNumberAxis;
18 18
import org.txm.chartsengine.jfreechart.core.themes.base.SymbolAxisBetweenTicks;
19 19
import org.txm.core.preferences.TXMPreferences;
20
import org.txm.core.results.ITXMResult;
20
import org.txm.core.results.TXMResult;
21 21
import org.txm.specificities.core.functions.SpecificitesResult;
22 22
import org.txm.specificities.core.messages.SpecificitiesCoreMessages;
23 23
import org.txm.specificities.core.preferences.SpecificitiesPreferences;
......
33 33
	}
34 34

  
35 35
	@Override
36
	public JFreeChart createChart(ITXMResult result, String preferencesNode) {
36
	public JFreeChart createChart(TXMResult result) {
37 37

  
38 38
		SpecificitesResult specificitiesResult = (SpecificitesResult) result;
39 39

  
40 40
		// parameters
41
		boolean transpose = TXMPreferences.getBoolean(preferencesNode, result, SpecificitiesPreferences.CHART_TRANSPOSE);
42
		boolean drawBars = TXMPreferences.getBoolean(preferencesNode, result, SpecificitiesPreferences.CHART_DRAW_BARS);
43
		boolean drawLines = TXMPreferences.getBoolean(preferencesNode, result, SpecificitiesPreferences.CHART_DRAW_LINES);
44
		float banality = TXMPreferences.getFloat(preferencesNode, result, SpecificitiesPreferences.CHART_BANALITY);
41
		boolean drawBars = result.getBooleanParameterValue(SpecificitiesPreferences.CHART_DRAW_BARS);
42
		boolean drawLines = result.getBooleanParameterValue(SpecificitiesPreferences.CHART_DRAW_LINES);
43
		float banality = result.getFloatParameterValue(SpecificitiesPreferences.CHART_BANALITY);
45 44
		
46 45
		JFreeChart chart = null;
47 46

  
......
85 84
	}
86 85

  
87 86
	@Override
88
	public void updateChart(Object chart, ITXMResult result, String preferencesNode) {
87
	public void updateChart(Object chart, TXMResult result) {
89 88
		
90 89
		SpecificitesResult specificitiesResult = (SpecificitesResult) result;
91 90
		JFreeChart jfcChart = (JFreeChart) chart;
......
100 99
		String[] xAxisSymbols;
101 100

  
102 101
		// Transpose the data set
103
		if(TXMPreferences.getBoolean(preferencesNode, result, SpecificitiesPreferences.CHART_TRANSPOSE))	{
102
		if(result.getBooleanParameterValue(SpecificitiesPreferences.CHART_TRANSPOSE))	{
104 103
	        xAxisSymbols = new String[specificitiesResult.getSelectedTypeNames().length];
105 104

  
106 105
			for(int i = 0; i < specificitiesResult.getSelectedPartNames().length; i++) {
......
139 138
        	minimumValue = 0;
140 139
        }
141 140
        if(maximumValue < 0)	{
142
        	maximumValue = TXMPreferences.getFloat(preferencesNode, result, SpecificitiesPreferences.CHART_BANALITY);
141
        	maximumValue = result.getFloatParameterValue(SpecificitiesPreferences.CHART_BANALITY);
143 142
        }
144 143
        // Custom range axis to cut the values to minimum and maximum values
145 144
        jfcChart.getXYPlot().setRangeAxis(new ExtendedNumberAxis((NumberAxis) jfcChart.getXYPlot().getRangeAxis(), true, true, minimumValue, maximumValue));
......
147 146
        jfcChart.getXYPlot().setDomainAxis(new SymbolAxisBetweenTicks(SpecificitiesCoreMessages.Charts_X_AXIS_LABEL, xAxisSymbols));
148 147

  
149 148
        
150
		super.updateChart(chart, result, preferencesNode);
149
		super.updateChart(chart, result);
151 150
		
152 151
	}
153 152
	
tmp/org.txm.specificities.core/src/org/txm/specificities/core/chartsengine/r/RSpecificitiesBarChartCreator.java (revision 403)
5 5
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences;
6 6
import org.txm.chartsengine.r.core.RChartCreator;
7 7
import org.txm.core.preferences.TXMPreferences;
8
import org.txm.core.results.ITXMResult;
8
import org.txm.core.results.TXMResult;
9 9
import org.txm.specificities.core.functions.SpecificitesResult;
10 10
import org.txm.specificities.core.messages.SpecificitiesCoreMessages;
11 11
import org.txm.specificities.core.preferences.SpecificitiesPreferences;
......
27 27
	}
28 28

  
29 29
	@Override
30
	public Object createChart(ITXMResult result, String preferencesNode) {
30
	public Object createChart(TXMResult result) {
31 31
		return null;
32 32
	}
33 33

  
34 34
	
35 35
	@Override
36
	public File createChartFile(ITXMResult result, File file, String preferencesNode) {
36
	public File createChartFile(TXMResult result, File file) {
37 37

  
38 38
		try {
39 39
			
40 40
			SpecificitesResult specificitiesResult = (SpecificitesResult) result;
41 41

  
42 42
			// parameters
43
			boolean transpose = TXMPreferences.getBoolean(preferencesNode, result, SpecificitiesPreferences.CHART_TRANSPOSE);
44
			boolean drawBars = TXMPreferences.getBoolean(preferencesNode, result, SpecificitiesPreferences.CHART_DRAW_BARS);
45
			boolean drawLines = TXMPreferences.getBoolean(preferencesNode, result, SpecificitiesPreferences.CHART_DRAW_LINES);
46
			float banality = TXMPreferences.getFloat(preferencesNode, result, SpecificitiesPreferences.CHART_BANALITY);
47
			int renderingColorMode = TXMPreferences.getInt(preferencesNode, result, ChartsEnginePreferences.RENDERING_COLORS_MODE);
43
			boolean transpose = result.getBooleanParameterValue(SpecificitiesPreferences.CHART_TRANSPOSE);
44
			boolean drawBars = result.getBooleanParameterValue(SpecificitiesPreferences.CHART_DRAW_BARS);
45
			boolean drawLines = result.getBooleanParameterValue(SpecificitiesPreferences.CHART_DRAW_LINES);
46
			float banality = result.getFloatParameterValue(SpecificitiesPreferences.CHART_BANALITY);
47
			int renderingColorMode = result.getIntParameterValue(ChartsEnginePreferences.RENDERING_COLORS_MODE);
48 48
			
49 49
			//boolean grayscale = (renderingColorMode == ChartsEngine.RENDERING_GRAYSCALE_MODE);
50 50
			
......
79 79

  
80 80
			// Title
81 81
			String title = "";
82
			if(TXMPreferences.getBoolean(preferencesNode, result, ChartsEnginePreferences.SHOW_TITLE))	{
82
			if(result.getBooleanParameterValue(ChartsEnginePreferences.SHOW_TITLE))	{
83 83
				title = specificitiesResult.getName();	
84 84
			}
85 85
			
......
151 151

  
152 152
			
153 153
			// Grid
154
			if(TXMPreferences.getBoolean(preferencesNode, result, ChartsEnginePreferences.SHOW_GRID))	{
154
			if(result.getBooleanParameterValue(ChartsEnginePreferences.SHOW_GRID))	{
155 155
				cmd += this.getChartsEngine().getGridPlotCmd();
156 156
			}
157 157
			
158 158
			// Legend
159
			if(TXMPreferences.getBoolean(preferencesNode, result, ChartsEnginePreferences.SHOW_LEGEND))	{
159
			if(result.getBooleanParameterValue(ChartsEnginePreferences.SHOW_LEGEND))	{
160 160
				if (drawBars)	{
161 161
					cmd += "legend(\"topright\", "+legend+", inset = c(-0.2,0), col = colors, fill = colors, xpd=TRUE);\n"; //$NON-NLS-1$ //$NON-NLS-2$
162 162
				}
tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/Specificites2.java (revision 403)
1
package org.txm.functions.contrasts;
2

  
3
import org.txm.lexicaltable.core.functions.LexicalTable;
4
import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
5
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
6
import org.txm.searchengine.cqp.corpus.Corpus;
7
import org.txm.searchengine.cqp.corpus.Partition;
8
import org.txm.searchengine.cqp.corpus.Property;
9
import org.txm.searchengine.cqp.corpus.Subcorpus;
10
import org.txm.specificities.core.statsengine.r.function.SpecificitiesImpl;
11
import org.txm.statsengine.core.StatException;
12
import org.txm.statsengine.r.core.RWorkspace;
13

  
14
public class Specificites2 extends Contrast {
15

  
16
	private ILexicalTable itable;
17

  
18
	public Specificites2(Corpus corpus, Subcorpus subcorpus, Property property)
19
			throws StatException, CqiClientException {
20
		super(corpus, subcorpus, property);
21
	}
22

  
23
	public Specificites2(Partition partition, Property property, int Fmin)
24
			throws StatException, CqiClientException {
25
		super(partition, property, Fmin);
26
	}
27

  
28

  
29
	public Specificites2(LexicalTable table) {
30
		super(table);
31
	}
32

  
33
	public boolean compute() throws StatException {
34
		itable = table.getData();
35
		colNames = itable.getColNames().asStringsArray();
36
		rowNames = itable.getRowNames().asStringsArray();
37
		frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(itable.getSymbol());
38

  
39
		// compute
40
		indices = new SpecificitiesImpl(itable).getScores(); //$NON-NLS-1$
41
		return true;
42
	}
43

  
44
	@Override
45
	public String getName() {
46
		return "Specif2"; //$NON-NLS-1$
47
	}
48

  
49
	@Override
50
	public String getSimpleName() {
51
		// TODO Auto-generated method stub
52
		return null;
53
	}
54

  
55
	@Override
56
	public String getDetails() {
57
		// TODO Auto-generated method stub
58
		return null;
59
	}
60

  
61
	@Override
62
	public void clean() {
63
		// TODO Auto-generated method stub
64

  
65
	}
66
}
0 67

  
tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/Contrasts.java (revision 403)
4 4

  
5 5
import org.txm.core.messages.TXMCoreMessages;
6 6
import org.txm.lexicaltable.core.functions.LexicalTable;
7
import org.txm.specificities.core.functions.Chi2;
8
import org.txm.specificities.core.functions.Specificites2;
9 7

  
10 8
public class Contrasts {
11 9
	LexicalTable table;
tmp/org.txm.specificities.core/src/org/txm/functions/contrasts/Chi2.java (revision 403)
1
package org.txm.functions.contrasts;
2

  
3
import org.txm.lexicaltable.core.functions.LexicalTable;
4
import org.txm.lexicaltable.core.statsengine.data.ILexicalTable;
5
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
6
import org.txm.searchengine.cqp.corpus.Corpus;
7
import org.txm.searchengine.cqp.corpus.Partition;
8
import org.txm.searchengine.cqp.corpus.Property;
9
import org.txm.searchengine.cqp.corpus.Subcorpus;
10
import org.txm.statsengine.core.StatException;
11
import org.txm.statsengine.r.core.RWorkspace;
12

  
13
public class Chi2 extends Contrast {
14
	
15
	private ILexicalTable itable;
16
	
17
	public Chi2(Corpus corpus, Subcorpus subcorpus, Property property)
18
			throws StatException, CqiClientException {
19
		super(corpus, subcorpus, property);
20
	}
21

  
22
	public Chi2(Partition partition, Property property, int Fmin)
23
			throws StatException, CqiClientException {
24
		super(partition, property, Fmin);
25
	}
26

  
27

  
28
	public Chi2(LexicalTable table) {
29
		super(table);
30
	}
31

  
32
	@Override
33
	public boolean compute() throws StatException {
34
		itable = table.getData();
35
		colNames = itable.getColNames().asStringsArray();
36
		rowNames = itable.getRowNames().asStringsArray();
37
		frequencies = RWorkspace.getRWorkspaceInstance().evalToInt2D(itable.getSymbol());
38
		
39
		// compute
40
		String cmd = "mat <- "+itable.getSymbol()+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$
41
					" mat2 <- rowSums(mat) %o% colSums(mat) / sum(mat)"+"\n"+ //$NON-NLS-1$ //$NON-NLS-2$
42
					symbol +" <- (mat - mat2) ^ 2 / mat2"; //$NON-NLS-1$
43
		indices = RWorkspace.getRWorkspaceInstance().evalToDouble2D(cmd);
44
		return true;
45
	}
46

  
47
	@Override
48
	public String getName() {
49
		return "Chi2"; //$NON-NLS-1$
50
	}
51

  
52
	@Override
53
	public String getSimpleName() {
54
		// TODO Auto-generated method stub
55
		return null;
56
	}
57

  
58
	@Override
59
	public String getDetails() {
60
		// TODO Auto-generated method stub
61
		return null;
62
	}
63

  
64
	@Override
65
	public void clean() {
66
		// TODO Auto-generated method stub
67
		
68
	}
69
}
0 70

  

Formats disponibles : Unified diff