Révision 187

tmp/org.txm.core/.groovy/suggestions.xdsl (revision 187)
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
<projectSuggestions/>
tmp/org.txm.core/data.properties (revision 187)
1
#HSQL Database Engine 2.0.0
2
#Mon Oct 19 18:27:18 CEST 2015
3
version=2.0.0
4
modified=yes
0 5

  
tmp/org.txm.core/log4j.properties (revision 187)
1
log4j.rootLogger=FATAL
0 2

  
tmp/org.txm.core/data.script (revision 187)
1
SET DATABASE UNIQUE NAME HSQLDB5080D3E890
2
SET DATABASE GC 0
3
SET DATABASE DEFAULT RESULT MEMORY ROWS 0
4
SET DATABASE EVENT LOG LEVEL 0
5
SET DATABASE SQL SIZE TRUE
6
SET DATABASE SQL NAMES FALSE
7
SET DATABASE TRANSACTION CONTROL LOCKS
8
SET DATABASE DEFAULT ISOLATION LEVEL READ COMMITTED
9
SET FILES WRITE DELAY 500 MILLIS
10
SET FILES BACKUP INCREMENT TRUE
11
SET FILES CACHE SIZE 10000
12
SET FILES CACHE ROWS 50000
13
SET FILES SCALE 8
14
SET FILES LOB SCALE 32
15
SET FILES DEFRAG 20
16
SET FILES NIO TRUE
17
SET FILES LOG TRUE
18
SET FILES LOG SIZE 50
19
SET DATABASE TEXT TABLE DEFAULTS ''
20
CREATE USER SA PASSWORD ''
21
CREATE SCHEMA PUBLIC AUTHORIZATION DBA
22
SET SCHEMA PUBLIC
23
ALTER SEQUENCE SYSTEM_LOBS.LOB_ID RESTART WITH 1
24
SET DATABASE DEFAULT INITIAL SCHEMA PUBLIC
25
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.YES_OR_NO TO PUBLIC
26
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.TIME_STAMP TO PUBLIC
27
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.CARDINAL_NUMBER TO PUBLIC
28
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.CHARACTER_DATA TO PUBLIC
29
GRANT USAGE ON DOMAIN INFORMATION_SCHEMA.SQL_IDENTIFIER TO PUBLIC
30
GRANT DBA TO SA
31
SET SCHEMA SYSTEM_LOBS
32
INSERT INTO BLOCKS VALUES(0,2147483647,0)
tmp/org.txm.core/.settings/org.eclipse.ltk.core.refactoring.prefs (revision 187)
1
#Wed Jan 12 14:19:56 CET 2011
2
eclipse.preferences.version=1
3
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
0 4

  
tmp/org.txm.core/.settings/org.eclipse.jdt.core.prefs (revision 187)
1
eclipse.preferences.version=1
2
org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch,*.groovy
3
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
5
org.eclipse.jdt.core.compiler.compliance=1.6
6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8
org.eclipse.jdt.core.compiler.source=1.6
0 9

  
tmp/org.txm.core/.settings/org.eclipse.jdt.groovy.core.prefs (revision 187)
1
eclipse.preferences.version=1
2
groovy.compiler.level=23
3
groovy.script.filters=scripts/**/*.groovy,y,src/main/resources/**/*.groovy,y,src/test/resources/**/*.groovy,y
0 4

  
tmp/org.txm.core/.settings/org.eclipse.core.resources.prefs (revision 187)
1
eclipse.preferences.version=1
2
encoding/<project>=UTF-8
0 3

  
tmp/org.txm.core/test/org/txm/annotation/temporary/DeleteAnnotation.java (revision 187)
1
package org.txm.annotation.temporary;
2

  
3
import static org.junit.Assert.*;
4

  
5
import org.junit.Test;
6

  
7
public class DeleteAnnotation {
8

  
9
	@Test
10
	public void test() {
11
		fail("Not yet implemented");
12
	}
13

  
14
}
0 15

  
tmp/org.txm.core/test/org/txm/annotation/temporary/UpdateAnnotation.java (revision 187)
1
package org.txm.annotation.temporary;
2

  
3
import static org.junit.Assert.*;
4

  
5
import org.junit.Test;
6

  
7
public class UpdateAnnotation {
8

  
9
	@Test
10
	public void test() {
11
		fail("Not yet implemented");
12
	}
13

  
14
}
0 15

  
tmp/org.txm.core/test/org/txm/annotation/temporary/CreateAnnotation.java (revision 187)
1
package org.txm.annotation.temporary;
2

  
3
import static org.junit.Assert.*;
4

  
5
import java.util.HashMap;
6

  
7
import org.junit.Test;
8
import org.txm.Toolbox;
9
import org.txm.annotation.storage.temporary.TemporaryAnnotationManager;
10
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
11
import org.txm.searchengine.cqp.clientExceptions.InvalidCqpIdException;
12
import org.txm.searchengine.cqp.corpus.CorpusManager;
13
import org.txm.searchengine.cqp.corpus.MainCorpus;
14

  
15
public class CreateAnnotation {
16

  
17
	@Test
18
	public void test() throws CqiClientException, InvalidCqpIdException {
19
		if (!Toolbox.isInitialized()) fail("Toolbox not initialized.");
20
		MainCorpus corpus = CorpusManager.getCorpusManager().getCorpus("VOEUX");
21
		if (corpus == null) fail("Corpus Voeux not loaded.");
22
		
23
		HashMap<String, Object> properties = TemporaryAnnotationManager.getInitialisationProperties(corpus);
24
		properties.put("eclipselink.persistencexml", System.getProperty("user.home")+"/workspace442/org.txm.toolbox/META-INF/persistence.xml");
25
		
26
		TemporaryAnnotationManager tam = new TemporaryAnnotationManager(corpus, properties);
27
		System.out.println(tam);
28
	}
29

  
30
}
0 31

  
tmp/org.txm.core/test/org/txm/annotation/temporary/AllTests.java (revision 187)
1
package org.txm.annotation.temporary;
2

  
3
import org.junit.runner.RunWith;
4
import org.junit.runners.Suite;
5
import org.junit.runners.Suite.SuiteClasses;
6
import org.txm.StartToolbox;
7

  
8
@RunWith(Suite.class)
9
@SuiteClasses({ StartToolbox.class, CreateAnnotation.class, DeleteAnnotation.class,
10
		UpdateAnnotation.class })
