Révision 1949

tmp/org.txm.index.core/plugin.xml (revision 1949)
7 7
            class="org.txm.index.core.preferences.IndexPreferences">
8 8
      </initializer>
9 9
   </extension>
10
   <extension
11
         point="org.txm.statengine.r.core.RTransformer">
12
      <transformer
13
            class="org.txm.index.core.r.IndexRTransformer"
14
            type="org.txm.index.core.functions.Index">
15
      </transformer>
16
   </extension>
10 17

  
11 18
</plugin>
tmp/org.txm.index.core/src/org/txm/index/core/functions/Index.java (revision 1949)
596 596
		return selectedLines;
597 597
	}
598 598

  
599

  
600 599
	/**
601 600
	 * return all the lines of the index.
602 601
	 *
......
624 623
		}
625 624
	}
626 625

  
627

  
628

  
629

  
630 626
	@Override
631 627
	public String getName() {
632 628
		try {
......
912 908
		this.setProperties(properties);
913 909
	}
914 910

  
915

  
916

  
917 911
	public void setParameters(CQLQuery query, List<WordProperty> props, Integer filterFmin, Integer filterFmax, Integer filterVmax, Integer nLinesPerPage) {
918 912
		this.pQuery = query;
919 913
		this.pProperties = props;
tmp/org.txm.index.core/src/org/txm/index/core/functions/PartitionIndex.java (revision 1949)
82 82

  
83 83
	/** The current Fmax value. */
84 84
	protected int Fmax = 0;
85
	
85 86
	/** The current Fmin value. */
86 87
	protected int Fmin = 9999999;
87 88

  
88 89
	/** The lexicon used to compute the index (if query = null || query == [] && properties.size() == 1 */
89 90
	@Deprecated
90 91
	protected CQPLexicon lexicon;
92
	
91 93
	@Deprecated
92 94
	protected boolean lexiconMode = false;
93 95

  
94

  
95 96
	/** The current lines. */
96 97
	protected List<Line> lines = new ArrayList<Line>();
97 98
	/** The current number of lines. */
tmp/org.txm.index.core/src/org/txm/index/core/r/IndexRTransformer.java (revision 1949)
1
package org.txm.index.core.r;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5

  
6
import org.txm.core.results.TXMResult;
7
import org.txm.index.core.functions.Index;
8
import org.txm.index.core.functions.Line;
9
import org.txm.statsengine.r.core.RTransformer;
10
import org.txm.statsengine.r.core.RWorkspace;
11
import org.txm.statsengine.r.core.exceptions.RWorkspaceException;
12

  
13
public class IndexRTransformer extends RTransformer<Index> {
14

  
15
	/** The novoc. */
16
	protected static int novoc = 1;
17

  
18
	/** The prefix r. */
19
	protected static String prefixR = "Index"; //$NON-NLS-1$
20

  
21
	
22
	public IndexRTransformer() {
23
		// TODO Auto-generated constructor stub
24
	}
25

  
26
	@Override
27
	public Index fromRtoTXM(String symbol) {
28
		// TODO Auto-generated method stub
29
		return null;
30
	}
31

  
32
	/**
33
	 * As r matrix.
34
	 *
35
	 * @return the string
36
	 * @throws RWorkspaceException the r workspace exception
37
	 */
38
	@Override
39
	public String fromTXMtoR(TXMResult o) throws RWorkspaceException {
40
		if ((o instanceof Index)) return null;
41
		
42
		Index index = (Index)o;
43
		
44
		String symbol = prefixR+novoc;
45

  
46
		ArrayList<String> colnames = new ArrayList<String>();
47

  
48
		colnames.add("F"); //$NON-NLS-1$
49
		
50
		//System.out.println("cols: "+colnames);
51
		List<Line> lines = index.getAllLines();
52
		String[] keywords = new String[lines.size()];
53

  
54
		int[] freq = new int[lines.size()];
55

  
56
		for (int i = 0 ; i < lines.size() ; i++) 
57
		{
58
			Line ligne = lines.get(i);
59
			freq[i] = ligne.getFrequency(); 
60
			keywords[i] = ligne.toString();
61
		}
62

  
63
		RWorkspace rw = RWorkspace.getRWorkspaceInstance();
64
		rw.addVectorToWorkspace("vocfreq", freq); //$NON-NLS-1$
65
		rw.addVectorToWorkspace("vockeywords", keywords); //$NON-NLS-1$
66
		rw.addVectorToWorkspace("voccolnames", colnames.toArray(new String[colnames.size()])); //$NON-NLS-1$
67

  
68
		int ncol = 1;
69

  
70
		int nrow = lines.size();
71
		String partscmd = ""; //$NON-NLS-1$
72
		
73
		rw.eval(symbol+ "<- matrix(data = c(vocfreq"+partscmd+"), nrow = "+nrow+", ncol = "+ncol+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
74
		rw.eval("colnames("+symbol+" ) <- voccolnames"); //$NON-NLS-1$ //$NON-NLS-2$
75
		rw.eval("rownames("+symbol+" ) <- vockeywords"); //$NON-NLS-1$ //$NON-NLS-2$
76
		rw.eval(symbol+ "<- list(data="+symbol+")"); //$NON-NLS-1$ //$NON-NLS-2$
77

  
78
		novoc++;
79
		return symbol;
80
	}
81
}
0 82

  

Formats disponibles : Unified diff