Révision 3472

TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/macro/prototypes/commands/CoocRecMacro.groovy (revision 3472)
17 17
	return false;
18 18
}
19 19

  
20
@Field @Option(name="output_file", usage="Output graph file", widget="File", required=true, def='output.graphml')
21
		def output_file
20 22
@Field @Option(name="starting_word", usage="The starting word", widget="String", required=true, def='Life')
21 23
		def starting_word
22 24
@Field @Option(name="property", usage="an example query", widget="String", required=true, def='lemma')
......
37 39
if (debug == "OFF") debug = 0; else if (debug == "ON") debug = 1; else if (debug == "ALL") debug = 2 else if (debug == "REALLY ALL") debug = 3
38 40
mode = mode == "Poly"
39 41

  
42
output = output_file.newWriter()
43

  
40 44
lmax = ""
41 45
for (int i = 0 ; i < profondeur_max; i++) lmax += "\t"
42 46

  
......
95 99
		if (mode) {
96 100
			if (right_dir) {
97 101
				def pivot = pivots[-1]
98
				println "$level\"$pivot\" -> \"$word\"	[label=\"${words[word].score}\",fontsize=$size,weight=${words[word].score}];"
102
				output.println "$level\"$pivot\" -> \"$word\"	[label=\"${words[word].score}\",fontsize=$size,weight=${words[word].score}];"
99 103
				if (mode) new_pivots.addAll(pivots)
100 104
				new_pivots << word
101 105
			} else {
102 106
				def pivot = pivots[0]
103
				println "$level\"$word\" -> \"$pivot\"	[label=\"${words[word].score}\",fontsize=$size,weight=${words[word].score}];"
107
				output.println "$level\"$word\" -> \"$pivot\"	[label=\"${words[word].score}\",fontsize=$size,weight=${words[word].score}];"
104 108

  
105 109
				new_pivots << word
106 110

  
......
109 113
			printCoocs(new_pivots, level+" ", cooc, right_dir)
110 114
		} else {
111 115
			def pivot = pivots[0]
112
			println "$level\"$pivot\" -- \"$word\"	[label=\"${words[word].score}\",fontsize=$size,weight=${words[word].score}];"
116
			output.println "$level\"$pivot\" -- \"$word\"	[label=\"${words[word].score}\",fontsize=$size,weight=${words[word].score}];"
113 117
			printCoocs([word], level+" ", cooc, true)
114 118
		}
115 119
	}
......
117 121

  
118 122

  
119 123
if (mode) {
120
	println "digraph {"
121
	println "rankdir=LR;"
124
	output.println "digraph {"
125
	output.println "rankdir=LR;"
122 126
} else {
123
	println "graph {"
127
	output.println "graph {"
124 128
}
125 129

  
126
println "\"$starting_word\" [shape=box];"
130
output.println "\"$starting_word\" [shape=box];"
127 131
if (mode) {
128 132
	printCoocs([starting_word], "", rightCooc, true)
129 133
	r = new HashSet()
......
132 136
	printCoocs([starting_word], "", rightCooc, true)
133 137
}
134 138

  
135
println "}"
139
output.println "}"
140
output.close()
141
println "Done : "+output_file.getAbsolutePath()

Formats disponibles : Unified diff