Révision 2719
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/annotation/CQL2WordAnnotationsMacro.groovy (revision 2719) | ||
---|---|---|
7 | 7 |
import org.txm.searchengine.cqp.corpus.query.* |
8 | 8 |
import org.txm.rcp.views.corpora.CorporaView |
9 | 9 |
import org.txm.annotation.kr.core.KRAnnotationEngine |
10 |
import org.txm.annotation.kr.core.repository.* |
|
10 |
import org.txm.annotation.kr.core.DatabasePersistenceManager |
|
11 |
import org.txm.annotation.kr.core.repository.KnowledgeRepositoryManager |
|
11 | 12 |
|
12 | 13 |
def scriptName = this.class.getSimpleName() |
13 | 14 |
|
... | ... | |
19 | 20 |
CQPCorpus corpus = corpusViewSelection |
20 | 21 |
|
21 | 22 |
MainCorpus mcorpus = corpus.getMainCorpus(); |
22 |
KnowledgeRepository kr = KnowledgeRepositoryManager.createSimpleKnowledgeRepository(mcorpus.getName()); |
|
23 | 23 |
|
24 |
KnowledgeRepository kr = null // the following code should be replaced with KnowledgeRepository.createSimpleKnowledgeRepository(mcorpus.getName()) |
|
25 |
if (KnowledgeRepositoryManager.getKnowledgeRepository(mcorpus.getName()) != null) { |
|
26 |
kr = getKnowledgeRepository(mcorpus.getName()); |
|
27 |
} else { |
|
28 |
HashMap<String, HashMap<String, ?>> conf = new HashMap<>(); |
|
29 |
HashMap<String, String> access = new HashMap<>(); |
|
30 |
conf.put(KRAnnotationEngine.KNOWLEDGE_ACCESS, access); |
|
31 |
HashMap<String, HashMap<String, String>> fields = new HashMap<>(); |
|
32 |
conf.put(KRAnnotationEngine.KNOWLEDGE_TYPES, fields); |
|
33 |
HashMap<String, HashMap<String, String>> strings = new HashMap<>(); |
|
34 |
conf.put(KRAnnotationEngine.KNOWLEDGE_STRINGS, strings); |
|
35 |
access.put("mode", DatabasePersistenceManager.ACCESS_FILE); |
|
36 |
access.put("version", "0"); |
|
37 |
kr = KnowledgeRepositoryManager.createKnowledgeRepository(mcorpus.getName(), conf); |
|
38 |
KnowledgeRepositoryManager.registerKnowledgeRepository(kr); |
|
39 |
} |
|
40 |
|
|
24 | 41 |
@Field @Option(name="query", usage="The CQL query to select tokens to annotate", widget="String", required=true, def="") |
25 |
String query |
|
42 |
String query
|
|
26 | 43 |
|
27 | 44 |
@Field @Option(name="word_property", usage="The word_property to annotate", widget="String", required=true, def="type") |
28 |
String word_property |
|
45 |
String word_property
|
|
29 | 46 |
|
30 | 47 |
@Field @Option(name="value", usage="the annotation value", widget="String", required=true, def="value") |
31 |
String value |
|
48 |
String value
|
|
32 | 49 |
|
33 | 50 |
// Open the parameters input dialog box |
34 | 51 |
if (!ParametersDialog.open(this)) return |
35 | 52 |
|
36 |
if (query == null || query.trim().length() == 0) { |
|
37 |
println "Error: no query set." |
|
38 |
return 0 |
|
39 |
} |
|
53 |
if (query == null || query.trim().length() == 0) {
|
|
54 |
println "Error: no query set."
|
|
55 |
return 0
|
|
56 |
}
|
|
40 | 57 |
|
41 | 58 |
annotManager = KRAnnotationEngine.getAnnotationManager(corpus); |
42 | 59 |
|
Formats disponibles : Unified diff