11
public class AllTests {
12

  
13
}
0 14

  
tmp/org.txm.core/test/org/txm/StartToolbox.java (revision 187)
1
package org.txm;
2

  
3
import java.io.File;
4

  
5
import org.junit.Test;
6

  
7
public class StartToolbox {
8

  
9
	@Test
10
	public void test() throws Exception {
11
		String home = System.getProperty("user.home");
12
		String product_configuration_path = "runtime-rcpapplication.product/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.txm.rcpapplication.prefs";
13
		File properties = new File(home, product_configuration_path);
14
		Toolbox.initialize(properties);
15
	}
16

  
17
}
0 18

  
tmp/org.txm.core/default.xml (revision 187)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<workspace name="default">
3
   <projects>
4
      <project name="default">
5
         <bases>
6
         </bases>
7

  
8
         <corpora>
9
         </corpora>
10
      </project>
11
   </projects>
12
</workspace>
0 13

  
tmp/org.txm.core/.project (revision 187)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.core</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
		<buildCommand>
24
			<name>net.sourceforge.metrics.builder</name>
25
			<arguments>
26
			</arguments>
27
		</buildCommand>
28
		<buildCommand>
29
			<name>com.stateofflow.eclipse.metrics.MetricsBuilder</name>
30
			<arguments>
31
			</arguments>
32
		</buildCommand>
33
	</buildSpec>
34
	<natures>
35
		<nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
36
		<nature>org.eclipse.pde.PluginNature</nature>
37
		<nature>org.eclipse.jdt.core.javanature</nature>
38
		<nature>net.sourceforge.metrics.nature</nature>
39
		<nature>com.stateofflow.eclipse.metrics.MetricsNature</nature>
40
	</natures>
41
</projectDescription>
0 42

  
tmp/org.txm.core/buildTST.properties (revision 187)
1
bin.includes = META-INF/,\
2
               .,\
3
               lib/
4
jars.compile.order = .,\
5
                     bin/
6
source.. = src/groovy/,\
7
           src/java/
8
jars.extra.classpath = lib/ant-1.7.1.jar,\
9
                       lib/antlr-2.7.7.jar,\
10
                       lib/asm-analysis-2.2.3.jar,\
11
                       lib/asm-tree-2.2.3.jar,\
12
                       lib/colt-1.2.0.jar,\
13
                       lib/commons-cli-1.2.jar,\
14
                       lib/commons-io-1.4.jar,\
15
                       lib/commons-lang-2.4.jar,\
16
                       lib/concurrent-1.3.4.jar,\
17
                       lib/hsqldb.jar,\
18
                       lib/jline-0.9.94.jar,\
19
                       lib/junit-4.5.jar,\
20
                       lib/log4j-1.2.12.jar,\
21
                       lib/REngine.jar,\
22
                       lib/RserveEngine.jar,\
23
                       lib/saxon-xom-9.2.jar
24
source.. = src/java/
25
output.. = bin/
0 26

  
tmp/org.txm.core/buildJavadoc.xml (revision 187)
1
<project name="Toolbox" default="doc">
2
	
3
	<path id="lib.dir">
4
		<!-- fileset : TO BE DEFINED MANUALLY -->
5
		<fileset dir="/home/mdecorde/LIBRAIRIES/groovy-2.2.1/embeddable">
6
			<include name="*.jar" />
7
		</fileset>
8
	</path>
9

  
10
	<tstamp>
11
		<format property="TODAY" pattern="yyyy-MM-dd HH:mm" />
12
	</tstamp>
13

  
14
	<taskdef name="groovydoc" classname="org.codehaus.groovy.ant.Groovydoc" classpathref="lib.dir" />
15
	
16
	<target name="doc">
17
		<mkdir dir="javadoc/" />
18
		<!-- packagenames : TO BE UPDATED MANUALLY using TBX exported packages list. BECAUSE org.txm.utils.tostring.ToString make groovydoc raise an exception ... -->
19
		<groovydoc 
20
			destdir="javadoc/" 
21
			sourcepath="src/java:src/groovy" 
