Révision 2794
| tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/actions/DefineSortReferencePattern.java (revision 2794) | ||
|---|---|---|
| 61 | 61 |
|
| 62 | 62 |
/** The Constant ID. */ |
| 63 | 63 |
private static final String ID = "org.txm.rcp.editors.concordances.definereferencepattern"; //$NON-NLS-1$ |
| 64 |
|
|
| 64 |
|
|
| 65 | 65 |
/** The window. */ |
| 66 | 66 |
private IWorkbenchWindow window; |
| 67 |
|
|
| 67 |
|
|
| 68 | 68 |
/** The concordance editor. */ |
| 69 | 69 |
private ConcordanceEditor concordanceEditor; |
| 70 |
|
|
| 70 |
|
|
| 71 | 71 |
/** |
| 72 | 72 |
* Instantiates a new define reference pattern. |
| 73 | 73 |
* |
| ... | ... | |
| 98 | 98 |
List<StructuralUnit> structuralUnits = null; |
| 99 | 99 |
List<Property> availableReferenceItems = new ArrayList<Property>(); |
| 100 | 100 |
try {
|
| 101 |
structuralUnits = concordanceEditor.getCorpus() |
|
| 102 |
.getOrderedStructuralUnits(); |
|
| 103 |
availableReferenceItems.addAll(concordanceEditor.getCorpus() |
|
| 104 |
.getOrderedProperties()); |
|
| 105 |
|
|
| 106 |
|
|
| 101 |
structuralUnits = concordanceEditor.getCorpus().getOrderedStructuralUnits(); |
|
| 102 |
availableReferenceItems.addAll(concordanceEditor.getCorpus().getOrderedProperties()); |
|
| 107 | 103 |
} catch (Exception e) {
|
| 108 | 104 |
org.txm.utils.logger.Log.printStackTrace(e); |
| 109 | 105 |
} |
| 110 | 106 |
|
| 111 | 107 |
for (StructuralUnit unit : structuralUnits) {
|
| 112 |
availableReferenceItems.addAll(unit.getProperties()); |
|
| 108 |
availableReferenceItems.addAll(unit.getOrderedProperties());
|
|
| 113 | 109 |
} |
| 114 | 110 |
|
| 115 | 111 |
// System.out.println("selected "+concordanceEditor.getSelectedReferences());
|
| 116 | 112 |
// System.out.println("before avail"+availableReferenceItems);
|
| 117 |
availableReferenceItems.remove(concordanceEditor |
|
| 118 |
.getSelectedSortReferences()); |
|
| 113 |
availableReferenceItems.remove(concordanceEditor.getSelectedSortReferences()); |
|
| 119 | 114 |
|
| 120 |
// System.out.println("after avail"+availableReferenceItems);
|
|
| 115 |
// System.out.println("after avail"+availableReferenceItems);
|
|
| 121 | 116 |
DefineReferencePatternDialog d = null; |
| 122 |
d = new DefineReferencePatternDialog(window.getShell(),
|
|
| 123 |
availableReferenceItems, concordanceEditor
|
|
| 124 |
.getSelectedSortReferences());
|
|
| 117 |
d = new DefineReferencePatternDialog(window.getShell(), |
|
| 118 |
availableReferenceItems, concordanceEditor |
|
| 119 |
.getSelectedSortReferences()); |
|
| 125 | 120 |
|
| 126 | 121 |
if (d.open() == Window.OK) {
|
| 127 |
concordanceEditor.setRefSortPattern(new ReferencePattern(d
|
|
| 128 |
.getSelectesdReferenceItems()));
|
|
| 122 |
concordanceEditor.setRefSortPattern(new ReferencePattern(d |
|
| 123 |
.getSelectesdReferenceItems())); |
|
| 129 | 124 |
//System.out.println(concordanceEditor.getSortReferencePattern()); |
| 130 | 125 |
} |
| 131 | 126 |
} |
| ... | ... | |
| 137 | 132 |
|
| 138 | 133 |
/** The available reference items. */ |
| 139 | 134 |
private List<Property> availableReferenceItems; |
| 140 |
|
|
| 135 |
|
|
| 141 | 136 |
/** The selected reference items. */ |
| 142 | 137 |
private List<Property> selectedReferenceItems; |
| 143 | 138 |
|
| ... | ... | |
| 152 | 147 |
List<Property> availableReferenceItems, |
| 153 | 148 |
List<Property> selectedReferences) {
|
| 154 | 149 |
super(parentShell); |
| 155 |
|
|
| 150 |
|
|
| 156 | 151 |
this.availableReferenceItems = availableReferenceItems; |
| 157 | 152 |
this.selectedReferenceItems = selectedReferences; |
| 158 | 153 |
this.availableReferenceItems.removeAll(selectedReferences); |
| ... | ... | |
| 173 | 168 |
*/ |
| 174 | 169 |
@Override |
| 175 | 170 |
protected void configureShell(Shell shell) {
|
| 176 |
super.configureShell(shell);
|
|
| 177 |
shell.setText(TXMUIMessages.referencesSortOptions);
|
|
| 178 |
|
|
| 179 |
shell.setSize(400, 500);
|
|
| 180 |
shell.setLocation(shell.getParent().getLocation());
|
|
| 181 |
}
|
|
| 182 |
|
|
| 171 |
super.configureShell(shell);
|
|
| 172 |
shell.setText(TXMUIMessages.referencesSortOptions);
|
|
| 173 |
|
|
| 174 |
shell.setSize(400, 500);
|
|
| 175 |
shell.setLocation(shell.getParent().getLocation());
|
|
| 176 |
} |
|
| 177 |
|
|
| 183 | 178 |
/* (non-Javadoc) |
| 184 | 179 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
| 185 | 180 |
*/ |
| ... | ... | |
| 202 | 197 |
availbleItems.add(property.getName()); |
| 203 | 198 |
} |
| 204 | 199 |
} |
| 205 |
|
|
| 200 |
|
|
| 206 | 201 |
GridData gridData = new GridData(GridData.FILL, GridData.FILL, |
| 207 | 202 |
true, true); |
| 208 | 203 |
//Point size = availbleItems.computeSize(SWT.DEFAULT, SWT.DEFAULT); |
| ... | ... | |
| 226 | 221 |
selectedItems.add(property.getName()); |
| 227 | 222 |
} |
| 228 | 223 |
} |
| 229 |
|
|
| 224 |
|
|
| 230 | 225 |
//DBL CLICK Listeners |
| 231 | 226 |
selectedItems.addMouseListener(new MouseListener() {
|
| 232 | 227 |
@Override |
| 233 | 228 |
public void mouseUp(MouseEvent e) { }
|
| 234 |
|
|
| 229 |
|
|
| 235 | 230 |
@Override |
| 236 | 231 |
public void mouseDown(MouseEvent e) { }
|
| 237 |
|
|
| 232 |
|
|
| 238 | 233 |
@Override |
| 239 | 234 |
public void mouseDoubleClick(MouseEvent e) {
|
| 240 | 235 |
int ind = selectedItems.getSelectionIndex(); |
| 241 | 236 |
availbleItems.add(selectedItems.getItem(ind)); |
| 242 | 237 |
selectedItems.remove(ind); |
| 243 | 238 |
availableReferenceItems |
| 244 |
.add(selectedReferenceItems.get(ind));
|
|
| 239 |
.add(selectedReferenceItems.get(ind)); |
|
| 245 | 240 |
selectedReferenceItems.remove(ind); |
| 246 | 241 |
selectedItems.setSelection(ind); |
| 247 | 242 |
} |
| ... | ... | |
| 249 | 244 |
availbleItems.addMouseListener(new MouseListener() {
|
| 250 | 245 |
@Override |
| 251 | 246 |
public void mouseUp(MouseEvent e) { }
|
| 252 |
|
|
| 247 |
|
|
| 253 | 248 |
@Override |
| 254 | 249 |
public void mouseDown(MouseEvent e) { }
|
| 255 |
|
|
| 250 |
|
|
| 256 | 251 |
@Override |
| 257 | 252 |
public void mouseDoubleClick(MouseEvent e) {
|
| 258 | 253 |
int ind = availbleItems.getSelectionIndex(); |
| 259 | 254 |
selectedItems.add(availbleItems.getItem(ind)); |
| 260 | 255 |
availbleItems.remove(ind); |
| 261 | 256 |
selectedReferenceItems |
| 262 |
.add(availableReferenceItems.get(ind));
|
|
| 257 |
.add(availableReferenceItems.get(ind)); |
|
| 263 | 258 |
availableReferenceItems.remove(ind); |
| 264 | 259 |
availbleItems.setSelection(ind); |
| 265 | 260 |
} |
| ... | ... | |
| 277 | 272 |
selectedItems.add(availbleItems.getItem(ind)); |
| 278 | 273 |
availbleItems.remove(ind); |
| 279 | 274 |
selectedReferenceItems |
| 280 |
.add(availableReferenceItems.get(ind));
|
|
| 275 |
.add(availableReferenceItems.get(ind)); |
|
| 281 | 276 |
availableReferenceItems.remove(ind); |
| 282 | 277 |
availbleItems.setSelection(ind); |
| 283 | 278 |
} |
| ... | ... | |
| 290 | 285 |
availbleItems.add(selectedItems.getItem(ind)); |
| 291 | 286 |
selectedItems.remove(ind); |
| 292 | 287 |
availableReferenceItems |
| 293 |
.add(selectedReferenceItems.get(ind));
|
|
| 288 |
.add(selectedReferenceItems.get(ind)); |
|
| 294 | 289 |
selectedReferenceItems.remove(ind); |
| 295 | 290 |
selectedItems.setSelection(ind); |
| 296 | 291 |
} |
| ... | ... | |
| 304 | 299 |
String value = selectedItems.getItem(ind); |
| 305 | 300 |
selectedItems.remove(ind); |
| 306 | 301 |
selectedItems.add(value, ind -1); |
| 307 |
|
|
| 302 |
|
|
| 308 | 303 |
Property prop = selectedReferenceItems.get(ind); |
| 309 | 304 |
selectedReferenceItems.remove(ind); |
| 310 | 305 |
selectedReferenceItems.add(ind-1,prop); |
| 311 |
|
|
| 306 |
|
|
| 312 | 307 |
selectedItems.setSelection(ind -1); |
| 313 | 308 |
} |
| 314 | 309 |
} |
| ... | ... | |
| 322 | 317 |
String value = selectedItems.getItem(ind); |
| 323 | 318 |
selectedItems.remove(ind); |
| 324 | 319 |
selectedItems.add(value, ind + 1); |
| 325 |
|
|
| 320 |
|
|
| 326 | 321 |
Property prop = selectedReferenceItems.get(ind); |
| 327 | 322 |
selectedReferenceItems.remove(ind); |
| 328 | 323 |
selectedReferenceItems.add(ind+1, prop); |
| 329 |
|
|
| 324 |
|
|
| 330 | 325 |
selectedItems.setSelection(ind + 1); |
| 331 | 326 |
} |
| 332 | 327 |
} |
| tmp/org.txm.internalview.rcp/src/org/txm/internalview/rcp/editors/InternalViewEditor.java (revision 2794) | ||
|---|---|---|
| 327 | 327 |
int[] n; |
| 328 | 328 |
try {
|
| 329 | 329 |
StructuralUnitProperty sup = null; |
| 330 |
for (StructuralUnitProperty s : internalView.getStructuralUnit().getProperties()) {
|
|
| 330 |
for (StructuralUnitProperty s : internalView.getStructuralUnit().getOrderedProperties()) {
|
|
| 331 | 331 |
sup = s; |
| 332 | 332 |
break; |
| 333 | 333 |
} |
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/StructuralUnit.java (revision 2794) | ||
|---|---|---|
| 99 | 99 |
} |
| 100 | 100 |
|
| 101 | 101 |
/** |
| 102 |
* Gets the properties defined on this type of structural unit. |
|
| 102 |
* Gets the actual properties defined on this type of structural unit.
|
|
| 103 | 103 |
* |
| 104 | 104 |
* @return the properties |
| 105 | 105 |
*/ |
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java (revision 2794) | ||
|---|---|---|
| 1184 | 1184 |
List<StructuralUnitProperty> properties = new ArrayList<>(); |
| 1185 | 1185 |
if (this.structuralUnits != null) |
| 1186 | 1186 |
for (StructuralUnit su : this.structuralUnits) |
| 1187 |
if (su.getProperties() != null) |
|
| 1187 |
if (su.getOrderedProperties() != null)
|
|
| 1188 | 1188 |
properties.addAll(su.getProperties()); |
| 1189 | 1189 |
|
| 1190 | 1190 |
return properties; |
| ... | ... | |
| 1202 | 1202 |
public List<StructuralUnitProperty> getStructuralUnitProperties(String name) throws CqiClientException {
|
| 1203 | 1203 |
StructuralUnit su = this.getStructuralUnit(name); |
| 1204 | 1204 |
|
| 1205 |
return su.getProperties(); |
|
| 1205 |
return su.getOrderedProperties();
|
|
| 1206 | 1206 |
} |
| 1207 | 1207 |
|
| 1208 | 1208 |
// /** |
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ReferencePattern.java (revision 2794) | ||
|---|---|---|
| 214 | 214 |
|
| 215 | 215 |
// add structural units properties |
| 216 | 216 |
for (StructuralUnit unit : corpus.getOrderedStructuralUnits()) {
|
| 217 |
availableReferenceItems.addAll(unit.getProperties()); |
|
| 217 |
availableReferenceItems.addAll(unit.getOrderedProperties());
|
|
| 218 | 218 |
} |
| 219 | 219 |
|
| 220 | 220 |
} catch (Exception e) {
|
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/core/functions/selection/Selection.java (revision 2794) | ||
|---|---|---|
| 158 | 158 |
|
| 159 | 159 |
// in case no metadatas are declared in import.xml |
| 160 | 160 |
if (allProperties.size() == 0) |
| 161 |
for (StructuralUnitProperty sup : text_su.getProperties()) |
|
| 161 |
for (StructuralUnitProperty sup : text_su.getOrderedProperties())
|
|
| 162 | 162 |
allProperties.add(sup); |
| 163 | 163 |
|
| 164 | 164 |
// get text ids (using starting position of texts) + text size using the positions |
| ... | ... | |
| 404 | 404 |
} |
| 405 | 405 |
|
| 406 | 406 |
if (displayPropertyNames.size() == 0) {
|
| 407 |
for (Property p : text_su.getProperties()) |
|
| 407 |
for (Property p : text_su.getOrderedProperties())
|
|
| 408 | 408 |
displayPropertyNames.add(p.getName()); |
| 409 | 409 |
} |
| 410 | 410 |
|
| tmp/org.txm.properties.core/src/org/txm/properties/core/functions/CorpusPropertiesComputer.java (revision 2794) | ||
|---|---|---|
| 29 | 29 |
import org.txm.utils.logger.Log; |
| 30 | 30 |
|
| 31 | 31 |
public class CorpusPropertiesComputer extends PropertiesComputer<CQPCorpus> {
|
| 32 |
|
|
| 32 |
|
|
| 33 | 33 |
public CorpusPropertiesComputer(Properties props, CQPCorpus result) {
|
| 34 | 34 |
super(props, result); |
| 35 | 35 |
} |
| 36 |
|
|
| 36 |
|
|
| 37 | 37 |
@Override |
| 38 | 38 |
public List<String> getComputableInformations() {
|
| 39 | 39 |
return Arrays.asList("all");
|
| 40 | 40 |
} |
| 41 |
|
|
| 41 |
|
|
| 42 | 42 |
@Override |
| 43 | 43 |
public LinkedHashMap<String, String> getInformation(String name) {
|
| 44 | 44 |
LinkedHashMap<String, String> data = new LinkedHashMap<>(); |
| 45 | 45 |
data.put("all", dump(props.pMaxPropertiesToDisplay));
|
| 46 | 46 |
return data; |
| 47 | 47 |
} |
| 48 |
|
|
| 48 |
|
|
| 49 | 49 |
@Override |
| 50 | 50 |
public String getInformationHTML(String info) {
|
| 51 | 51 |
return htmlDump(); |
| 52 | 52 |
} |
| 53 |
|
|
| 53 |
|
|
| 54 | 54 |
// Numbers |
| 55 | 55 |
/** The T. */ |
| 56 | 56 |
int numberOfWords = 0; // number of word |
| 57 |
|
|
| 57 |
|
|
| 58 | 58 |
/** The N properties. */ |
| 59 | 59 |
int NProperties = 0; // number of word properties |
| 60 | 60 |
// HashMap<String, Integer> propertiesCounts = new HashMap<String, Integer>(); |
| 61 | 61 |
// // properties counts |
| 62 |
|
|
| 62 |
|
|
| 63 | 63 |
/** The properties values. */ |
| 64 | 64 |
HashMap<String, List<String>> propertiesValues = new HashMap<>(); // properties values |
| 65 |
|
|
| 65 |
|
|
| 66 | 66 |
/** The N structures. */ |
| 67 | 67 |
int NStructures = 0; // number of structures |
| 68 |
|
|
| 68 |
|
|
| 69 | 69 |
/** The structures counts. */ |
| 70 | 70 |
HashMap<String, Integer> structuresCounts = new HashMap<>(); // structures counts |
| 71 |
|
|
| 71 |
|
|
| 72 | 72 |
/** The internal architecture. */ |
| 73 | 73 |
List<String> internalArchitecture = new ArrayList<>(); // cqp structures = propertiesCounts keys but ordered |
| 74 |
|
|
| 74 |
|
|
| 75 | 75 |
/** The hierarchie counts. */ |
| 76 | 76 |
HashMap<String, Integer> hierarchieCounts = new HashMap<>(); // hierarchic structures counts |
| 77 |
|
|
| 77 |
|
|
| 78 | 78 |
/** The internal architecture properties. */ |
| 79 | 79 |
HashMap<String, HashMap<String, List<String>>> internalArchitectureProperties = new HashMap<>(); // hierarchic structures counts |
| 80 |
|
|
| 80 |
|
|
| 81 | 81 |
/** The internal architecture properties counts. */ |
| 82 | 82 |
HashMap<String, HashMap<String, Integer>> internalArchitecturePropertiesCounts = new HashMap<>(); // hierarchic structures counts |
| 83 |
|
|
| 83 |
|
|
| 84 | 84 |
// Annotations description |
| 85 | 85 |
/** The annotations types. */ |
| 86 | 86 |
HashMap<String, Integer> annotationsTypes = new HashMap<>(); // for each annotation its description |
| 87 |
|
|
| 87 |
|
|
| 88 | 88 |
/** The annotations origins. */ |
| 89 | 89 |
HashMap<String, Integer> annotationsOrigins = new HashMap<>(); // for each annoation its origin description |
| 90 |
|
|
| 90 |
|
|
| 91 | 91 |
/** The properties. */ |
| 92 | 92 |
List<WordProperty> properties; |
| 93 |
|
|
| 93 |
|
|
| 94 | 94 |
/** The structures. */ |
| 95 | 95 |
List<StructuralUnit> structures; |
| 96 |
|
|
| 96 |
|
|
| 97 | 97 |
@Override |
| 98 | 98 |
public String getName() {
|
| 99 | 99 |
String filename = result.getMainCorpus() + "-" + result.getName(); //$NON-NLS-1$ |
| ... | ... | |
| 102 | 102 |
} |
| 103 | 103 |
return filename; |
| 104 | 104 |
} |
| 105 |
|
|
| 105 |
|
|
| 106 | 106 |
/** |
| 107 | 107 |
* Step general infos. |
| 108 | 108 |
*/ |
| ... | ... | |
| 123 | 123 |
Log.printStackTrace(e); |
| 124 | 124 |
return; |
| 125 | 125 |
} |
| 126 |
|
|
| 126 |
|
|
| 127 | 127 |
try {
|
| 128 | 128 |
numberOfWords = result.getSize();// corpus.getLexicon(corpus.getProperty("id")).nbrOfToken();
|
| 129 | 129 |
} |
| ... | ... | |
| 133 | 133 |
return; |
| 134 | 134 |
} |
| 135 | 135 |
} |
| 136 |
|
|
| 136 |
|
|
| 137 | 137 |
/** |
| 138 | 138 |
* step2. randomly position are choose |
| 139 | 139 |
*/ |
| 140 | 140 |
public void stepLexicalProperties() {
|
| 141 | 141 |
propertiesValues.clear(); |
| 142 |
|
|
| 142 |
|
|
| 143 | 143 |
AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient(); |
| 144 |
|
|
| 144 |
|
|
| 145 | 145 |
int s = Math.min(props.pMaxPropertiesToDisplay, numberOfWords); |
| 146 | 146 |
int[] positions = new int[s]; |
| 147 | 147 |
int n = 0; |
| ... | ... | |
| 153 | 153 |
positions[n++] = i; |
| 154 | 154 |
} |
| 155 | 155 |
} |
| 156 |
|
|
| 156 |
|
|
| 157 | 157 |
for (Property p : properties) {
|
| 158 | 158 |
// int size; |
| 159 | 159 |
try {
|
| ... | ... | |
| 165 | 165 |
} |
| 166 | 166 |
} |
| 167 | 167 |
} |
| 168 |
|
|
| 168 |
|
|
| 169 | 169 |
/** |
| 170 | 170 |
* Step structural units. |
| 171 | 171 |
*/ |
| 172 | 172 |
public void stepStructuralUnits() {
|
| 173 | 173 |
try {
|
| 174 | 174 |
structures = result.getOrderedStructuralUnits(); |
| 175 |
|
|
| 175 |
|
|
| 176 | 176 |
List<StructuralUnit> sstructures = new ArrayList<>(structures); |
| 177 | 177 |
for (StructuralUnit su : structures) {
|
| 178 | 178 |
if (su.getName().equals("txmcorpus")) {
|
| ... | ... | |
| 193 | 193 |
hierarchieCounts.put(su.getName(), -1); |
| 194 | 194 |
internalArchitectureProperties.put(su.getName(), new HashMap<String, List<String>>()); |
| 195 | 195 |
internalArchitecturePropertiesCounts.put(su.getName(), new HashMap<String, Integer>()); |
| 196 |
|
|
| 197 |
if (su.getProperties().size() > 0) {
|
|
| 198 |
for (StructuralUnitProperty sup : su.getProperties()) {// for each of its property
|
|
| 199 |
try {
|
|
| 200 |
List<String> allvalues = sup.getValues(result); |
|
| 201 |
internalArchitectureProperties.get(su.getName()).put(sup.getName(), allvalues.subList(0, Math.min(allvalues.size(), props.pMaxPropertiesToDisplay))); |
|
| 202 |
internalArchitecturePropertiesCounts.get(su.getName()).put(sup.getName(), allvalues.size()); |
|
| 203 |
} |
|
| 204 |
catch (Exception e) {
|
|
| 205 |
ArrayList<String> list = new ArrayList<>(1); |
|
| 206 |
list.add(PropertiesCoreMessages.error); |
|
| 207 |
internalArchitectureProperties.get(su.getName()).put(sup.getName(), list); |
|
| 208 |
internalArchitecturePropertiesCounts.get(su.getName()).put(sup.getName(), -1); |
|
| 209 |
} |
|
| 196 |
|
|
| 197 |
for (StructuralUnitProperty sup : su.getOrderedProperties()) {// for each of its property
|
|
| 198 |
try {
|
|
| 199 |
List<String> allvalues = sup.getValues(result); |
|
| 200 |
internalArchitectureProperties.get(su.getName()).put(sup.getName(), allvalues.subList(0, Math.min(allvalues.size(), props.pMaxPropertiesToDisplay))); |
|
| 201 |
internalArchitecturePropertiesCounts.get(su.getName()).put(sup.getName(), allvalues.size()); |
|
| 210 | 202 |
} |
| 203 |
catch (Exception e) {
|
|
| 204 |
ArrayList<String> list = new ArrayList<>(1); |
|
| 205 |
list.add(PropertiesCoreMessages.error); |
|
| 206 |
internalArchitectureProperties.get(su.getName()).put(sup.getName(), list); |
|
| 207 |
internalArchitecturePropertiesCounts.get(su.getName()).put(sup.getName(), -1); |
|
| 208 |
} |
|
| 211 | 209 |
} |
| 212 | 210 |
} |
| 213 | 211 |
} |
| 214 |
|
|
| 212 |
|
|
| 215 | 213 |
/** |
| 216 | 214 |
* dump the results of the diagnostic in a String containing HTML code. |
| 217 | 215 |
* |
| ... | ... | |
| 219 | 217 |
*/ |
| 220 | 218 |
public String htmlDump() {
|
| 221 | 219 |
StringBuffer buff = new StringBuffer(); |
| 222 |
|
|
| 220 |
|
|
| 223 | 221 |
buff.append("<? version=\"1.0\" encoding=\"UTF-8\"?>\n" + //$NON-NLS-1$
|
| 224 | 222 |
"<html>" + //$NON-NLS-1$ |
| 225 | 223 |
"<head>" + //$NON-NLS-1$ |
| ... | ... | |
| 227 | 225 |
"</head>" + //$NON-NLS-1$ |
| 228 | 226 |
"<body>\n"); //$NON-NLS-1$ |
| 229 | 227 |
buff.append("<h2 style'font-family:\"Arial\";'>" + PropertiesCoreMessages.descriptionOf + this.result.getName() + " (CQP ID=" + this.result.getID() + ")</h2>\n"); //$NON-NLS-2$ //$NON-NLS-1$
|
| 230 |
|
|
| 228 |
|
|
| 231 | 229 |
Project projet = this.result.getProject(); |
| 232 | 230 |
// if (projet.getCreationDate() != null) {
|
| 233 | 231 |
// buff.append(NLS.bind(PropertiesCoreMessages.createdTheP0, TXMResult.PRETTY_LOCALIZED_TIME_FORMAT.format(projet.getCreationDate()))); |
| ... | ... | |
| 239 | 237 |
if (projet.getDescription() != null && projet.getDescription().length() > 0) {
|
| 240 | 238 |
buff.append("<p><h3>Description</h3>" + projet.getDescription() + "</p>"); //$NON-NLS-1$ //$NON-NLS-2$
|
| 241 | 239 |
} |
| 242 |
|
|
| 240 |
|
|
| 243 | 241 |
buff.append("<h3 style'font-family:\"Arial\";'>" + PropertiesCoreMessages.generalStatistics_2 + "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
| 244 |
|
|
| 242 |
|
|
| 245 | 243 |
// counts |
| 246 | 244 |
buff.append("<ul>\n"); //$NON-NLS-1$
|
| 247 | 245 |
buff.append("<li>" + NLS.bind(PropertiesCoreMessages.numberOfWordsP0, NumberFormat.getInstance().format(numberOfWords)) + "</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
| 248 |
|
|
| 246 |
|
|
| 249 | 247 |
buff.append("<li>" + PropertiesCoreMessages.numberOfWordProperties + (properties.size()) + " (" + StringUtils.join(properties, ", ") + ")</li>\n"); //$NON-NLS-2$ //$NON-NLS-1$
|
| 250 | 248 |
buff.append("<li>" + PropertiesCoreMessages.numberOfStructuralUnits + (structures.size()) + " (" + StringUtils.join(structures, ", ") + ")</li>\n"); //$NON-NLS-2$ //$NON-NLS-1$
|
| 251 | 249 |
buff.append("</ul>\n"); //$NON-NLS-1$
|
| 252 |
|
|
| 250 |
|
|
| 253 | 251 |
// Propriétés d'occurrences |
| 254 | 252 |
buff.append("<h3 style'font-family:\"Arial\";'>" + NLS.bind(PropertiesCoreMessages.lexicalUnitsPropertiesMaxP0Values, props.pMaxPropertiesToDisplay) + "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
| 255 | 253 |
ArrayList<String> properties = new ArrayList<>(propertiesValues.keySet()); |
| ... | ... | |
| 269 | 267 |
} |
| 270 | 268 |
} |
| 271 | 269 |
buff.append("</ul>\n"); //$NON-NLS-1$
|
| 272 |
|
|
| 270 |
|
|
| 273 | 271 |
// Propriété de structures |
| 274 | 272 |
buff.append("<h3 style'font-family:\"Arial\";'>" + NLS.bind(PropertiesCoreMessages.structuralUnitsPropertiesMaxP0Values, props.pMaxPropertiesToDisplay) + "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
| 275 | 273 |
buff.append("<ul>\n"); //$NON-NLS-1$
|
| ... | ... | |
| 277 | 275 |
StringBuffer subbuffer = new StringBuffer(); |
| 278 | 276 |
if (s.equals("txmcorpus")) //$NON-NLS-1$
|
| 279 | 277 |
continue;// ignore the txmcorpus structure |
| 280 |
|
|
| 278 |
|
|
| 281 | 279 |
properties = new ArrayList<>(internalArchitectureProperties.get(s).keySet()); |
| 282 |
|
|
| 280 |
|
|
| 283 | 281 |
subbuffer.append("<li> " + s + "\n<ul>\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
| 284 | 282 |
if (internalArchitectureProperties.get(s).keySet().size() == 0) |
| 285 | 283 |
subbuffer.append("<li>" + PropertiesCoreMessages.noProperty + "</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
| 286 |
|
|
| 284 |
|
|
| 287 | 285 |
// System.out.println("struct: "+s+" >> "+properties);
|
| 288 | 286 |
Collections.sort(properties); |
| 289 | 287 |
// System.out.println("struct: "+s+" >sort> "+properties);
|
| ... | ... | |
| 304 | 302 |
subbuffer.append(psv.replace("<", "<")); //$NON-NLS-1$ //$NON-NLS-2$
|
| 305 | 303 |
else |
| 306 | 304 |
subbuffer.append("\"\""); //$NON-NLS-1$
|
| 307 |
|
|
| 305 |
|
|
| 308 | 306 |
if (i == values.size() - 1) |
| 309 | 307 |
subbuffer.append("."); //$NON-NLS-1$
|
| 310 | 308 |
else |
| 311 | 309 |
subbuffer.append(", "); //$NON-NLS-1$
|
| 312 |
|
|
| 310 |
|
|
| 313 | 311 |
if (i >= props.pMaxPropertiesToDisplay) {
|
| 314 | 312 |
subbuffer.append("..."); //$NON-NLS-1$
|
| 315 | 313 |
break; |
| ... | ... | |
| 318 | 316 |
subbuffer.append("</li>\n"); //$NON-NLS-1$
|
| 319 | 317 |
} |
| 320 | 318 |
} |
| 321 |
|
|
| 319 |
|
|
| 322 | 320 |
if (properties.size() == 0) {
|
| 323 | 321 |
subbuffer.append("<p>--</p>\n"); //$NON-NLS-1$
|
| 324 | 322 |
} |
| 325 |
|
|
| 323 |
|
|
| 326 | 324 |
subbuffer.append("</ul>\n</li>\n"); //$NON-NLS-1$
|
| 327 | 325 |
if (nbOfValues > 0) {
|
| 328 | 326 |
buff.append(subbuffer); |
| ... | ... | |
| 331 | 329 |
buff.append("</ul>\n"); //$NON-NLS-1$
|
| 332 | 330 |
buff.append("</body>\n"); //$NON-NLS-1$
|
| 333 | 331 |
buff.append("</html>\n"); //$NON-NLS-1$
|
| 334 |
|
|
| 332 |
|
|
| 335 | 333 |
return buff.toString(); |
| 336 | 334 |
} |
| 337 |
|
|
| 335 |
|
|
| 338 | 336 |
/** |
| 339 | 337 |
* dump the result in the console. |
| 340 | 338 |
* |
| ... | ... | |
| 344 | 342 |
*/ |
| 345 | 343 |
public String dump(int maxvalue) {
|
| 346 | 344 |
StringBuffer buff = new StringBuffer(); |
| 347 |
|
|
| 345 |
|
|
| 348 | 346 |
buff.append(PropertiesCoreMessages.generalStatistics); |
| 349 | 347 |
buff.append(PropertiesCoreMessages.t + String.format(Locale.FRANCE, "%,d", numberOfWords) + "\n"); //$NON-NLS-1$ |
| 350 | 348 |
buff.append(PropertiesCoreMessages.wordProperties + String.format("%,d", NProperties) + "\n"); //$NON-NLS-1$
|
| ... | ... | |
| 356 | 354 |
buff.append(PropertiesCoreMessages.s + String.format("%,d", NStructures) + "\n"); //$NON-NLS-1$
|
| 357 | 355 |
for (String s : structuresCounts.keySet()) |
| 358 | 356 |
buff.append(" - " + s + "\n");// +structuresCounts.get(s)+"\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
| 359 |
|
|
| 357 |
|
|
| 360 | 358 |
/* |
| 361 | 359 |
* buff.append("* Structural Units counts\n"); for(String s :
|
| 362 | 360 |
* internalArchitecture) buff.append(" - "+s+" "+hierarchieCounts.get(s)+"\n");
|
| ... | ... | |
| 368 | 366 |
if (!(s.equals("text") && (ps.equals("project") || ps.equals("base") || ps.equals("id")))) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
| 369 | 367 |
{
|
| 370 | 368 |
buff.append(" - " + ps + "(" + internalArchitectureProperties.get(s).get(ps).size() + ") = "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
| 371 |
|
|
| 369 |
|
|
| 372 | 370 |
int valuecount = 0; |
| 373 | 371 |
for (String psv : internalArchitectureProperties.get(s).get(ps)) {
|
| 374 | 372 |
buff.append(psv); |
| ... | ... | |
| 379 | 377 |
if (valuecount < internalArchitectureProperties.get(s).get(ps).size()) |
| 380 | 378 |
buff.append(", "); //$NON-NLS-1$
|
| 381 | 379 |
} |
| 382 |
|
|
| 380 |
|
|
| 383 | 381 |
buff.append("\n"); //$NON-NLS-1$
|
| 384 | 382 |
} |
| 385 | 383 |
} |
| 386 | 384 |
} |
| 387 |
|
|
| 385 |
|
|
| 388 | 386 |
return buff.toString(); |
| 389 | 387 |
} |
| 390 |
|
|
| 391 |
|
|
| 388 |
|
|
| 389 |
|
|
| 392 | 390 |
/** |
| 393 | 391 |
* Gets the t. |
| 394 | 392 |
* |
| ... | ... | |
| 397 | 395 |
public int getT() {
|
| 398 | 396 |
return numberOfWords; |
| 399 | 397 |
} |
| 400 |
|
|
| 398 |
|
|
| 401 | 399 |
/** |
| 402 | 400 |
* Gets the n properties. |
| 403 | 401 |
* |
| ... | ... | |
| 406 | 404 |
public int getNProperties() {
|
| 407 | 405 |
return NProperties; |
| 408 | 406 |
} |
| 409 |
|
|
| 407 |
|
|
| 410 | 408 |
/** |
| 411 | 409 |
* Gets the internal architecture. |
| 412 | 410 |
* |
| ... | ... | |
| 415 | 413 |
public List<String> getInternalArchitecture() {
|
| 416 | 414 |
return internalArchitecture; |
| 417 | 415 |
} |
| 418 |
|
|
| 416 |
|
|
| 419 | 417 |
/** |
| 420 | 418 |
* Gets the n structures. |
| 421 | 419 |
* |
| ... | ... | |
| 424 | 422 |
public int getNStructures() {
|
| 425 | 423 |
return NStructures; |
| 426 | 424 |
} |
| 427 |
|
|
| 425 |
|
|
| 428 | 426 |
/** |
| 429 | 427 |
* Gets the structures counts. |
| 430 | 428 |
* |
| ... | ... | |
| 433 | 431 |
public HashMap<String, Integer> getStructuresCounts() {
|
| 434 | 432 |
return structuresCounts; |
| 435 | 433 |
} |
| 436 |
|
|
| 434 |
|
|
| 437 | 435 |
/** |
| 438 | 436 |
* Gets the annotations types. |
| 439 | 437 |
* |
| ... | ... | |
| 442 | 440 |
public HashMap<String, Integer> getAnnotationsTypes() {
|
| 443 | 441 |
return annotationsTypes; |
| 444 | 442 |
} |
| 445 |
|
|
| 443 |
|
|
| 446 | 444 |
/** |
| 447 | 445 |
* Gets the annotations origins. |
| 448 | 446 |
* |
| ... | ... | |
| 451 | 449 |
public HashMap<String, Integer> getAnnotationsOrigins() {
|
| 452 | 450 |
return annotationsOrigins; |
| 453 | 451 |
} |
| 454 |
|
|
| 452 |
|
|
| 455 | 453 |
@Override |
| 456 | 454 |
public boolean _compute(TXMProgressMonitor monitor) throws Exception {
|
| 457 |
|
|
| 455 |
|
|
| 458 | 456 |
monitor.setTask(props.getComputingStartMessage()); |
| 459 |
|
|
| 457 |
|
|
| 460 | 458 |
this.stepGeneralInfos(); |
| 461 | 459 |
monitor.worked(34); |
| 462 |
|
|
| 460 |
|
|
| 463 | 461 |
this.stepLexicalProperties(); |
| 464 | 462 |
monitor.worked(33); |
| 465 |
|
|
| 463 |
|
|
| 466 | 464 |
this.stepStructuralUnits(); |
| 467 | 465 |
monitor.worked(33); |
| 468 |
|
|
| 466 |
|
|
| 469 | 467 |
return true; |
| 470 | 468 |
} |
| 471 |
|
|
| 469 |
|
|
| 472 | 470 |
public String getDetails() {
|
| 473 | 471 |
if (numberOfWords >= 0) {
|
| 474 | 472 |
return NLS.bind(PropertiesCoreMessages.numberOfWordsP0, numberOfWords); |
Formats disponibles : Unified diff