Revision 1726 tmp/org.txm.analec.rcp/src/org/txm/macro/urs/edit/ConcordanceToUnitMacro.groovy

ConcordanceToUnitMacro.groovy (revision 1726)
82 82

  
83 83
int n = 0
84 84
for (int iLine = 0 ; iLine < lines.size() ; iLine++) {
85
	int iUnit = 0
85 86
	def line = lines[iLine]
86 87
	def m = line.getMatch()
88
	def do_create = true
87 89
	if (create_only_if_new && iUnit < units.size()) { // test only if create_only_if_new == true
88 90
		def unit = null
89
		//TODO don't iterates over
90
		int iUnit = 0
91
		//TODO don't iterates over all units
91 92
		while (iUnit < units.size() ) { //&& units[iUnit].getDeb() < m.getStart()) {
92 93
			if (iUnit < units.size()) {
93 94
				unit = units[iUnit++]
94 95
				if (unit.getDeb() == m.getStart() && unit.getFin() == m.getEnd()) { // skip and print the line
95 96
					println "skiping line: "+line.getViewRef().toString()+" "+line.keywordToString()
97
					do_create = false
96 98
					continue
97 99
				}
98 100
			}
99 101
		}
100 102
	}
101
	n++
102
	def props = [:]
103
	props[prop] = value
104
	Unite u = analecCorpus.addUniteSaisie(unit_type, m.getStart(), m.getEnd(), props)
105
	//println "$props -> "+u.getProps()
103
	if (do_create) {
104
		n++
105
		def props = [:]
106
		props[prop] = value
107
		Unite u = analecCorpus.addUniteSaisie(unit_type, m.getStart(), m.getEnd(), props)
108
		//	println "$props -> "+u.getProps()
109
	}
106 110
}
107 111
println "$n $unit_type created."
108 112
if (n > 0) corpus.setIsModified(true);

Also available in: Unified diff