Révision 2151
tmp/org.txm.analec.rcp/src/org/txm/macro/urs/DemoMacro.groovy (revision 2151) | ||
---|---|---|
25 | 25 |
|
26 | 26 |
// display annotations per Element type (Unite, Relation, Schema) and per type |
27 | 27 |
|
28 |
// Create annotation type |
|
29 |
|
|
30 |
structure.ajouterType(Unite.class, "EXEMPLE"); |
|
31 |
//structure.ajouterType(Relation.class, "EXEMPLE"); |
|
32 |
//structure.ajouterType(Schema.class, "EXEMPLE"); |
|
33 |
println structure.getTypes(Unite.class) |
|
34 |
|
|
35 |
// Create annotation property |
|
36 |
|
|
37 |
structure.ajouterProp(Unite.class, "EXEMPLE", "PEXEMPLE") |
|
38 |
println structure.getNomsProps(Unite.class, "EXEMPLE") |
|
39 |
|
|
40 |
// Create annotation value |
|
41 |
|
|
42 |
structure.ajouterVal(Unite.class, "EXEMPLE", "PEXEMPLE", "oui") |
|
43 |
structure.ajouterVal(Unite.class, "EXEMPLE", "PEXEMPLE", "non") |
|
44 |
|
|
45 |
// Create annotations |
|
46 |
|
|
47 |
def props = [:] |
|
48 |
props["PEXEMPLE"] = "oui" |
|
49 |
def u = analecCorpus.addUniteSaisie("EXEMPLE", 0, 10, props) |
|
50 |
println u |
|
51 |
|
|
52 |
// Edit annotations |
|
53 |
|
|
54 |
u.getProps()["EXEMPLE"] = "non" |
|
55 |
|
|
56 |
// Unit getters |
|
57 |
|
|
58 |
println u.getDeb() // start of unit |
|
59 |
println u.getFin() // end of unit |
|
60 |
|
|
61 |
println u.getProp("EXEMPLE") |
|
62 |
println u.getType() |
|
63 |
|
|
64 |
// Browse Units |
|
65 |
|
|
66 |
println "Units:" |
|
67 |
for (String type : structure.getUnites()) { |
|
68 |
def units = analecCorpus.getUnites(type) |
|
69 |
if (units.size() > 0) { |
|
70 |
println " ${units.size()} $type" |
|
71 |
} |
|
72 |
} |
|
73 |
|
|
74 |
// Browse Relations |
|
75 |
|
|
76 |
println "Relations:" |
|
77 |
for (String type : structure.getRelations()) { |
|
78 |
def relations = analecCorpus.getRelations(type) |
|
79 |
if (relations.size() > 0) { |
|
80 |
println " ${relations.size()} $type" |
|
81 |
} |
|
82 |
} |
|
83 |
|
|
84 |
// Browse Schemas |
|
85 |
|
|
86 |
println "Schemas:" |
|
87 |
for (String type : structure.getSchemas()) { |
|
88 |
def schemas = analecCorpus.getSchemas(type) |
|
89 |
if (schemas.size() > 0) { |
|
90 |
println " ${schemas.size()} $type" |
|
91 |
} |
|
92 |
} |
|
93 |
|
|
94 |
// Delete annotations |
|
95 |
|
|
96 |
analecCorpus.supUnite(u) |
|
97 |
//analecCorpus.supRelation(rel) |
|
98 |
//analecCorpus.supSchema(sch) |
|
99 |
|
|
100 |
// Delete annotation value |
|
101 |
|
|
102 |
structure.supprimerVal(Unite.class, "EXEMPLE", "PEXEMPLE", "oui") |
|
103 |
structure.supprimerVal(Unite.class, "EXEMPLE", "PEXEMPLE", "non") |
|
104 |
|
|
105 |
// Delete annotation property |
|
106 |
|
|
107 |
structure.supprimerProp(Unite.class, "EXEMPLE", "PEXEMPLE") |
|
108 |
|
|
109 |
// Delete annotation type |
|
110 |
|
|
111 |
structure.supprimerType(Unite.class, "EXEMPLE"); |
|
112 |
//structure.supprimerType(Relation.class, "EXEMPLE"); |
|
113 |
//structure.supprimerType(Schema.class, "EXEMPLE"); |
|
114 |
|
|
115 |
// Revert changes |
|
116 |
|
|
117 |
//URSCorpora.revert(corpus); |
|
118 |
|
|
119 |
// Save changes |
|
120 |
|
|
121 |
//URSCorpora.saveCorpus(corpus) |
|
122 |
|
|
123 |
|
|
28 |
// Create annotation type |
|
29 |
|
|
30 |
structure.ajouterType(Unite.class, "EXEMPLE"); |
|
31 |
//structure.ajouterType(Relation.class, "EXEMPLE"); |
|
32 |
//structure.ajouterType(Schema.class, "EXEMPLE"); |
|
33 |
println structure.getTypes(Unite.class) |
|
34 |
|
|
35 |
// Create annotation property |
|
36 |
|
|
37 |
structure.ajouterProp(Unite.class, "EXEMPLE", "PEXEMPLE") |
|
38 |
println structure.getNomsProps(Unite.class, "EXEMPLE") |
|
39 |
|
|
40 |
// Create annotation value |
|
41 |
|
|
42 |
structure.ajouterVal(Unite.class, "EXEMPLE", "PEXEMPLE", "oui") |
|
43 |
structure.ajouterVal(Unite.class, "EXEMPLE", "PEXEMPLE", "non") |
|
44 |
|
|
45 |
// Create annotations |
|
46 |
|
|
47 |
// Unite |
|
48 |
def u = analecCorpus.addUniteSaisie("EXEMPLE", 0, 10, ["PEXEMPLE":"oui"]) |
|
49 |
def u2 = analecCorpus.addUniteSaisie("EXEMPLE", 12, 12, ["PEXEMPLE":"oui"]) |
|
50 |
println u |
|
51 |
|
|
52 |
// Edit annotations |
|
53 |
|
|
54 |
u.getProps()["PEXEMPLE"] = "non" |
|
55 |
|
|
56 |
// Unit getters |
|
57 |
|
|
58 |
println u.getDeb() // start of unit |
|
59 |
println u.getFin() // end of unit |
|
60 |
|
|
61 |
println u.getProp("EXEMPLE") |
|
62 |
println u.getType() |
|
63 |
|
|
64 |
// Relation |
|
65 |
Relation relation = new Relation("REXEMPLE", u, u2) |
|
66 |
relation.getProps().put("PEXEMPLE", "oui") |
|
67 |
analecCorpus.addRelationLue(relation) // add the new relation |
|
68 |
|
|
69 |
// Schema |
|
70 |
Schema schema = new Schema() |
|
71 |
schema.type = "SEXEMPLE" |
|
72 |
schema.props.put("PEXEMPLE", "oui") |
|
73 |
schema.ajouter(u) // insert one unit |
|
74 |
|
|
75 |
analecCorpus.addSchemaLu(schema) // add the new schema |
|
76 |
|
|
77 |
// Browse Units |
|
78 |
|
|
79 |
println "Units:" |
|
80 |
for (String type : structure.getUnites()) { |
|
81 |
def units = analecCorpus.getUnites(type) |
|
82 |
if (units.size() > 0) { |
|
83 |
println " ${units.size()} $type" |
|
84 |
} |
|
85 |
} |
|
86 |
|
|
87 |
// Browse Relations |
|
88 |
|
|
89 |
println "Relations:" |
|
90 |
for (String type : structure.getRelations()) { |
|
91 |
def relations = analecCorpus.getRelations(type) |
|
92 |
if (relations.size() > 0) { |
|
93 |
println " ${relations.size()} $type" |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
// Browse Schemas |
|
98 |
|
|
99 |
println "Schemas:" |
|
100 |
for (String type : structure.getSchemas()) { |
|
101 |
def schemas = analecCorpus.getSchemas(type) |
|
102 |
if (schemas.size() > 0) { |
|
103 |
println " ${schemas.size()} $type" |
|
104 |
} |
|
105 |
} |
|
106 |
|
|
107 |
// URS selections |
|
108 |
|
|
109 |
// select Schemas |
|
110 |
def debug = 0 // 1 2 for more logs |
|
111 |
def strict_inclusion = true |
|
112 |
def position = 0 |
|
113 |
def minimum_schema_size = 1; |
|
114 |
def maximum_schema_size = 10; |
|
115 |
def schema_ursql = "SEXEMPLE" |
|
116 |
def unit_ursql = "EXEMPLE@PEXEMPLE=oui" |
|
117 |
println AnalecUtils.selectSchemasInCorpus(debug, analecCorpus, corpus, schema_ursql, minimum_schema_size, maximum_schema_size, strict_inclusion) |
|
118 |
|
|
119 |
|
|
120 |
// with URSQL |
|
121 |
println AnalecUtils.filterElements(debug, analecCorpus.getUnites("EXEMPLE"), unit_ursql) |
|
122 |
|
|
123 |
// with intersection with CQP corpus matches |
|
124 |
AnalecUtils.filterUniteByInclusion(debug, analecCorpus.getUnites("EXEMPLE"), corpus.getMatches(), strict_inclusion, position) |
|
125 |
|
|
126 |
// by size |
|
127 |
AnalecUtils.filterBySize(analecCorpus.getSchemas("SEXEMPLE"), minimum_schema_size, maximum_schema_size) |
|
128 |
|
|
129 |
// Delete annotations |
|
130 |
|
|
131 |
analecCorpus.supUnite(u) |
|
132 |
//analecCorpus.supRelation(rel) |
|
133 |
//analecCorpus.supSchema(sch) |
|
134 |
|
|
135 |
// Delete annotation value |
|
136 |
|
|
137 |
structure.supprimerVal(Unite.class, "EXEMPLE", "PEXEMPLE", "oui") |
|
138 |
structure.supprimerVal(Unite.class, "EXEMPLE", "PEXEMPLE", "non") |
|
139 |
|
|
140 |
// Delete annotation property |
|
141 |
|
|
142 |
structure.supprimerProp(Unite.class, "EXEMPLE", "PEXEMPLE") |
|
143 |
|
|
144 |
// Delete annotation type |
|
145 |
|
|
146 |
structure.supprimerType(Unite.class, "EXEMPLE"); |
|
147 |
//structure.supprimerType(Relation.class, "EXEMPLE"); |
|
148 |
//structure.supprimerType(Schema.class, "EXEMPLE"); |
|
149 |
|
|
150 |
// Revert changes |
|
151 |
|
|
152 |
//URSCorpora.revert(corpus); |
|
153 |
|
|
154 |
// Save changes |
|
155 |
|
|
156 |
//URSCorpora.saveCorpus(corpus) |
|
157 |
|
Formats disponibles : Unified diff