Revision 2134 tmp/org.txm.analec.rcp/src/org/txm/macro/urs/exploit/UnitsReferentialDensityMacro.groovy

UnitsReferentialDensityMacro.groovy (revision 2134)
49 49
if (!ParametersDialog.open(this)) return;
50 50
if (debug == "OFF") debug = 0; else if (debug == "ON") debug = 1; else if (debug == "ALL") debug = 2 else if (debug == "REALLY ALL") debug = 3
51 51

  
52

  
53 52
for (def corpus : selection) {
54
def analecCorpus = URSCorpora.getCorpus(corpus);
55

  
56
int nMots = corpus.getSize();
57

  
58
def units = AnalecUtils.selectUnitsInSchema(debug, analecCorpus, corpus, schema_ursql, minimum_schema_size, maximum_schema_size,
53
	
54
	def analecCorpus = URSCorpora.getCorpus(corpus);
55
	
56
	int nMots = corpus.getSize();
57
	
58
	def units = AnalecUtils.selectUnitsInSchema(debug, analecCorpus, corpus, schema_ursql, minimum_schema_size, maximum_schema_size,
59 59
	unit_ursql, position_in_schema, cql_limit, strict_inclusion, position_in_matches);
60

  
61
int nUnites = units.size();
62

  
63
coef = (nUnites /nMots)
64
println "$corpus referential density: nUnites/nMots = $nUnites/$nMots = $coef = ${coef*100}%"
65
if (nUnites >= nMots) {
66
	println "WARNING: possible encoding error in $corpus. Number of units ($nUnites) is greater than number of words ($nMots)"
67
}
68
//return ["result":coef, "data":["nUnites":nUnites, "nMots":nMots]]
60
	
61
	int nUnites = units.size();
62
	
63
	coef = (nUnites /nMots)
64
	rounded = String.format( "%.2f", coef * 100.0d )
65
	println "$corpus referential density: nUnites/nMots = $nUnites/$nMots = $coef = ${rounded}%"
66
	if (nUnites >= nMots) {
67
		println "WARNING: possible encoding error in $corpus. Number of units ($nUnites) is greater than number of words ($nMots)"
68
	}
69
	//return ["result":coef, "data":["nUnites":nUnites, "nMots":nMots]]
69 70
}

Also available in: Unified diff