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

UnitsInterdistanceMacro.groovy (revision 2134)
76 76
		Collections.sort(units)
77 77
			
78 78
		for (int i = 0 ; i < units.size() ; i++) {
79
			int d1 = 0;
80
			int d2 = 0;
81
			if (i < units.size()-1) d1 = units[i+1].getDeb() - units[i].getFin();
79
			int d1 = 9999999;
80
			int d2 = 9999999;
81
			
82
			
83
			if (i < units.size()-1) d1 = units[i+1].getDeb() - units[i].getFin() - 1;
82 84
			if (d1 < 0) {
83 85
				//println "D1 "+units[i+1].getDeb()+" - "+units[i].getFin()+" = "+d1
84 86
				d1 = 0; // the first unit pass the next one ?
85 87
			}
86
			if (i > 0) d2 = units[i].getDeb() - units[i-1].getFin();
88
			if (i > 0) {
89
				d2 = units[i].getDeb() - units[i-1].getFin() - 1;
90
				distances << d2
91
				nDistances++
92
			}
87 93
			if (d2 < 0) {
88 94
				//println "D2 "+units[i].getDeb()+" - "+units[i-1].getFin()+" = "+d2
89 95
				d2 = 0; // the first unit pass the next one ?
90 96
			}
91
			distances << d1
92 97
			
93 98
			if (d1 < d2) cadences << d1 else cadences << d2
94
			
95
			nDistances++
96 99
		}
97 100
	}
98 101
	distances = distances.sort()
......
104 107
	cadence = (cadences_total / nDistances)
105 108
	
106 109
	println "$corpus distances:"
107
	//println "distances $distances"
108
	println "distance moyenne inter-mayonnaise : $distances_total / $nDistances = $coef"
109
	println "distance medianne inter-mayonnaise : "+distances[(int)(distances.size() / 2)]
110
	if (debug > 0) println "distances $distances"
111
	println "distance moyenne : $distances_total / ${distances.size()} = $coef"
112
	println "distance medianne : "+distances[(int)(distances.size() / 2)]
110 113
	println "distance quartils : "+distances[0]+" "+distances[(int)(distances.size() / 4)] + " "+distances[(int)(distances.size() / 2)]+" "+distances[(int)(3*distances.size() / 4)]+" "+distances[(int)(distances.size() -1)]
111
	//println "cadences $cadences"
112
	println "cadence moyenne : $cadences_total / $nDistances = $cadence"
114
	if (debug > 0) println "cadences $cadences"
115
	println "cadence moyenne : $cadences_total / ${cadences.size()} = $cadence"
113 116
	println "cadence medianne : "+cadences[(int)(cadences.size() / 2)]
114 117
	println "cadence quartils : "+cadences[0]+" "+cadences[(int)(cadences.size() / 4)] + " "+cadences[(int)(cadences.size() / 2)]+" "+cadences[(int)(3*cadences.size() / 4)]+" "+cadences[(int)(cadences.size() -1)]
115 118
	

Also available in: Unified diff