22
			packagenames="filters.BuildXmlLiturgie,filters.Concatenator,filters.CutHeader,filters.EliminateWhiteSpaces,filters.FusionHeader,filters.FusionXmlHeaderBody,filters.MinimalFilter,filters.OneOpenTagPerLine,filters.OneTagPerLine,filters.ProcessEnclitics,filters.ProcessQuotes,filters.RegexFilter,filters.ReunitBrokenTags,filters.ReunitBrokenWords,filters.TagSentences,filters.Tokeniser,filters.WordInternalElement,filters.eliminateNAttributes,org.txm,org.txm.annotation,org.txm.doc,org.txm.export,org.txm.export.conll2009,org.txm.export.ts,org.txm.functions,org.txm.functions.ca,org.txm.functions.classification,org.txm.functions.concordances,org.txm.functions.concordances.comparators,org.txm.functions.contrasts,org.txm.functions.cooccurrences,org.txm.functions.cooccurrences.comparators,org.txm.functions.coocmatrix,org.txm.functions.diagnostic,org.txm.functions.internal,org.txm.functions.intertextualdistance,org.txm.functions.mesures,org.txm.functions.parabrowser,org.txm.functions.parallelcontexts,org.txm.functions.preview,org.txm.functions.queryindex,org.txm.functions.referencer,org.txm.functions.progression,org.txm.functions.selection,org.txm.functions.specificities,org.txm.functions.summary,org.txm.functions.index,org.txm.importer,org.txm.importer.RGAQCJ,org.txm.importer.alceste,org.txm.importer.bfm,org.txm.importer.bvh,org.txm.importer.corptef,org.txm.importer.csv,org.txm.importer.cwb,org.txm.importer.discours,org.txm.importer.doc,org.txm.importer.europress,org.txm.importer.factiva,org.txm.importer.filters,org.txm.importer.fleurs,org.txm.importer.frantext,org.txm.importer.graal,org.txm.importer.hyperbase,org.txm.importer.hyperprince,org.txm.importer.lasla,org.txm.importer.limsi,org.txm.importer.perrault,org.txm.importer.quick,org.txm.importer.scripting,org.txm.importer.tigersearch,org.txm.importer.tmx,org.txm.importer.transana,org.txm.importer.transcriber,org.txm.importer.wtc,org.txm.importer.xml,org.txm.importer.xmltxm,org.txm.importer.xmltxmpara,org.txm.metadatas,org.txm.objects,org.txm.renderer,org.txm.scripts,org.txm.scripts.clix,org.txm.scripts.i18n,org.txm.scripts.teitxm,org.txm.scripts.tigersearch,org.txm.searchengine.cqp,org.txm.searchengine.cqp.clientExceptions,org.txm.searchengine.cqp.corpus,org.txm.searchengine.cqp.corpus.query,org.txm.searchengine.cqp.serverException,org.txm.searchengine.ts,org.txm.setup,org.txm.sql,org.txm.stat,org.txm.stat.data,org.txm.stat.engine.r,org.txm.stat.engine.r.data,org.txm.stat.engine.r.function,org.txm.stat.engine.r.rcolt,org.txm.stat.utils,org.txm.svn,org.txm.sw,org.txm.test,org.txm.tests,org.txm.tokenizer,org.txm.toolbox,org.txm.utils,org.txm.utils.i18n,org.txm.utils.logger,org.txm.utils.processbuilder,org.txm.utils.saxon,org.txm.utils.treetagger" 
23
			use="true"  
24
			windowtitle="TXM Groovy and Java documentation ${TODAY}" 
25
			doctitle="TXM Groovy and Java documentation ${TODAY}" 
26
			header="TXM Groovy and Java documentation ${TODAY}" 
27
			footer="TXM Groovy and Java documentation ${TODAY}" 
28
			private="false">
29
			
30
			<link packages="java.,org.xml.,javax.,org.xml." href="http://java.sun.com/j2se/1.5.0/docs/api" />
31
			<link packages="org.apache.ant.,org.apache.tools.ant." href="http://www.dpml.net/api/ant/1.7.0" />
32
			<link packages="org.junit.,junit.framework." href="http://junit.sourceforge.net/junit3.8.1/javadoc/" />
33
			<link packages="groovy.,org.codehaus.groovy." href="http://groovy.codehaus.org/api/" />
34
		</groovydoc>
35
	</target>
36
</project>
0 37

  
tmp/org.txm.core/src/groovy/tests/tests_groovy.groovy (revision 187)
1
print(Progression5)
tmp/org.txm.core/src/groovy/tests/advancedPartition.groovy (revision 187)
1
package tests
2

  
3
import org.txm.rcpapplication.views.*
4
import org.txm.searchengine.cqp.corpus.*
5

  
6

  
7
/*
8
import java.awt.Dimension
9
import java.util.UUID;
10

  
11
import javax.swing.JFrame;
12
import javax.swing.JOptionPane;
13

  
14
import org.txm.Toolbox
15
import org.txm.searchengine.cqp.MemCqiClient
16
import org.txm.searchengine.cqp.MemCqiServer
17
import org.txm.searchengine.cqp.corpus.*
18
import org.txm.functions.ReferencePattern
19
import org.txm.rcpapplication.views.CorporaView
20
import org.txm.searchengine.cqp.corpus.query.Query
21
*/
22

  
23

  
24
/**
25
 * Create partition with advanced CQL queries and autoname the parts.
26
 * Can create partitions by defining a multi-level structural units hierarchy or by defining several properties values for one structural unit.
27
 * Can define some structural units to remove from the resulting parts subcorpus.
28
 *
29
 */
