Révision 367
tmp/org.txm.concordance.core/build.properties (revision 367) | ||
---|---|---|
1 |
source.. = src/ |
|
2 |
output.. = bin/ |
|
3 |
bin.includes = META-INF/,\ |
|
4 |
.,\ |
|
5 |
plugin.xml |
|
0 | 6 |
tmp/org.txm.concordance.core/plugin.xml (revision 367) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<?eclipse version="3.4"?> |
|
3 |
<plugin> |
|
4 |
<extension |
|
5 |
point="org.eclipse.core.runtime.preferences"> |
|
6 |
<initializer |
|
7 |
class="org.txm.concordance.core.preferences.ConcordancePreferences"> |
|
8 |
</initializer> |
|
9 |
</extension> |
|
10 |
|
|
11 |
</plugin> |
|
0 | 12 |
tmp/org.txm.concordance.core/.settings/org.eclipse.jdt.core.prefs (revision 367) | ||
---|---|---|
1 |
eclipse.preferences.version=1 |
|
2 |
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled |
|
3 |
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 |
|
4 |
org.eclipse.jdt.core.compiler.compliance=1.6 |
|
5 |
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error |
|
6 |
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error |
|
7 |
org.eclipse.jdt.core.compiler.source=1.6 |
|
0 | 8 |
tmp/org.txm.concordance.core/.classpath (revision 367) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<classpath> |
|
3 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> |
|
4 |
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> |
|
5 |
<classpathentry kind="src" path="src"/> |
|
6 |
<classpathentry kind="output" path="bin"/> |
|
7 |
</classpath> |
|
0 | 8 |
tmp/org.txm.concordance.core/META-INF/MANIFEST.MF (revision 367) | ||
---|---|---|
1 |
Manifest-Version: 1.0 |
|
2 |
Bundle-ManifestVersion: 2 |
|
3 |
Bundle-Name: Concordances Core |
|
4 |
Bundle-SymbolicName: org.txm.concordance.core;singleton:=true |
|
5 |
Bundle-Version: 1.0.0.qualifier |
|
6 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 |
|
7 |
Require-Bundle: org.txm.core, |
|
8 |
org.txm.annotation.core;bundle-version="1.0.0", |
|
9 |
org.eclipse.core.runtime;bundle-version="3.10.0" |
|
10 |
Export-Package: org.txm.concordance.core.functions, |
|
11 |
org.txm.concordance.core.functions.comparators, |
|
12 |
org.txm.concordance.core.messages, |
|
13 |
org.txm.concordance.core.preferences |
|
14 |
Bundle-Vendor: Textometry.org |
|
0 | 15 |
tmp/org.txm.concordance.core/.project (revision 367) | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>org.txm.concordance.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 |
</buildSpec> |
|
24 |
<natures> |
|
25 |
<nature>org.eclipse.pde.PluginNature</nature> |
|
26 |
<nature>org.eclipse.jdt.core.javanature</nature> |
|
27 |
</natures> |
|
28 |
</projectDescription> |
|
0 | 29 |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/messages/messages.properties (revision 367) | ||
---|---|---|
1 |
#created/updated with GetStringsFromPropertiesFile.groovy |
|
2 |
#Mon Jul 03 14:53:55 CEST 2017 |
|
3 |
LexicographicLeftContextComparator_0=Left context |
|
4 |
NullComparator_0=None |
|
5 |
Concordance_8=Failed to get texts limits\: |
|
6 |
Concordance_7=\ results |
|
7 |
PropertiesReferenceComparator_0=References |
|
8 |
Concordance_6=Retrieving |
|
9 |
Concordance_5= |
|
10 |
Concordance_4=Failed to remove QueryResult from CQP\: |
|
11 |
Concordance_3=\ results retrieved in |
|
12 |
Concordance_2=undefined |
|
13 |
Concordance_1=** Failed to retrieve text_id property from lines |
|
14 |
Concordance_0=\ |
|
15 |
CompositeComparator_0=Composite\: |
|
16 |
LexicographicRightContextComparator_0=Right context |
|
17 |
LexicographicKeywordComparator_0=Keyword |
|
18 |
Concordance_19=Context |
|
19 |
Concordance_18= |
|
20 |
Concordance_17=Reference |
|
21 |
Concordance_16=RightContext |
|
22 |
Concordance_15=Keyword |
|
23 |
Concordance_14=LeftContext |
|
24 |
Concordance_13=Reference |
|
25 |
Concordance_12=** Failed to export Concordance\: |
|
0 | 26 |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/messages/ConcordanceMessages.java (revision 367) | ||
---|---|---|
1 |
package org.txm.concordance.core.messages; |
|
2 |
|
|
3 |
import org.eclipse.osgi.util.NLS; |
|
4 |
import org.txm.utils.messages.Utf8NLS; |
|
5 |
|
|
6 |
/** |
|
7 |
* Toolbox core messages. |
|
8 |
* |
|
9 |
* @author mdecorde |
|
10 |
* @author sjacquot |
|
11 |
* |
|
12 |
*/ |
|
13 |
public class ConcordanceMessages extends NLS { |
|
14 |
|
|
15 |
private static final String BUNDLE_NAME = "org.txm.concordance.core.messages.messages"; //$NON-NLS-1$ |
|
16 |
|
|
17 |
public static String Concordance_0; |
|
18 |
public static String Concordance_1; |
|
19 |
public static String Concordance_12; |
|
20 |
public static String Concordance_13; |
|
21 |
public static String Concordance_14; |
|
22 |
public static String Concordance_15; |
|
23 |
public static String Concordance_16; |
|
24 |
public static String Concordance_17; |
|
25 |
public static String Concordance_18; |
|
26 |
public static String Concordance_19; |
|
27 |
public static String Concordance_2; |
|
28 |
public static String Concordance_3; |
|
29 |
public static String Concordance_4; |
|
30 |
public static String Concordance_5; |
|
31 |
public static String Concordance_6; |
|
32 |
public static String Concordance_7; |
|
33 |
public static String Concordance_8; |
|
34 |
public static String CompositeComparator_0; |
|
35 |
public static String PropertiesReferenceComparator_0; |
|
36 |
public static String LexicographicLeftContextComparator_0; |
|
37 |
public static String LexicographicKeywordComparator_0; |
|
38 |
public static String LexicographicRightContextComparator_0; |
|
39 |
public static String NullComparator_0; |
|
40 |
|
|
41 |
static { |
|
42 |
// initialize resource bundle |
|
43 |
Utf8NLS.initializeMessages(BUNDLE_NAME, ConcordanceMessages.class); |
|
44 |
} |
|
45 |
} |
|
0 | 46 |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/messages/messages_ru.properties (revision 367) | ||
---|---|---|
1 |
#created/updated with GetStringsFromPropertiesFile.groovy |
|
2 |
#Mon Jul 03 14:53:55 CEST 2017 |
|
3 |
LexicographicLeftContextComparator_0=MISSING |
|
4 |
NullComparator_0=MISSING |
|
5 |
Concordance_8=MISSING |
|
6 |
Concordance_7=MISSING |
|
7 |
PropertiesReferenceComparator_0=MISSING |
|
8 |
Concordance_6=MISSING |
|
9 |
Concordance_5=MISSING |
|
10 |
Concordance_4=MISSING |
|
11 |
Concordance_3=MISSING |
|
12 |
Concordance_2=MISSING |
|
13 |
Concordance_1=MISSING |
|
14 |
Concordance_0=MISSING |
|
15 |
CompositeComparator_0=MISSING |
|
16 |
LexicographicRightContextComparator_0=MISSING |
|
17 |
LexicographicKeywordComparator_0=MISSING |
|
18 |
Concordance_19=MISSING |
|
19 |
Concordance_18=MISSING |
|
20 |
Concordance_17=MISSING |
|
21 |
Concordance_16=MISSING |
|
22 |
Concordance_15=MISSING |
|
23 |
Concordance_14=MISSING |
|
24 |
Concordance_13=MISSING |
|
25 |
Concordance_12=MISSING |
|
0 | 26 |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/messages/messages_fr.properties (revision 367) | ||
---|---|---|
1 |
#created/updated with GetStringsFromPropertiesFile.groovy |
|
2 |
#Mon Jul 03 14:53:55 CEST 2017 |
|
3 |
LexicographicLeftContextComparator_0=Contexte gauche |
|
4 |
NullComparator_0=Aucun |
|
5 |
Concordance_8=Echec de la récupération des limites de texte \: |
|
6 |
Concordance_7=\ résultats |
|
7 |
PropertiesReferenceComparator_0=Références |
|
8 |
Concordance_6=Récupération |
|
9 |
Concordance_5=MISSING |
|
10 |
Concordance_4=Echec de la suppression du QueryResult de CQP\: |
|
11 |
Concordance_3=\ résultats obtenus en |
|
12 |
Concordance_2=indéfini |
|
13 |
Concordance_1=** Echec de récupération de la propriété 'text_id' des lignes |
|
14 |
Concordance_0=\ |
|
15 |
CompositeComparator_0=Composé \: |
|
16 |
LexicographicRightContextComparator_0=Contexte droit |
|
17 |
LexicographicKeywordComparator_0=Pivot |
|
18 |
Concordance_19=Contexte |
|
19 |
Concordance_18=MISSING |
|
20 |
Concordance_17=Référence |
|
21 |
Concordance_16=ContexteDroit |
|
22 |
Concordance_15=Pivot |
|
23 |
Concordance_14=ContexteGauche |
|
24 |
Concordance_13=Référence |
|
25 |
Concordance_12=** Echec de l'exportation de la concordance \: |
|
0 | 26 |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/comparators/NullComparator.java (revision 367) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $ |
|
25 |
// $LastChangedRevision: 2386 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.concordance.core.functions.comparators; |
|
29 |
|
|
30 |
import org.txm.concordance.core.functions.Line; |
|
31 |
import org.txm.concordance.core.messages.ConcordanceMessages; |
|
32 |
|
|
33 |
// TODO: Auto-generated Javadoc |
|
34 |
/** |
|
35 |
* return the order of the text. |
|
36 |
* |
|
37 |
* @author mdecorde |
|
38 |
*/ |
|
39 |
public class NullComparator extends LocalizedLineComparator { |
|
40 |
|
|
41 |
/** The Constant NAME. */ |
|
42 |
private static final String NAME = ConcordanceMessages.NullComparator_0; |
|
43 |
|
|
44 |
/** |
|
45 |
* Instantiates a new null comparator. |
|
46 |
*/ |
|
47 |
public NullComparator() { |
|
48 |
super(NAME); |
|
49 |
} |
|
50 |
|
|
51 |
/* (non-Javadoc) |
|
52 |
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
|
53 |
*/ |
|
54 |
@Override |
|
55 |
public int compare(Line l1, Line l2) { |
|
56 |
return l1.getKeywordPosition() - l2.getKeywordPosition(); |
|
57 |
} |
|
58 |
} |
|
0 | 59 |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/comparators/PropertiesReferenceComparator.java (revision 367) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $ |
|
25 |
// $LastChangedRevision: 2386 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.concordance.core.functions.comparators; |
|
29 |
|
|
30 |
import org.txm.concordance.core.functions.Line; |
|
31 |
import org.txm.concordance.core.messages.ConcordanceMessages; |
|
32 |
import org.txm.functions.Reference; |
|
33 |
import org.txm.searchengine.cqp.corpus.Property; |
|
34 |
|
|
35 |
// TODO: Auto-generated Javadoc |
|
36 |
/** |
|
37 |
* Compare the references of concordance line @ author mdecorde. |
|
38 |
*/ |
|
39 |
public class PropertiesReferenceComparator extends LocalizedLineComparator { |
|
40 |
|
|
41 |
/** The Constant NAME. */ |
|
42 |
private static final String NAME = ConcordanceMessages.PropertiesReferenceComparator_0; |
|
43 |
|
|
44 |
//protected Collator collator = Collator.getInstance(new Locale(System.getProperty("user.language"))); //$NON-NLS-1$ |
|
45 |
|
|
46 |
/** |
|
47 |
* Instantiates a new properties reference comparator. |
|
48 |
*/ |
|
49 |
public PropertiesReferenceComparator() { |
|
50 |
super(NAME); |
|
51 |
} |
|
52 |
|
|
53 |
/* (non-Javadoc) |
|
54 |
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
|
55 |
*/ |
|
56 |
@Override |
|
57 |
public int compare(Line l1, Line l2) { |
|
58 |
if (l1 == null || l2 == null) |
|
59 |
return 0; |
|
60 |
|
|
61 |
Reference ref1 = l1.getAnaRef(); |
|
62 |
Reference ref2 = l2.getAnaRef(); |
|
63 |
assert (ref1.getReferencePattern().equals(ref2.getReferencePattern())); |
|
64 |
for (Property prop : ref1.getProperties()) { |
|
65 |
int c = 0; |
|
66 |
try { |
|
67 |
Integer i1 = Integer.parseInt(ref1.getValue(prop)); |
|
68 |
Integer i2 = Integer.parseInt(ref2.getValue(prop)); |
|
69 |
c = i1.compareTo(i2); |
|
70 |
} catch (NumberFormatException e) { |
|
71 |
//System.out.println("sort "+ref1+ " "+ ref2 +" with "+collator); |
|
72 |
c = collator.compare(ref1.getValue(prop), ref2.getValue(prop)); |
|
73 |
} |
|
74 |
|
|
75 |
if (c != 0) { |
|
76 |
return c; |
|
77 |
} |
|
78 |
} |
|
79 |
return 0; |
|
80 |
} |
|
81 |
} |
|
0 | 82 |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/comparators/ReverseComparator.java (revision 367) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $ |
|
25 |
// $LastChangedRevision: 2386 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.concordance.core.functions.comparators; |
|
29 |
|
|
30 |
import org.txm.concordance.core.functions.Line; |
|
31 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
32 |
|
|
33 |
// TODO: Auto-generated Javadoc |
|
34 |
/** |
|
35 |
* Revert a comparator @ author mdecorde. |
|
36 |
*/ |
|
37 |
public class ReverseComparator extends LineComparator { |
|
38 |
|
|
39 |
/** The comparator. */ |
|
40 |
private LineComparator comparator; |
|
41 |
|
|
42 |
/** |
|
43 |
* Instantiates a new reverse comparator. |
|
44 |
* |
|
45 |
* @param name the name |
|
46 |
* @param comparator the comparator |
|
47 |
*/ |
|
48 |
public ReverseComparator(String name, LineComparator comparator) { |
|
49 |
super(name); |
|
50 |
this.comparator = comparator; |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* Instantiates a new reverse comparator. |
|
55 |
* |
|
56 |
* @param comparator the comparator |
|
57 |
*/ |
|
58 |
public ReverseComparator(LineComparator comparator) { |
|
59 |
super(comparator.getName()); |
|
60 |
this.comparator = comparator; |
|
61 |
} |
|
62 |
|
|
63 |
/* (non-Javadoc) |
|
64 |
* @see org.txm.functions.concordances.comparators.LineComparator#initialize(org.txm.searchengine.cqp.corpus.Corpus) |
|
65 |
*/ |
|
66 |
@Override |
|
67 |
public void initialize(Corpus corpus) { |
|
68 |
comparator.initialize(corpus); |
|
69 |
} |
|
70 |
|
|
71 |
/* (non-Javadoc) |
|
72 |
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
|
73 |
*/ |
|
74 |
@Override |
|
75 |
public int compare(Line l1, Line l2) { |
|
76 |
return -1 * comparator.compare(l1, l2); |
|
77 |
} |
|
78 |
} |
|
0 | 79 |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/comparators/LocalizedLineComparator.java (revision 367) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2014-07-15 09:42:00 +0200 (mar., 15 juil. 2014) $ |
|
25 |
// $LastChangedRevision: 2820 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.concordance.core.functions.comparators; |
|
29 |
|
|
30 |
import java.text.Collator; |
|
31 |
import java.util.Locale; |
|
32 |
|
|
33 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
34 |
import org.txm.utils.logger.Log; |
|
35 |
|
|
36 |
// TODO: Auto-generated Javadoc |
|
37 |
/** |
|
38 |
* use the giver locale to compare concordance line, if locale is not defined, |
|
39 |
* use the system locale @ author mdecorde. |
|
40 |
*/ |
|
41 |
public abstract class LocalizedLineComparator extends LineComparator { |
|
42 |
|
|
43 |
/** The locale. */ |
|
44 |
private Locale locale = new Locale("en", "US"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
45 |
|
|
46 |
/** The collator. */ |
|
47 |
protected Collator collator; |
|
48 |
|
|
49 |
/** |
|
50 |
* Instantiates a new localized line comparator. |
|
51 |
* |
|
52 |
* @param name the name |
|
53 |
*/ |
|
54 |
public LocalizedLineComparator(String name) { |
|
55 |
super(name); |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* Gets the locale. |
|
60 |
* |
|
61 |
* @return the locale |
|
62 |
*/ |
|
63 |
public Locale getLocale() { |
|
64 |
return locale; |
|
65 |
} |
|
66 |
|
|
67 |
/** |
|
68 |
* Sets the locale. |
|
69 |
* |
|
70 |
* @param locale the new locale |
|
71 |
*/ |
|
72 |
public void setLocale(Locale locale) { |
|
73 |
Log.info("Set comparator locale to "+locale); |
|
74 |
this.locale = locale; |
|
75 |
this.collator = Collator.getInstance(locale); |
|
76 |
this.collator.setStrength(Collator.TERTIARY); |
|
77 |
} |
|
78 |
|
|
79 |
/* (non-Javadoc) |
|
80 |
* @see org.txm.functions.concordances.comparators.LineComparator#initialize(org.txm.searchengine.cqp.corpus.Corpus) |
|
81 |
*/ |
|
82 |
@Override |
|
83 |
public void initialize(Corpus corpus) { |
|
84 |
setLocale(corpus.getLocale()); |
|
85 |
} |
|
86 |
} |
|
0 | 87 |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/comparators/LexicographicLeftContextComparator.java (revision 367) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2014-07-15 09:42:00 +0200 (mar., 15 juil. 2014) $ |
|
25 |
// $LastChangedRevision: 2820 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.concordance.core.functions.comparators; |
|
29 |
|
|
30 |
import java.util.HashMap; |
|
31 |
import java.util.List; |
|
32 |
|
|
33 |
import org.txm.concordance.core.functions.Concordance; |
|
34 |
import org.txm.concordance.core.functions.Line; |
|
35 |
import org.txm.concordance.core.messages.ConcordanceMessages; |
|
36 |
import org.txm.searchengine.cqp.corpus.Property; |
|
37 |
|
|
38 |
// TODO: Auto-generated Javadoc |
|
39 |
/** |
|
40 |
* Compare two values of left context of a concordance line @ author mdecorde. |
|
41 |
*/ |
|
42 |
public class LexicographicLeftContextComparator extends |
|
43 |
StringListBasedComparator { |
|
44 |
|
|
45 |
/** The Constant NAME. */ |
|
46 |
private static final String NAME = ConcordanceMessages.LexicographicLeftContextComparator_0; |
|
47 |
private Concordance conc; |
|
48 |
private List<Property> props; |
|
49 |
|
|
50 |
/** |
|
51 |
* Instantiates a new lexicographic left context comparator. |
|
52 |
*/ |
|
53 |
public LexicographicLeftContextComparator() { |
|
54 |
super(NAME); |
|
55 |
} |
|
56 |
|
|
57 |
/* (non-Javadoc) |
|
58 |
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
|
59 |
*/ |
|
60 |
@Override |
|
61 |
public int compare(Line l1, Line l2) { |
|
62 |
|
|
63 |
this.conc = l1.getConcordance(); |
|
64 |
this.props = conc.getLeftAnalysisProperties(); |
|
65 |
if (props.size() == 0) |
|
66 |
return 0; |
|
67 |
int rez = 0; |
|
68 |
int i = 0; |
|
69 |
|
|
70 |
HashMap<Property, List<String>> values1 = l1.getLeftAnalysisProperty(); |
|
71 |
HashMap<Property, List<String>> values2 = l2.getLeftAnalysisProperty(); |
|
72 |
int j1 = l1.getLeftAnalysisProperty().get(props.get(0)).size() -1; |
|
73 |
int j2 = l2.getLeftAnalysisProperty().get(props.get(0)).size() -1; |
|
74 |
|
|
75 |
String v1, v2; |
|
76 |
|
|
77 |
while (rez == 0) { |
|
78 |
|
|
79 |
if ((j1 < 0) && (j2 < 0)) |
|
80 |
return 0; |
|
81 |
if (j1 < 0) |
|
82 |
return -1; // end of line 1 |
|
83 |
if (j2 < 0) |
|
84 |
return 1; // end of line 2 |
|
85 |
|
|
86 |
v1 = values1.get(props.get(i)).get(j1); |
|
87 |
v2 = values2.get(props.get(i)).get(j2); |
|
88 |
|
|
89 |
if (v1 == null) return -1; |
|
90 |
if (v2 == null) return 1; |
|
91 |
|
|
92 |
rez = collator.compare(v1, v2); |
|
93 |
if (++i >= props.size()) { // iterates over properties before tokens |
|
94 |
i = 0; |
|
95 |
j1--; |
|
96 |
j2--; |
|
97 |
} |
|
98 |
} |
|
99 |
return rez; |
|
100 |
} |
|
101 |
} |
|
0 | 102 |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/comparators/StringListBasedComparator.java (revision 367) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $ |
|
25 |
// $LastChangedRevision: 2386 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.concordance.core.functions.comparators; |
|
29 |
|
|
30 |
import java.util.Iterator; |
|
31 |
import java.util.List; |
|
32 |
|
|
33 |
// TODO: Auto-generated Javadoc |
|
34 |
/** |
|
35 |
* The Class StringListBasedComparator. |
|
36 |
*/ |
|
37 |
public abstract class StringListBasedComparator extends LocalizedLineComparator { |
|
38 |
|
|
39 |
/** |
|
40 |
* Instantiates a new string list based comparator. |
|
41 |
* |
|
42 |
* @param name the name |
|
43 |
*/ |
|
44 |
StringListBasedComparator(String name) { |
|
45 |
super(name); |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* Compare list. |
|
50 |
* |
|
51 |
* @param l1 the l1 |
|
52 |
* @param l2 the l2 |
|
53 |
* @return the int |
|
54 |
*/ |
|
55 |
protected int compareList(List<String> l1, List<String> l2) { |
|
56 |
Iterator<String> it1 = l1.iterator(); |
|
57 |
Iterator<String> it2 = l2.iterator(); |
|
58 |
|
|
59 |
while (it1.hasNext() && it2.hasNext()) { |
|
60 |
int c = collator.compare(it1.next(), it2.next()); |
|
61 |
if (c != 0) |
|
62 |
return c; |
|
63 |
} |
|
64 |
if (it1.hasNext()) |
|
65 |
return 1; // it2 is a prefix of it1 |
|
66 |
if (it2.hasNext()) |
|
67 |
return -1; // it1 is a prefix of it2 |
|
68 |
return 0; |
|
69 |
} |
|
70 |
} |
|
0 | 71 |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/comparators/CompositeComparator.java (revision 367) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $ |
|
25 |
// $LastChangedRevision: 2386 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.concordance.core.functions.comparators; |
|
29 |
|
|
30 |
import java.util.List; |
|
31 |
|
|
32 |
import org.txm.concordance.core.functions.Line; |
|
33 |
import org.txm.concordance.core.messages.ConcordanceMessages; |
|
34 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
35 |
|
|
36 |
// TODO: Auto-generated Javadoc |
|
37 |
/** |
|
38 |
* The Class CompositeComparator. |
|
39 |
*/ |
|
40 |
public class CompositeComparator extends LineComparator { |
|
41 |
|
|
42 |
/** The comparators. */ |
|
43 |
private List<LineComparator> comparators; |
|
44 |
|
|
45 |
/** |
|
46 |
* Instantiates a new composite comparator. A composite comparator C is made |
|
47 |
* of a list compartors [C0,...,Cn]. C.compare(l1,l2) == 1 (resp. -1) if and |
|
48 |
* only if their exists k such as Ci.compare(l1,l2)==0 for i<k and |
|
49 |
* Ck.compare(l1,l2)=1 (resp. -1) C.compare(l1,l2) == 0 if and only if |
|
50 |
* Ci.compare(l1,l2)==0 for all i |
|
51 |
* |
|
52 |
* @param name the name |
|
53 |
* @param comparators the comparators |
|
54 |
*/ |
|
55 |
public CompositeComparator(String name, List<LineComparator> comparators) { |
|
56 |
super(name); |
|
57 |
setComparators(comparators); |
|
58 |
} |
|
59 |
|
|
60 |
/*public CompositeComparator addComparator(LineComparator comparator) { |
|
61 |
this.comparators.add(comparator); |
|
62 |
return this; |
|
63 |
}*/ |
|
64 |
|
|
65 |
/* (non-Javadoc) |
|
66 |
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
|
67 |
*/ |
|
68 |
@Override |
|
69 |
public int compare(Line l1, Line l2) { |
|
70 |
//System.out.println("compare: "+l1+" "+l2); |
|
71 |
for (LineComparator comparator : comparators) { |
|
72 |
int c = comparator.compare(l1, l2); |
|
73 |
//System.out.println("comparator: "+comparator+" = "+c); |
|
74 |
if (c != 0) |
|
75 |
return c; |
|
76 |
} |
|
77 |
return 0; |
|
78 |
} |
|
79 |
|
|
80 |
/* (non-Javadoc) |
|
81 |
* @see org.txm.functions.concordances.comparators.LineComparator#initialize(org.txm.searchengine.cqp.corpus.Corpus) |
|
82 |
*/ |
|
83 |
@Override |
|
84 |
public void initialize(Corpus corpus) { |
|
85 |
for (LineComparator comparator : comparators) |
|
86 |
comparator.initialize(corpus); |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* Gets the comparators. |
|
91 |
* |
|
92 |
* @return the comparators |
|
93 |
*/ |
|
94 |
public List<LineComparator> getComparators() { |
|
95 |
return comparators; |
|
96 |
} |
|
97 |
|
|
98 |
/** |
|
99 |
* Sets the comparators. |
|
100 |
* |
|
101 |
* @param comp the new comparators |
|
102 |
*/ |
|
103 |
public void setComparators(List<LineComparator> comp) { |
|
104 |
this.comparators = comp; |
|
105 |
this.name = ConcordanceMessages.CompositeComparator_0; |
|
106 |
for(LineComparator c: comp) |
|
107 |
this.name += c.getName()+" "; //$NON-NLS-1$ |
|
108 |
} |
|
109 |
} |
|
0 | 110 |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/comparators/LexicographicRightContextComparator.java (revision 367) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2014-07-15 09:42:00 +0200 (mar., 15 juil. 2014) $ |
|
25 |
// $LastChangedRevision: 2820 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.concordance.core.functions.comparators; |
|
29 |
|
|
30 |
import java.util.HashMap; |
|
31 |
import java.util.List; |
|
32 |
|
|
33 |
import org.txm.concordance.core.functions.Concordance; |
|
34 |
import org.txm.concordance.core.functions.Line; |
|
35 |
import org.txm.concordance.core.messages.ConcordanceMessages; |
|
36 |
import org.txm.searchengine.cqp.corpus.Property; |
|
37 |
|
|
38 |
// TODO: Auto-generated Javadoc |
|
39 |
/** |
|
40 |
* Compare two values of right context of a concordance line @ author mdecorde. |
|
41 |
*/ |
|
42 |
public class LexicographicRightContextComparator extends |
|
43 |
StringListBasedComparator { |
|
44 |
|
|
45 |
/** The Constant NAME. */ |
|
46 |
private static final String NAME = ConcordanceMessages.LexicographicRightContextComparator_0; |
|
47 |
private Concordance conc; |
|
48 |
private List<Property> props; |
|
49 |
|
|
50 |
/** |
|
51 |
* Instantiates a new lexicographic right context comparator. |
|
52 |
*/ |
|
53 |
public LexicographicRightContextComparator() { |
|
54 |
super(NAME); |
|
55 |
} |
|
56 |
|
|
57 |
/* (non-Javadoc) |
|
58 |
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
|
59 |
*/ |
|
60 |
@Override |
|
61 |
public int compare(Line l1, Line l2) { |
|
62 |
int rez = 0; |
|
63 |
int i = 0; // property counter |
|
64 |
int j = 0; // position counter |
|
65 |
HashMap<Property, List<String>> values1 = l1.getRightAnalysisProperty(); |
|
66 |
HashMap<Property, List<String>> values2 = l2.getRightAnalysisProperty(); |
|
67 |
this.conc = l1.getConcordance(); |
|
68 |
this.props = conc.getRightAnalysisProperties(); |
|
69 |
|
|
70 |
List<String> vals1; |
|
71 |
List<String> vals2; |
|
72 |
|
|
73 |
String v1, v2; |
|
74 |
|
|
75 |
int size1 = values1.get(props.get(0)).size(); |
|
76 |
int size2 = values2.get(props.get(0)).size(); |
|
77 |
|
|
78 |
while (rez == 0) { |
|
79 |
// vals1 = values1.get(props.get(i)); |
|
80 |
// vals2 = values2.get(props.get(i)); |
|
81 |
|
|
82 |
//System.out.println("LINE 1: "+vals1); |
|
83 |
//System.out.println("LINE 2: "+vals2); |
|
84 |
if(size1 <= j && size2 <= j) |
|
85 |
return 0; // end of line 1 |
|
86 |
if (size1 <= j) |
|
87 |
return -1; // end of line 1 |
|
88 |
if (size2 <= j) |
|
89 |
return 1; // end of line 2 |
|
90 |
|
|
91 |
v1 = values1.get(props.get(i)).get(j); |
|
92 |
v2 = values2.get(props.get(i)).get(j); |
|
93 |
|
|
94 |
//System.out.println("COMP "+j+" : "+v1+" "+v2); |
|
95 |
if (v1 == null) return -1; |
|
96 |
if (v2 == null) return 1; |
|
97 |
|
|
98 |
rez = collator.compare(v1, v2); |
|
99 |
if (++i >= props.size()) { // iterates over properties before tokens |
|
100 |
i = 0; |
|
101 |
j++; |
|
102 |
} |
|
103 |
} |
|
104 |
return rez; |
|
105 |
} |
|
106 |
} |
|
0 | 107 |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/comparators/LexicographicKeywordComparator.java (revision 367) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $ |
|
25 |
// $LastChangedRevision: 2386 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.concordance.core.functions.comparators; |
|
29 |
|
|
30 |
import java.util.HashMap; |
|
31 |
import java.util.List; |
|
32 |
|
|
33 |
import org.txm.concordance.core.functions.Concordance; |
|
34 |
import org.txm.concordance.core.functions.Line; |
|
35 |
import org.txm.concordance.core.messages.ConcordanceMessages; |
|
36 |
import org.txm.searchengine.cqp.corpus.Property; |
|
37 |
|
|
38 |
// TODO: Auto-generated Javadoc |
|
39 |
/** |
|
40 |
* Compare two values of keyword of a concordance line |
|
41 |
* @author mdecorde. |
|
42 |
*/ |
|
43 |
public class LexicographicKeywordComparator extends LocalizedLineComparator { |
|
44 |
|
|
45 |
/** The Constant NAME. */ |
|
46 |
private static final String NAME = ConcordanceMessages.LexicographicKeywordComparator_0; |
|
47 |
private Concordance conc; |
|
48 |
private List<Property> props; |
|
49 |
|
|
50 |
/** |
|
51 |
* Instantiates a new lexicographic keyword comparator. |
|
52 |
*/ |
|
53 |
public LexicographicKeywordComparator() { |
|
54 |
super(NAME); |
|
55 |
} |
|
56 |
|
|
57 |
/* (non-Javadoc) |
|
58 |
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) |
|
59 |
*/ |
|
60 |
@Override |
|
61 |
public int compare(Line l1, Line l2) { |
|
62 |
int rez = 0; |
|
63 |
int i = 0; |
|
64 |
int j = 0; |
|
65 |
HashMap<Property, List<String>> values1 = l1.getKeywordsAnalysisProperty(); |
|
66 |
HashMap<Property, List<String>> values2 = l2.getKeywordsAnalysisProperty(); |
|
67 |
this.conc = l1.getConcordance(); |
|
68 |
this.props = conc.getKeywordAnalysisProperties(); |
|
69 |
while(rez == 0) { |
|
70 |
List<String> vals1 = values1.get(props.get(i)); |
|
71 |
List<String> vals2 = values2.get(props.get(i)); |
|
72 |
if(vals1.size() <= j && vals2.size() <= j) |
|
73 |
return 0; // end of line 1 |
|
74 |
if(vals1.size() <= j) |
|
75 |
return -1; // end of line 1 |
|
76 |
if(vals2.size() <= j) |
|
77 |
return 1; // end of line 2 |
|
78 |
rez = collator.compare(vals1.get(j), vals2.get(j)); |
|
79 |
if(++i >= props.size()) { // iterates over properties before tokens |
|
80 |
i = 0; |
|
81 |
j++; |
|
82 |
} |
|
83 |
} |
|
84 |
|
|
85 |
return rez; |
|
86 |
} |
|
87 |
} |
|
0 | 88 |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/comparators/package.html (revision 367) | ||
---|---|---|
1 |
<html> |
|
2 |
<body> |
|
3 |
<p>Sorters for displaying concordance.</p> |
|
4 |
</body> |
|
5 |
</html> |
|
0 | 6 |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/comparators/LineComparator.java (revision 367) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2013-05-06 17:38:43 +0200 (lun., 06 mai 2013) $ |
|
25 |
// $LastChangedRevision: 2386 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.concordance.core.functions.comparators; |
|
29 |
|
|
30 |
import java.util.Comparator; |
|
31 |
|
|
32 |
import org.txm.concordance.core.functions.Line; |
|
33 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
34 |
|
|
35 |
// TODO: Auto-generated Javadoc |
|
36 |
/** |
|
37 |
* Abstract comparator of concordance line @ author mdecorde. |
|
38 |
*/ |
|
39 |
public abstract class LineComparator implements Comparator<Line> { |
|
40 |
|
|
41 |
/** The name. */ |
|
42 |
protected String name; |
|
43 |
|
|
44 |
/** The available comparator. */ |
|
45 |
private static String[] availableComparator = new String[] { |
|
46 |
"org.txm.functions.concordances.comparators.LexicographicKeywordComparator", //$NON-NLS-1$ |
|
47 |
"org.txm.functions.concordances.comparators.LexicographicLeftContextComparator", //$NON-NLS-1$ |
|
48 |
"org.txm.functions.concordances.comparators.LexicographicRightContextComparator", //$NON-NLS-1$ |
|
49 |
"org.txm.functions.concordances.comparators.PropertiesReferenceComparator" //$NON-NLS-1$ |
|
50 |
}; |
|
51 |
|
|
52 |
/** |
|
53 |
* Return the list of all the known comparators. Any non-abstract class |
|
54 |
* extending LineComparator should be mentionned in the availableComparator |
|
55 |
* list |
|
56 |
* |
|
57 |
* @return the available comparators |
|
58 |
*/ |
|
59 |
static public String[] getAvailableComparators() { |
|
60 |
return availableComparator; |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* Instantiates a new line comparator. |
|
65 |
* |
|
66 |
* @param name the name |
|
67 |
*/ |
|
68 |
public LineComparator(String name) { |
|
69 |
this.name = name; |
|
70 |
|
|
71 |
} |
|
72 |
|
|
73 |
/** |
|
74 |
* Gets the name. |
|
75 |
* |
|
76 |
* @return the name |
|
77 |
*/ |
|
78 |
public String getName() { |
|
79 |
return name; |
|
80 |
} |
|
81 |
|
|
82 |
/* (non-Javadoc) |
|
83 |
* @see java.lang.Object#toString() |
|
84 |
*/ |
|
85 |
@Override |
|
86 |
public String toString() { |
|
87 |
return "C:" + name; //$NON-NLS-1$ |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* Initialize. |
|
92 |
* |
|
93 |
* @param corpus the corpus |
|
94 |
*/ |
|
95 |
public abstract void initialize(Corpus corpus); |
|
96 |
|
|
97 |
} |
|
0 | 98 |
tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java (revision 367) | ||
---|---|---|
1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
4 |
// Sophia Antipolis, University of Paris 3. |
|
5 |
// |
|
6 |
// The TXM platform is free software: you can redistribute it |
|
7 |
// and/or modify it under the terms of the GNU General Public |
|
8 |
// License as published by the Free Software Foundation, |
|
9 |
// either version 2 of the License, or (at your option) any |
|
10 |
// later version. |
|
11 |
// |
|
12 |
// The TXM platform is distributed in the hope that it will be |
|
13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
15 |
// PURPOSE. See the GNU General Public License for more |
|
16 |
// details. |
|
17 |
// |
|
18 |
// You should have received a copy of the GNU General |
|
19 |
// Public License along with the TXM platform. If not, see |
|
20 |
// http://www.gnu.org/licenses. |
|
21 |
// |
|
22 |
// |
|
23 |
// |
|
24 |
// $LastChangedDate: 2016-11-29 16:47:07 +0100 (Tue, 29 Nov 2016) $ |
|
25 |
// $LastChangedRevision: 3349 $ |
|
26 |
// $LastChangedBy: mdecorde $ |
|
27 |
// |
|
28 |
package org.txm.concordance.core.functions; |
|
29 |
|
|
30 |
import java.io.BufferedOutputStream; |
|
31 |
import java.io.BufferedWriter; |
|
32 |
import java.io.File; |
|
33 |
import java.io.FileOutputStream; |
|
34 |
import java.io.IOException; |
|
35 |
import java.io.OutputStreamWriter; |
|
36 |
import java.io.UnsupportedEncodingException; |
|
37 |
import java.io.Writer; |
|
38 |
import java.util.ArrayList; |
|
39 |
import java.util.Arrays; |
|
40 |
import java.util.Collections; |
|
41 |
import java.util.Comparator; |
|
42 |
import java.util.HashMap; |
|
43 |
import java.util.HashSet; |
|
44 |
import java.util.List; |
|
45 |
import java.util.Map; |
|
46 |
|
|
47 |
import org.txm.annotation.Annotation; |
|
48 |
import org.txm.annotation.AnnotationManager; |
|
49 |
import org.txm.annotation.repository.AnnotationType; |
|
50 |
import org.txm.annotation.repository.TypedValue; |
|
51 |
import org.txm.concordance.core.functions.comparators.LineComparator; |
|
52 |
import org.txm.concordance.core.messages.ConcordanceMessages; |
|
53 |
//import org.txm.core.messages.ConcordanceMessages; |
|
54 |
import org.txm.functions.Function; |
|
55 |
import org.txm.functions.Reference; |
|
56 |
import org.txm.functions.ReferencePattern; |
|
57 |
import org.txm.searchengine.cqp.AbstractCqiClient; |
|
58 |
import org.txm.searchengine.cqp.MemCqiClient; |
|
59 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
60 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
61 |
import org.txm.searchengine.cqp.corpus.CorpusManager; |
|
62 |
import org.txm.searchengine.cqp.corpus.Property; |
|
63 |
import org.txm.searchengine.cqp.corpus.QueryResult; |
|
64 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
|
65 |
import org.txm.searchengine.cqp.corpus.query.Match; |
|
66 |
import org.txm.searchengine.cqp.corpus.query.Query; |
|
67 |
import org.txm.searchengine.cqp.serverException.CqiServerError; |
|
68 |
import org.txm.statsengine.r.core.RWorkspace; |
|
69 |
import org.txm.statsengine.r.core.exceptions.RWorkspaceException; |
|
70 |
import org.txm.utils.logger.Log; |
|
71 |
|
|
72 |
// TODO: Auto-generated Javadoc |
|
73 |
/** |
|
74 |
* The Class Concordance. |
|
75 |
* |
|
76 |
* @author jmague, mdecorde |
|
77 |
*/ |
|
78 |
public class Concordance extends Function { |
|
79 |
|
|
80 |
/** |
|
81 |
* The Enum Format. |
|
82 |
*/ |
|
83 |
public enum Format { |
|
84 |
/** The CONCORDANCE. */ |
|
85 |
CONCORDANCE, |
|
86 |
/** The CONTEXT. */ |
|
87 |
CONTEXT |
|
88 |
}; |
|
89 |
|
|
90 |
/** The lines. */ |
|
91 |
private List<Line> lines; |
|
92 |
|
|
93 |
/** The query result. */ |
|
94 |
private QueryResult queryResult; |
|
95 |
|
|
96 |
/** The view properties. */ |
|
97 |
private List<Property> viewProperties; // contains all the view properties |
|
98 |
// needed |
|
99 |
/** The left c view properties. */ |
|
100 |
private List<Property> leftCViewProperties; |
|
101 |
|
|
102 |
/** The right c view properties. */ |
|
103 |
private List<Property> rightCViewProperties; |
|
104 |
|
|
105 |
/** The keyword view properties. */ |
|
106 |
private List<Property> keywordViewProperties; |
|
107 |
|
|
108 |
/** The analysis property. */ |
|
109 |
private List<Property> leftAnalysisProperties; |
|
110 |
|
|
111 |
/** The right c analysis property. */ |
|
112 |
private List<Property> rightAnalysisProperties; |
|
113 |
|
|
114 |
/** The keyword analysis property. */ |
|
115 |
private List<Property> keywordAnalysisProperties; |
|
116 |
|
|
117 |
/** The n lines. */ |
|
118 |
private int nLines; |
|
119 |
|
|
120 |
/** The right context size. */ |
|
121 |
private int rightContextSize; |
|
122 |
|
|
123 |
/** The left context size. */ |
|
124 |
private int leftContextSize; |
|
125 |
|
|
126 |
/** The corpus. */ |
|
127 |
//private Corpus corpus; |
|
128 |
|
|
129 |
/** The reference pattern. */ |
|
130 |
private ReferencePattern refViewPattern; |
|
131 |
private ReferencePattern refAnalysePattern; |
|
132 |
|
|
133 |
/** The cache. */ |
|
134 |
//private Map<Property, CqpDataProxy> cache; |
|
135 |
|
|
136 |
/** The query. */ |
|
137 |
private Query query; |
|
138 |
|
|
139 |
/** The symbol. */ |
|
140 |
private String symbol; |
|
141 |
|
|
142 |
/** The writer. */ |
|
143 |
private Writer writer; |
|
144 |
|
|
145 |
/** |
|
146 |
* Creates a new concordance and compute it. |
|
147 |
* |
|
148 |
* @param corpus The corpus on which apply the query |
|
149 |
* @param query The query defining the keywords |
|
150 |
* @param analysisProperty The property used to sort the lines |
|
151 |
* @param viewProperties The property used to print the lines |
|
152 |
* @param referencePattern the reference pattern |
|
153 |
* @param leftContextSize The size in words of the left context |
|
154 |
* @param rightContextSize The size in words of the right context |
|
155 |
* @throws CqiClientException the cqi client exception |
|
156 |
*/ |
|
157 |
public Concordance(Corpus corpus, Query query, Property analysisProperty, |
|
158 |
List<Property> viewProperties, ReferencePattern referencePattern, ReferencePattern refAnalysePattern, |
|
159 |
int leftContextSize, int rightContextSize) |
|
160 |
throws CqiClientException { |
|
161 |
|
|
162 |
super(corpus); |
|
163 |
// set concordance parameters |
|
164 |
this.query = query; |
|
165 |
this.leftAnalysisProperties = Arrays.asList(analysisProperty); // same analysis property |
|
166 |
this.rightAnalysisProperties = Arrays.asList(analysisProperty); |
|
167 |
this.keywordAnalysisProperties = Arrays.asList(analysisProperty); |
|
168 |
this.viewProperties = viewProperties; // same view property for left, right context and keyword |
|
169 |
this.leftCViewProperties = viewProperties; |
|
170 |
this.rightCViewProperties = viewProperties; |
|
171 |
this.keywordViewProperties = viewProperties; |
|
172 |
this.updateViewPropertiesList(); |
|
173 |
this.refViewPattern = referencePattern; |
|
174 |
this.refAnalysePattern = refAnalysePattern; |
|
175 |
this.leftContextSize = leftContextSize; |
|
176 |
this.rightContextSize = rightContextSize; |
|
177 |
|
|
178 |
if (corpus != null) { |
|
179 |
setCQLSeparator(corpus.getCQLLimitQuery()); |
|
180 |
} |
|
181 |
|
|
182 |
computeConcordance(); |
|
183 |
} |
|
184 |
|
|
185 |
/** |
|
186 |
* Creates a new concordance and compute it. |
|
187 |
* |
|
188 |
* @param corpus The corpus on which apply the query |
|
189 |
* @param query The query defining the keywords |
|
190 |
* @param analysisProperty The property used to sort the lines |
|
191 |
* @param leftCViewProperties The property used to print the lines of Left context |
|
192 |
* @param rightCViewProperties The property used to print the lines of right context |
|
193 |
* @param keywordViewProperties The property used to print the lines of keyword |
|
194 |
* @param referencePattern the reference pattern |
Formats disponibles : Unified diff