Revision 2105 tmp/org.txm.analec.rcp/src/org/txm/macro/urs/exploit/UnitsIndexMacro.groovy

UnitsIndexMacro.groovy (revision 2105)
11 11
import org.kohsuke.args4j.*
12 12
import org.txm.Toolbox
13 13
import org.txm.annotation.urs.*
14
import org.txm.lexicaltable.core.functions.LexicalTable
14 15
import org.txm.lexicaltable.core.statsengine.r.data.LexicalTableImpl
15 16
import org.txm.macro.urs.*
16 17
import org.txm.rcp.commands.*
......
36 37
if (selection.size() == 0) {
37 38
	println "** $scriptName: please select a Corpus or a Partition in the Corpus view: "+corpusViewSelections
38 39
	return false
40
} else {
41
	for (def c : selection) c.compute(false)
39 42
}
40 43

  
41 44
// BEGINNING OF PARAMETERS
42
@Field @Option(name="schema_ursql", usage="TYPE@PROP=VALUE", widget="String", required=true, def="CHAINE")
45
@Field @Option(name="schema_ursql", usage="TYPE@PROP=VALUE", widget="String", required=false, def="CHAINE")
43 46
		String schema_ursql
44
@Field @Option(name="minimum_schema_size", usage="Minimum size needed to consider a schema", widget="Integer", required=true, def="3")
47
@Field @Option(name="minimum_schema_size", usage="Minimum size needed to consider a schema", widget="Integer", required=false, def="3")
45 48
		int minimum_schema_size
46
@Field @Option(name="maximum_schema_size", usage="Maximum size needed to consider a schema", widget="Integer", required=true, def="9999999")
49
@Field @Option(name="maximum_schema_size", usage="Maximum size needed to consider a schema", widget="Integer", required=false, def="9999999")
47 50
		int maximum_schema_size
48 51
@Field @Option(name="unit_ursql", usage="TYPE@PROP=VALUE", widget="String", required=false, def="MENTION")
49 52
		String unit_ursql
50
@Field @Option(name="unit_property_display", usage="Unit property to count", widget="String", required=true, def="CATEGORIE")
53
@Field @Option(name="unit_property_display", usage="Unit property to count", widget="String", required=false, def="CATEGORIE")
51 54
		String unit_property_display
52 55
@Field @Option(name="word_property_display", usage="Word property to display instead of the unit property", widget="String", required=false, def="")
53 56
		String word_property_display
54
@Field @Option(name="position_in_schema", usage="Unit distance in schema (0 = no selection, 1 = first after limit, -1 = last before limit, etc.)", widget="Integer", required=true, def="0")
57
@Field @Option(name="position_in_schema", usage="Unit distance in schema (0 = no selection, 1 = first after limit, -1 = last before limit, etc.)", widget="Integer", required=false, def="0")
55 58
		int position_in_schema
56
@Field @Option(name="cql_limit", usage="CQL to build structure limits", widget="Query", required=true, def="<div> [] expand to div")
59
@Field @Option(name="cql_limit", usage="CQL to build structure limits", widget="Query", required=false, def="")
57 60
		cql_limit
58
@Field @Option(name="strict_inclusion", usage="Units must be strictly included into corpus matches", widget="Boolean", required=true, def="true")
61
@Field @Option(name="strict_inclusion", usage="Units must be strictly included into corpus matches", widget="Boolean", required=false, def="true")
59 62
		strict_inclusion
60
@Field @Option(name="position_in_matches", usage="Unit distance to structure limit (0 = no selection, 1 = first after limit, -1 = last before limit, etc.)", widget="Integer", required=true, def="0")
63
@Field @Option(name="position_in_matches", usage="Unit distance to structure limit (0 = no selection, 1 = first after limit, -1 = last before limit, etc.)", widget="Integer", required=false, def="0")
61 64
		position_in_matches
62 65
//@Field @Option(name="output_2D", usage="output barplot or 3D plot", widget="Boolean", required=true, def="true")
63 66
		output_2D = true
64
@Field @Option(name="output_showlegend", usage="output barplot or 3D plot", widget="Boolean", required=true, def="true")
67
@Field @Option(name="output_showlegend", usage="output barplot or 3D plot", widget="Boolean", required=false, def="true")
65 68
		output_showlegend
66
@Field @Option(name="output_fmin", usage="minimal frequency displayed", widget="Integer", required=true, def="0")
69
@Field @Option(name="output_fmin", usage="minimal frequency displayed", widget="Integer", required=false, def="0")
67 70
		output_fmin
68
@Field @Option(name="output_histogram", usage="show or not a histogram of the result", widget="Boolean", required=true, def="true")
71
@Field @Option(name="output_histogram", usage="show or not a histogram of the result", widget="Boolean", required=false, def="true")
69 72
		output_histogram
70
@Field @Option(name="output_lexicaltable", usage="create or not a lexical table with the result", widget="Boolean", required=true, def="false")
73
@Field @Option(name="output_lexicaltable", usage="create or not a lexical table with the result", widget="Boolean", required=false, def="false")
71 74
		output_lexicaltable
72
@Field @Option(name="debug", usage="Show internal variable content", widget="StringArray", metaVar="OFF	ON	ALL	REALLY ALL", required=true, def="OFF")
75
@Field @Option(name="debug", usage="Show internal variable content", widget="StringArray", metaVar="OFF	ON	ALL	REALLY ALL", required=false, def="OFF")
73 76
		debug
74 77
if (!ParametersDialog.open(this)) return
75 78
if (debug == "OFF") debug = 0; else if (debug == "ON") debug = 1; else if (debug == "ALL") debug = 2 else if (debug == "REALLY ALL") debug = 3
......
238 241

  
239 242
def lt = null;
240 243
if (output_lexicaltable) {
241
	
242
	if (corpusViewSelection instanceof Partition) {
243
		lt = new LexicalTableImpl(matrix as DoubleMatrix2D, corpusViewSelection, corpusViewSelection.getCorpus().getProperty("word"),
244
				rownames, colnames)
245
		lt.setCorpus(corpusViewSelection.getCorpus());
246
		corpusViewSelection.storeResult(lt)
244
	def parent = selection[0]
245
	println "parent="+parent.getClass()
246
	if (parent instanceof Part) {
247
		println "part="+parent
248
		parent = parent.getParent()
249
		println "partition="+parent
250
		lt = new LexicalTable(parent);
251
		lt.setData(new LexicalTableImpl(matrix as DoubleMatrix2D, rownames, colnames))
252

  
247 253
	} else {
248
		lt = new LexicalTableImpl(matrix as DoubleMatrix2D, corpus.getProperty("word"),
249
				rownames, colnames)
250
		lt.setCorpus(corpus);
251
		corpus.storeResult(lt)
254
		lt = new LexicalTable(parent);
255
		lt.setData(new LexicalTableImpl(matrix as DoubleMatrix2D, rownames, colnames))
252 256
	}
257
	lt.setUserName(schema_ursql+">"+unit_ursql)
253 258
}
254 259

  
255

  
256 260
if (file.exists() && file.getTotalSpace() > 0) {
257 261
	println "SVG file: "+file.getAbsolutePath()
258 262

  

Also available in: Unified diff