30

  
31
// TODO : Log
32
println "******************************** Starting ********************************************";
33

  
34

  
35
// *************************** User parameters ************************************************************
36

  
37

  
38
// Test 1 : partition en excluant des sections
39
def CORPUS_NAME = "LIVRETOPERA2"								// The name of the corpus to partition
40

  
41
def SUBCORPUS_NAME = null										// The name of the subcorpus to partition
42
//def SUBCORPUS_NAME = "TEST"										// The name of the subcorpus to partition if needed
43
// FIXME: subcorpus management is bugged, when trying to create a CA on a Partition created on a subcorpus, it doesn't work because of the getLexicon() method which throws a CqiCqpErrorErrorGeneral exception
44

  
45
PartitionQueriesGenerator.STRUCTURAL_UNITS = ['sp']; 					// Applying the partition on these structural units
46
PartitionQueriesGenerator.STRUCTURAL_UNITS_PROPERTIES = ['who'];		// Applying the partition on these properties of structural units defined above
47

  
48
PartitionQueriesGenerator.STRUCTURAL_UNITS_TO_IGNORE = ['speaker'];	// These structural units will be removed from the partition. NOTE : If doing that you need to define an EXPAND_TARGET
49
																		// if you want some subcorpus parts that will manage sequential positions queries
50

  
51
PartitionQueriesGenerator.EXPAND_TARGET = 'lg'; 						// Expand the results to this structural unit parent target. If some structural units to ignore are defined
52
																		// and the expand target is upper on the hierarchy than them, the structural units to ignore WON'T be ignored
53

  
54
//PartitionQueriesGenerator.PARTITION_NAME = 'gugu';					// The partition name. If empty or not defined, the partition will be autonamed regarding of the structural units and properties
55

  
56

  
57

  
58

  
59
// Test 2 : partition sur arborescence (multi-niveau sur 2 niveaux)
60
//def CORPUS_NAME = "LIVRETOPERA10TEXTES"
61
//PartitionQueriesGenerator.STRUCTURAL_UNITS = ['text', 'div1'];
62
//PartitionQueriesGenerator.STRUCTURAL_UNITS_PROPERTIES = ['id', 'name'];
63

  
64

  
65
// Test 3 : partition sur arborescence (multi-niveau sur 3 niveaux)
66
//def CORPUS_NAME = "LIVRETOPERA10TEXTES"
67
//PartitionQueriesGenerator.STRUCTURAL_UNITS = ['text', 'div1', 'div2'];
68
//PartitionQueriesGenerator.STRUCTURAL_UNITS_PROPERTIES = ['id', 'name', 'name'];
69

  
70

  
71
// Test 4 : partition sur arborescence (multi-niveau sur 4 niveaux)
72
// Ajouter le 'n' permet par exemple ici de trier les parties par ordre de scène car sinon le tri est problématique, ex : "SCENE II" passe avant "SCENE PREMIERE"
73
//def CORPUS_NAME = "LIVRETOPERA2"
74
//PartitionQueriesGenerator.STRUCTURAL_UNITS = ['text', 'div1', 'div2', 'div2'];
75
//PartitionQueriesGenerator.STRUCTURAL_UNITS_PROPERTIES = ['id', 'name', 'n', 'name'];
76

  
77

  
78
// Test 5 : partitions croisées (sur plusieurs propriétés d'une même structure)
79
//def CORPUS_NAME = "DISCOURS"
80
//PartitionQueriesGenerator.STRUCTURAL_UNITS = ['text', 'text'];
81
//PartitionQueriesGenerator.STRUCTURAL_UNITS_PROPERTIES = ['loc', 'type'];
82

  
83

  
84

  
85
// Tests
86
//def CORPUS_NAME = "LIVRETOPERA10TEXTES"
87
//PartitionQueriesGenerator.STRUCTURAL_UNITS = ['div1', 'sp'];
88
//PartitionQueriesGenerator.STRUCTURAL_UNITS_PROPERTIES = ['name', 'who'];
89

  
90
// Tests
91
//def CORPUS_NAME = "LIVRETOPERA10TEXTES"
92
//PartitionQueriesGenerator.STRUCTURAL_UNITS = ['div1'];
93
//PartitionQueriesGenerator.STRUCTURAL_UNITS_PROPERTIES = ['n'];
94
//PartitionQueriesGenerator.PART_NAMES_PREFIX = 'act_';
95

  
96

  
97

  
98

  
99
// *************************** Debug parameters ************************************************************
100

  
101

  
102
PartitionQueriesGenerator.DEBUG = 0; 	// If DEBUG != 0 then partition is not created,
103
										// script only outputs the created queries and part names strings in console
104

  
105

  
106

  
107
// *************************** End of parameters ************************************************************
108

  
109

  
110

  
111

  
112

  
113

  
114

  
115
// Running
116
def partition = PartitionQueriesGenerator.createPartition(CORPUS_NAME, SUBCORPUS_NAME);
117

  
118

  
119
// Refreshing the RCP component
120
if(partition != null)	{
121
	monitor.syncExec(new Runnable() {
122
			public void run() {
123
				CorporaView.refresh();
124
				CorporaView.expand(partition.getParent());
125
			}
126
		});
127
}
128

  
129

  
130

  
131

  
132

  
133
/**
134
 * Create a list of queries and part names regarding the structural units, structural units properties, structural units to ignore user defined lists and expand target value specified.
135
 * @author s
136
 *
137
 */
138
public class PartitionQueriesGenerator	{
139

  
140
	public static int DEBUG = 0;								// si DEBUG != 0, alors les requêtes sont affichées mais la partition n'est pas créée
141

  
142
	public static String PARTITION_NAME = '';
143
	public static String[] STRUCTURAL_UNITS = [];				// Liste des unités structurelles sur lesquelles effectuer la partition, ex: ['text', 'div1']
144
	public static String[] STRUCTURAL_UNITS_PROPERTIES = [];	// Propriétés des unités structurelles sur lesquelles effectuer la partition, ex : ['id', 'name']
145
	public static String[] STRUCTURAL_UNITS_TO_IGNORE = [];		// Structure à ignorer, ex. CQL : !speaker
146
	public static String PART_NAMES_PREFIX = '';
147
	public static String EXPAND_TARGET = null;					// Expand to target, englobe les empans jusqu'à la balise parente spécifiée. NOTE : Le expand entre en conflit avec les sections à ignorer.
148
																// Si la target est à un niveau supérieur aux balises à ignorer, il les remet dans liste de résultats CWB et elles ne sont donc pas ignorées
149

  
150

  
151

  
152
	public static ArrayList<String> queries = new ArrayList<String>();
153
	public static ArrayList<String> partNames = new ArrayList<String>();
154

  
155

  
156
	/**
157
	 * Init the generator and process.
158
	 * @param corpusName
159
	 */
160
	public static Partition createPartition(String corpusName, String subcorpusName)	{
161

  
162
		if(STRUCTURAL_UNITS.size() > 0 && STRUCTURAL_UNITS.size() == STRUCTURAL_UNITS_PROPERTIES.size())	{
163

  
164
			// TODO : Log
165
			println '**************************************************************************************************************'
166
			println 'Creating the queries on corpus "' + corpusName + "'" ;
167

  
168
			Corpus corpus = CorpusManager.getCorpusManager().getCorpus(corpusName);
169

  
170

  
171
			// Subcorpora
172
			if(subcorpusName != null)	{
173
				corpus = corpus.getSubcorpusByName(subcorpusName);
174
			}
175

  
176

  
177

  
178
			// Recursing through the corpus and subcorpus
179
			process(corpus, 0, '', '');
180

  
181
			// Finalizing the queries
182
			finalizeQueries();
183

  
184

  
185
			// TODO : Debug
186
			// Displaying the partition name
187
			println '';
188
			println 'PARTITION_NAME: ' + PartitionQueriesGenerator.PARTITION_NAME;
189

  
190
			// Displaying the queries
191
			println 'Queries (count = ' + PartitionQueriesGenerator.queries.size() + '):';
192
			for(query in PartitionQueriesGenerator.queries)	{
193
				println query;
194
			}
195
			// Displaying the part names
196
			println 'Partnames (count = ' + PartitionQueriesGenerator.partNames.size() + '):';
197
			for(partName in PartitionQueriesGenerator.partNames)	{
198
				print partName + ' / ';
199
			}
200

  
201

  
202
			// TODO : Log
203
			println 'Queries created.';
204

  
205
			// Creating the partition
206
			if(DEBUG == 0 && queries.size() == partNames.size()) {
207
				return corpus.createPartition(PARTITION_NAME, queries, partNames);
208
			}
209

  
210
		}
211
		else	{
212
			// TODO : Log
213
			println 'Structural units count or structural units properties count error.';
214
			return null
215
		}
216

  
217
	}
218

  
219

  
220

  
221

  
222
	/**
223
	 * Recurse through structural units and structural units properties of corpus and create the queries and the part names.
224
	 * @param corpus the corpus or subcorpus
225
	 * @param index the index for recursion
226
	 * @param tmpQuery the temporary query for creating subcorpus part
227
	 * @param tmpPartName the temporary part name of the subcorpus part
228
	 */
229
	protected static void process(Corpus corpus, int index, String tmpQuery, String tmpPartName)	{
230

  
231

  
232
		// End of array
233
		if(index >= STRUCTURAL_UNITS.size())	{
234

  
235
			queries.add(tmpQuery);
236
			partNames.add(PART_NAMES_PREFIX + tmpPartName);
237

  
238
			return;
239
		}
240

  
241
		StructuralUnit su = corpus.getStructuralUnit(STRUCTURAL_UNITS[index]);
242
		StructuralUnitProperty sup = su.getProperty(STRUCTURAL_UNITS_PROPERTIES[index]);
243

  
244
		// TODO : Log
245
		println ''
246
		if(index == 0)	{
247
			println 'Pocessing Structural Unit Property "' + sup.getFullName() + '" on mother corpus "' + corpus.getName() + '"';
248
		}
249
		else	{
250
			println 'Pocessing Structural Unit Property "' + sup.getFullName() + '" on subcorpus part "' + tmpPartName + '"';
251
		}
252
		println ''
253

  
254

  
255
		// Creating the queries parts for each structural units properties values
256
		//for (supValue in sup.getOrderedValues()) { // TODO : signaler bug Matthieu, on ne devrait pas être obligé de repasser le sous-corpus à la méthode car sup a déjà été créée depuis le sous-corpus ? getValues() bugge aussi
257
		for (supValue in sup.getOrderedValues(corpus)) {
258

  
259
			// TODO : Log
260
			println ''
261
			println 'Value "' + supValue + '"';
262
			println ''
263

  
264

  
265
			// Getting the subcorpus linked to the structural unit property value
266
			Subcorpus tmpSubcorpus = corpus.createSubcorpusWithQueryString(su, sup, supValue, "tmp" + UUID.randomUUID());
267

  
268
			// Partition conditions and part name separators
269
			String and = '';
270
			String underscore = '';
271
			if(tmpQuery != '')	{
272
				underscore = '_';
273
				and = ' & ';
274
			}
275

  
276

  
277
			process(tmpSubcorpus, index + 1, (tmpQuery + and + '_.' + sup.getFullName() + '="' + supValue + '"'), tmpPartName + underscore + supValue);
278

  
279
			// Deleting the temporary subcorpus
280
			// TODO : bug : cette méthode ne supprime pas le corpus sans doute car il faut que le sous-corpus ne contienne pas d'autres sous-corpus ? le delete() en revanche fonctionne.
281
//			corpus.dropSubcorpus(tmpSubcorpus);
282
			tmpSubcorpus.delete();
283

  
284
		}
285
	}
286

  
287

  
288
	/**
289
	 * 	Autoname the partition.
290
	 * @param partitionName
291
	 */
292
	protected static void autoNamePartition(String partitionName)	{
293

  
294
		// Structural units names and properties
295
		for(int i = 0; i < STRUCTURAL_UNITS.size(); i++)	{
296
			partitionName +=  STRUCTURAL_UNITS[i] + '_' + STRUCTURAL_UNITS_PROPERTIES[i] + '.';
297
		}
298

  
299
		// Structural units to ignore
300
		for(int i = 0; i < STRUCTURAL_UNITS_TO_IGNORE.size(); i++)	{
301
			partitionName +=  'NOT_' + STRUCTURAL_UNITS_TO_IGNORE[i] + '.';
302
		}
303

  
304

  
305
		// Removing last point in name
306
		PARTITION_NAME = partitionName.substring(0, partitionName.length() - 1);
307
	}
308

  
309

  
310
	/**
311
	 * Finalize the queries.
312
	 */
313
	protected static void finalizeQueries()	{
314

  
315
		String expandTo = '';
316
		// Expanding to user defined target
317
		if(EXPAND_TARGET != null && EXPAND_TARGET != '')	{
318
			expandTo = ' expand to ' + EXPAND_TARGET;
319
		}
320
		// Expanding to last child structural unit in user defined hierarchy
321
		else if(STRUCTURAL_UNITS_TO_IGNORE.size() == 0)	{
322
			expandTo = ' expand to ' + STRUCTURAL_UNITS[STRUCTURAL_UNITS.size() - 1];
323
		}
324

  
325
		// Autonaming the partition
326
		if(PARTITION_NAME == '')	{
327
			autoNamePartition(PARTITION_NAME);
328
			// Finalizing partition name
329
			PARTITION_NAME += expandTo.replace(' expand to', '.EXPAND TO').replace(' ', '_');
330
		}
331

  
332

  
333
		// Finalizing queries
334
		for(int j = 0; j < queries.size(); j++)	{
335

  
336
			String queryEnd = '';
337

  
338
			// Removing some sections
339
			for(sectionToIgnore in STRUCTURAL_UNITS_TO_IGNORE)	{
340
				queryEnd += ' & !' + sectionToIgnore;
341
			}
342

  
343
			queryEnd += ']' + expandTo;
344

  
345
			queries.set(j, '[' +  queries.get(j) + queryEnd);
346
		}
347
	}
348

  
349
}
350

  
351

  
352

  
353

  
354

  
355

  
356
/*
357
// Test dialogue de confirmation avant création de la partition
358
JFrame frame = new JFrame('test');
359
//frame.setMinimumSize(new Dimension(400, 400));
360
//frame.setVisible(true);
361
//frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
362
int n = JOptionPane.showConfirmDialog(
363
	frame, "Would you like green eggs and ham?",
364
	"An Inane Question",
365
	JOptionPane.YES_NO_OPTION);
366
if (n == JOptionPane.YES_OPTION) {
367
frame.setTitle("Ewww!");
368
} else if (n == JOptionPane.NO_OPTION) {
369
frame.setTitle("Me neither!");
370
} else {
371
frame.setTitle("Come on -- tell me!");
372
}*/
373

  
374

  
375

  
376

  
377

  
378
//// Récupération des unités structurelles et création de la liste des requêtes CQL
379
//int i = 0;
380
//ArrayList<String> queries = new ArrayList<String>();
381
//ArrayList<String> partNames = new ArrayList<String>();
382
//
383
//
384
//int currentQueriesCount;
385
//if(STRUCTURAL_UNITS.size() > 0 && STRUCTURAL_UNITS.size() == STRUCTURAL_UNITS_PROPERTIES.size())	{
386
//
387
//	// Parcours des unités strcuturelles à traiter
388
//	for (suName in STRUCTURAL_UNITS) {
389
//
390
//		// Définition auto du nom de partition
391
//		PARTITION_NAME += suName + '_';
392
//
393
//
394
//		StructuralUnit su = corpus.getStructuralUnit(suName);
395
//
396
//
397
//		// TODO : Debug
398
//		println ''
399
//		println 'Structural Unit Name: ' + su.getName();
400
//
401
//
402
//		// Récupération des propriétés d'unités structurelles
403
//		for (StructuralUnitProperty sup in su.getProperties())	{
404
//
405
//
406
//			if(STRUCTURAL_UNITS_PROPERTIES[i] != '' && sup.getName() == STRUCTURAL_UNITS_PROPERTIES[i])	{
407
//
408
//				// Définition auto du nom de partition
409
//				PARTITION_NAME += STRUCTURAL_UNITS_PROPERTIES[i] + ".";
410
//
411
//				// TODO : Debug
412
//				println "Structural Unit Property: " + sup.getName() + " ";
413
//
414
//
415
//				// Récupération des valeurs des propriétés d'unités structurelles
416
//
417
//				//for (supValue in sup.getOrderedValues()) {
418
//				for (supValue in sup.getOrderedValues()) {
419
//
420
//					// Récupération du sous-corpus lié à la valeur de propriété de structure
421
//					Subcorpus tmpSubcorpus = corpus.createSubcorpusWithQueryString(su, sup, supValue, "tmp");
422
//
423
//					String query = suName + '_' + STRUCTURAL_UNITS_PROPERTIES[i] + '="' + supValue + '"';
424
//
425
//
426
//					queries.add(query);
427
//					partNames.add(supValue);
428
//
429
//					// TODO : Debug
430
//					print supValue + " ";
431
//
432
//					// Suppression du sous-corpus temporaire
433
//					corpus.dropSubcorpus(tmpSubcorpus);
434
//
435
//				}
436
//
437
//			}
438
//		}
439
//
440
//
441
////		// Ajout des niveaux inférieurs
442
////		for(int i = 1; i < STRUCTURAL_UNITS.size(); i++)	{
443
////
444
////			for(int j = 0; j < queries.size(); j++)	{
445
////				queries.set(j, queries.get(j) + ' & _.' + STRUCTURAL_UNITS[i] + '_' + STRUCTURAL_UNITS_PROPERTIES[i] + '=".*"');
446
////
447
////				// Noms de partitions
448
////				partNames.set(j, partNames.get(j) + '_' + STRUCTURAL_UNITS[i] + '_'  + STRUCTURAL_UNITS_PROPERTIES[i]);
449
////			}
450
////		}
451
//
452
//
453
//
454
//
455
//
456
//
457
//		i++;
458
//	//	}
459
//	//	else	{
460
//	//
461
//	//	}
462
//
463
//	}
464
//
465
//
466
//
467
//
468
//
469
//	// Clôture des requêtes
470
//	for(int j = 0; j < queries.size(); j++)	{
471
//
472
//		String queryEnd = '';
473
//
474
//		// Suppression de sections
475
//		for(sectionToIgnore in STRUCTURAL_UNITS_TO_IGNORE)	{
476
//			queryEnd += ' & !' + sectionToIgnore;
477
//		}
478
//
479
//		queryEnd += ']';
480
//
481
//		// Expand to target
482
//		if(EXPAND_TARGET != null && EXPAND_TARGET != '')	{
483
//			queryEnd += ' expand to ' + EXPAND_TARGET;
484
//		}
485
//
486
//		queries.set(j, '[_.' +  queries.get(j) + queryEnd);
487
//	}
488
//}
489

  
490

  
491

  
492

  
493

  
494

  
495

  
496

  
497

  
498

  
499

  
500

  
501

  
502

  
503

  
504

  
505
////for (suName in STRUCTURAL_UNITS) {
506
//if(STRUCTURAL_UNITS.size() > 0 && STRUCTURAL_UNITS.size() == STRUCTURAL_UNITS_PROPERTIES.size())	{
507
//
508
//	suName = STRUCTURAL_UNITS[0]
509
//	//if(STRUCTURAL_UNITS.size() > 1)	{
510
//
511
//	// Définition auto du nom de partition
512
//	PARTITION_NAME += suName + '_';
513
//
514
//
515
//	// TODO : Debug
516
//	println ''
517
//	println "Structural Unit Name: $suName"
518
//
519
//	// Récupération des valeurs des propriétés d'unités structurelles
520
//	for (sup in discours.getStructuralUnitProperties(suName.asType(String)))	{
521
//
522
//		supName = STRUCTURAL_UNITS_PROPERTIES[0];
523
//
524
//		if(supName != '' && sup.getName() == supName)	{
525
//
526
//			// Définition auto du nom de partition
527
//			PARTITION_NAME += supName + ".";
528
//
529
//			// TODO : Debug
530
//			println "Structural Unit Property: " + supName + " ";
531
//
532
//			for (supValue in sup.getOrderedValues()) {
533
//
534
//				String query = '[_.' + suName + '_' + supName + '="' + supValue + '"';
535
//
536
//				// Suppression de sections
537
//				for(sectionToIgnore in STRUCTURAL_UNITS_TO_IGNORE)	{
538
//					query += ' & !' + sectionToIgnore;
539
//				}
540
//
541
//
542
//
543
//				queries.add(query);
544
//				partNames.add(supValue);
545
//
546
//				// TODO : Debug
547
//				print supValue + " ";
548
//			}
549
//		}
550
//	}
551
//
552
//
553
//	// Ajout des niveaux inférieurs
554
//	for(int i = 1; i < STRUCTURAL_UNITS.size(); i++)	{
555
//
556
//		for(int j = 0; j < queries.size(); j++)	{
557
//			queries.set(j, queries.get(j) + ' & _.' + STRUCTURAL_UNITS[i] + '_' + STRUCTURAL_UNITS_PROPERTIES[i] + '=".*"');
558
//
559
//			// Noms de partitions
560
//			partNames.set(j, partNames.get(j) + '_' + STRUCTURAL_UNITS[i] + '_'  + STRUCTURAL_UNITS_PROPERTIES[i]);
561
//		}
562
//	}
563
//
564
//
565
//	// Clôture des requêtes
566
//	for(int j = 0; j < queries.size(); j++)	{
567
//
568
//		String queryEnd = ']';
569
//
570
//		// Expand to target
571
//		if(EXPAND_TARGET != null && EXPAND_TARGET != '')	{
572
//			queryEnd += ' expand to ' + EXPAND_TARGET;
573
//		}
574
//
575
//		queries.set(j, queries.get(j) + queryEnd);
576
//	}
577
//
578
//
579
//
580
//	//i++;
581
////	}
582
////	else	{
583
////
584
////	}
585
//
586
////}
587
//}
588

  
589

  
590

  
591
// Fonctionnelle pour 1 niveau de hiérarchie
592
//// Récupération des unités structurelles et création de la liste des requêtes CQL
593
//int i = 0;
594
//String supName;
595
//ArrayList queries = new ArrayList();
596
//ArrayList partNames = new ArrayList();
597
//
598
//for (suName in STRUCTURAL_UNITS) {
599
//
600
//
601
//	// Définition auto du nom de partition
602
//	NAME += suName + '_';
603
//
604
//
605
//
606
//	println "Structural Unit Name: $suName"
607
//
608
//	// Récupération des valeurs des propriétés d'unités structurelles
609
//	for (sup in discours.getStructuralUnitProperties(suName.asType(String)))	{
610
//
611
//		supName = STRUCTURAL_UNITS_PROPERTIES[i];
612
//
613
//		if(supName != '' && sup.getName() == supName)	{
614
//
615
//			// Définition auto du nom de partition
616
//			NAME += supName + ".";
617
//
618
//			// TODO : Debug
619
//			println "Structural Unit Property: " + supName + " ";
620
//
621
//			for (supValue in sup.getOrderedValues()) {
622
//
623
//				String query = '[_.' + suName + '_' + supName + '="' + supValue + '"';
624
//
625
//				// Suppression de sections
626
//				for(sectionToIgnore in STRUCTURAL_UNITS_TO_IGNORE)	{
627
//					query += ' & !' + sectionToIgnore;
628
//				}
629
//
630
//				 query += ']';
631
//
632
//				// Expand to target
633
//				if(EXPAND_TARGET != null && EXPAND_TARGET != '')	{
634
//					query += ' expand to ' + EXPAND_TARGET;
635
//				}
636
//
637
//
638
//				queries.add(query);
639
//				partNames.add(supValue);
640
//
641
//				// TODO : Debug
642
//				print supValue + " ";
643
//			}
644
//		}
645
//	}
646
//	i++;
647
//}
648

  
649

  
650

  
651

  
652
//// start
653
//if (queries.size() == partnames.size()) {
654
////	def discours = CorpusManager.getCorpusManager().getCorpus(CORPUS)
655
//	def partition;
656
//	if (SUBCORPUS == null) {
657
//		println "partition build with $discours"
658
//		partition = discours.createPartition(NAME, queries.as, PARTNAMES)
659
//	} else {
660
//		def subcorpus
661
//		if (SUBCORPUSQUERY == null) {
662
//			println "partition build with subcorpus by name $SUBCORPUS"
663
//			subcorpus = discours.getSubcorpusByName(SUBCORPUS)
664
//			if (subcorpus == null) {
665
//				println "Error: SUBCORPUS NOT FOUND with name : $SUBCORPUS"
666
//			}
667
//		} else {
668
//			println "partition build with subcorpus with query $SUBCORPUSQUERY"
669
//			subcorpus = discours.createSubcorpus(new Query(SUBCORPUSQUERY), SUBCORPUS)
670
//		}
671
//		partition = subcorpus.createPartition(NAME, QUERIES, PARTNAMES)
672
//	}
673
//
674
//	def list = Arrays.asList(partition.getPartSizes())
675
//	println "Partition created $NAME: "+list+" parts"
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff