Révision 2247
tmp/org.txm.properties.rcp/plugin.xml (revision 2247) | ||
---|---|---|
28 | 28 |
id="org.txm.properties.rcp.editors.PropertiesEditor" |
29 | 29 |
name="%command.name"> |
30 | 30 |
</editor> |
31 |
<editor |
|
32 |
class="org.txm.properties.rcp.editors.PropertiesPagedEditor" |
|
33 |
default="false" |
|
34 |
icon="icons/functions/properties.png" |
|
35 |
id="org.txm.properties.rcp.editors.PropertiesPagedEditor" |
|
36 |
name="%command.name"> |
|
37 |
</editor> |
|
31 | 38 |
</extension> |
32 | 39 |
<extension |
33 | 40 |
point="org.eclipse.core.runtime.adapters"> |
... | ... | |
55 | 62 |
checkEnabled="false"> |
56 | 63 |
<or> |
57 | 64 |
<reference |
58 |
definitionId="OneCorpusSelected">
|
|
65 |
definitionId="OneTXMResultSelected">
|
|
59 | 66 |
</reference> |
60 | 67 |
</or> |
61 | 68 |
</visibleWhen> |
... | ... | |
70 | 77 |
<visibleWhen |
71 | 78 |
checkEnabled="false"> |
72 | 79 |
<reference |
73 |
definitionId="OneCorpusSelected">
|
|
80 |
definitionId="OneTXMResultSelected">
|
|
74 | 81 |
</reference> |
75 | 82 |
</visibleWhen> |
76 | 83 |
</command> |
... | ... | |
84 | 91 |
<visibleWhen |
85 | 92 |
checkEnabled="false"> |
86 | 93 |
<reference |
87 |
definitionId="OneCorpusSelected">
|
|
94 |
definitionId="OneTXMResultSelected">
|
|
88 | 95 |
</reference> |
89 | 96 |
</visibleWhen> |
90 | 97 |
</command> |
tmp/org.txm.properties.rcp/src/org/txm/properties/rcp/editors/PropertiesGeneralTab.java (revision 2247) | ||
---|---|---|
1 |
package org.txm.properties.rcp.editors; |
|
2 |
|
|
3 |
import java.util.Date; |
|
4 |
|
|
5 |
import org.eclipse.jface.viewers.DecoratingLabelProvider; |
|
6 |
import org.eclipse.jface.viewers.IBaseLabelProvider; |
|
7 |
import org.eclipse.swt.SWT; |
|
8 |
import org.eclipse.swt.events.KeyEvent; |
|
9 |
import org.eclipse.swt.events.KeyListener; |
|
10 |
import org.eclipse.swt.events.SelectionEvent; |
|
11 |
import org.eclipse.swt.events.SelectionListener; |
|
12 |
import org.eclipse.swt.graphics.Image; |
|
13 |
import org.eclipse.swt.layout.GridData; |
|
14 |
import org.eclipse.swt.widgets.Button; |
|
15 |
import org.eclipse.swt.widgets.Label; |
|
16 |
import org.eclipse.swt.widgets.TabFolder; |
|
17 |
import org.eclipse.swt.widgets.Text; |
|
18 |
import org.txm.core.results.TXMResult; |
|
19 |
import org.txm.rcp.IImageKeys; |
|
20 |
import org.txm.rcp.views.corpora.CorporaView; |
|
21 |
|
|
22 |
public class PropertiesGeneralTab extends PropertiesTab { |
|
23 |
|
|
24 |
private Text nameField; |
|
25 |
|
|
26 |
public PropertiesGeneralTab(TabFolder folder, PropertiesPagedEditor editor2) { |
|
27 |
super(folder, editor2); |
|
28 |
tab.setText("General"); |
|
29 |
|
|
30 |
parent.getLayout().numColumns = 3; |
|
31 |
parent.getLayout().verticalSpacing = 10; |
|
32 |
parent.getLayout().horizontalSpacing = 10; |
|
33 |
parent.getLayout().marginTop = 10; |
|
34 |
parent.getLayout().marginLeft = 10; |
|
35 |
|
|
36 |
Label image = new Label(parent, SWT.NONE); |
|
37 |
//image.setImage(IImageKeys.getImage("")); |
|
38 |
IBaseLabelProvider lp = CorporaView.getInstance().getTreeViewer().getLabelProvider(); |
|
39 |
if (lp instanceof DecoratingLabelProvider) { |
|
40 |
Image img = ((DecoratingLabelProvider)lp).getImage(editor.getResult().getParent()); |
|
41 |
if (img != null) { |
|
42 |
image.setImage(img); |
|
43 |
} else { |
|
44 |
image.setImage(IImageKeys.getImage(IImageKeys.FILE)); |
|
45 |
} |
|
46 |
} |
|
47 |
image.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, true, 1, 7)); |
|
48 |
|
|
49 |
|
|
50 |
Label l = new Label(parent, SWT.NONE); |
|
51 |
l.setText("Name"); |
|
52 |
|
|
53 |
nameField = new Text(parent, SWT.BORDER); |
|
54 |
nameField.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false)); |
|
55 |
nameField.setText(editor.getResult().getParent().getUserName()); |
|
56 |
nameField.addKeyListener(new KeyListener() { |
|
57 |
|
|
58 |
@Override |
|
59 |
public void keyReleased(KeyEvent e) { |
|
60 |
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR && nameField.getText().length() > 0 && !nameField.getText().equals(editor.getResult().getParent().getUserName())) { |
|
61 |
editor.getResult().getParent().setUserName(nameField.getText()); |
|
62 |
System.out.println("Name updated with "+nameField.getText()); |
|
63 |
CorporaView.refreshObject(editor.getResult().getParent()); |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
@Override |
|
68 |
public void keyPressed(KeyEvent e) { } |
|
69 |
}); |
|
70 |
new Label(parent, SWT.NONE).setText("Type"); |
|
71 |
l = new Label(parent, SWT.NONE); |
|
72 |
l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false)); |
|
73 |
l.setText(editor.getResult().getParent().getResultType()); |
|
74 |
|
|
75 |
// new Label(parent, SWT.NONE).setText("Size"); |
|
76 |
// l = new Label(parent, SWT.NONE); |
|
77 |
// l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false)); |
|
78 |
// l.setText(""+editor.getResult().getParent().getChildren().size()); |
|
79 |
|
|
80 |
new Label(parent, SWT.NONE).setText("Parent"); |
|
81 |
l = new Label(parent, SWT.NONE); |
|
82 |
l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false)); |
|
83 |
l.setText(""+editor.getResult().getParent().getParent().getUserName()); |
|
84 |
|
|
85 |
new Label(parent, SWT.NONE).setText("Creation date"); |
|
86 |
l = new Label(parent, SWT.NONE); |
|
87 |
l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false)); |
|
88 |
Date d = editor.getResult().getParent().getCreationDate(); |
|
89 |
if (d != null) { |
|
90 |
l.setText(""+TXMResult.PRETTY_LOCALIZED_TIME_FORMAT.format(d)); |
|
91 |
} |
|
92 |
|
|
93 |
new Label(parent, SWT.NONE).setText("Last update date"); |
|
94 |
l = new Label(parent, SWT.NONE); |
|
95 |
l.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false)); |
|
96 |
d = editor.getResult().getParent().getLastComputingDate(); |
|
97 |
if (d != null) { |
|
98 |
l.setText(""+TXMResult.PRETTY_LOCALIZED_TIME_FORMAT.format(d)); |
|
99 |
} else { |
|
100 |
l.setText("(not computed)"); |
|
101 |
} |
|
102 |
|
|
103 |
new Label(parent, SWT.NONE); |
|
104 |
|
|
105 |
Button clipButton = new Button(parent, SWT.PUSH); |
|
106 |
clipButton.setLayoutData(new GridData(GridData.END, GridData.END, false, false)); |
|
107 |
clipButton.setText("Copy"); |
|
108 |
clipButton.addSelectionListener(new SelectionListener() { |
|
109 |
|
|
110 |
@Override |
|
111 |
public void widgetSelected(SelectionEvent e) { |
|
112 |
toClipboard(); |
|
113 |
} |
|
114 |
|
|
115 |
@Override |
|
116 |
public void widgetDefaultSelected(SelectionEvent e) { } |
|
117 |
}); |
|
118 |
} |
|
119 |
|
|
120 |
public void toClipboard() { |
|
121 |
StringBuffer buffer = new StringBuffer(); |
|
122 |
buffer.append("Name: "+ editor.getResult().getParent().getUserName()); |
|
123 |
buffer.append("\n"); |
|
124 |
buffer.append("Type: "+editor.getResult().getParent().getResultType()); |
|
125 |
buffer.append("\n"); |
|
126 |
// buffer.append("Size: "+editor.getResult().getParent().getChildren().size()); |
|
127 |
// buffer.append("\n"); |
|
128 |
buffer.append("Parent: "+editor.getResult().getParent().getParent().getUserName()); |
|
129 |
buffer.append("\n"); |
|
130 |
Date d = editor.getResult().getParent().getCreationDate(); |
|
131 |
if (d != null) { |
|
132 |
buffer.append("Creation date: "+TXMResult.PRETTY_LOCALIZED_TIME_FORMAT.format(d)); |
|
133 |
} |
|
134 |
|
|
135 |
buffer.append("\n"); |
|
136 |
d = editor.getResult().getParent().getCreationDate(); |
|
137 |
if (d != null) { |
|
138 |
buffer.append("Last update date: "+TXMResult.PRETTY_LOCALIZED_TIME_FORMAT.format(d)); |
|
139 |
} else { |
|
140 |
buffer.append("Last update date: (never computed)"); |
|
141 |
} |
|
142 |
|
|
143 |
org.txm.rcp.utils.IOClipboard.write(buffer.toString()); |
|
144 |
} |
|
145 |
|
|
146 |
@Override |
|
147 |
public void updateResultFromEditor(boolean update) { |
|
148 |
// TODO Auto-generated method stub |
|
149 |
} |
|
150 |
|
|
151 |
@Override |
|
152 |
public void updateEditorFromResult() { |
|
153 |
// TODO Auto-generated method stub |
|
154 |
} |
|
155 |
} |
|
0 | 156 |
tmp/org.txm.properties.rcp/src/org/txm/properties/rcp/editors/PropertiesTab.java (revision 2247) | ||
---|---|---|
1 |
package org.txm.properties.rcp.editors; |
|
2 |
|
|
3 |
import org.eclipse.swt.SWT; |
|
4 |
import org.eclipse.swt.widgets.TabFolder; |
|
5 |
import org.eclipse.swt.widgets.TabItem; |
|
6 |
import org.txm.rcp.swt.GLComposite; |
|
7 |
|
|
8 |
public abstract class PropertiesTab { |
|
9 |
|
|
10 |
protected TabFolder folder; |
|
11 |
protected TabItem tab; |
|
12 |
protected GLComposite parent; |
|
13 |
|
|
14 |
protected PropertiesPagedEditor editor; |
|
15 |
|
|
16 |
public PropertiesTab(TabFolder folder, PropertiesPagedEditor editor) { |
|
17 |
tab = new TabItem(folder, SWT.NONE); |
|
18 |
parent = new GLComposite(folder, SWT.NONE, "tab"); |
|
19 |
tab.setControl(parent); |
|
20 |
|
|
21 |
this.folder = folder; |
|
22 |
this.editor = editor; |
|
23 |
} |
|
24 |
|
|
25 |
public abstract void updateResultFromEditor(boolean update) throws Exception; |
|
26 |
|
|
27 |
public abstract void updateEditorFromResult(); |
|
28 |
} |
|
0 | 29 |
tmp/org.txm.properties.rcp/src/org/txm/properties/rcp/editors/PropertiesPagedEditor.java (revision 2247) | ||
---|---|---|
1 |
package org.txm.properties.rcp.editors; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
|
|
5 |
import org.eclipse.swt.SWT; |
|
6 |
import org.eclipse.swt.layout.GridData; |
|
7 |
import org.eclipse.swt.widgets.Composite; |
|
8 |
import org.eclipse.swt.widgets.Spinner; |
|
9 |
import org.eclipse.swt.widgets.TabFolder; |
|
10 |
import org.eclipse.swt.widgets.TabItem; |
|
11 |
import org.txm.properties.core.functions.Properties; |
|
12 |
import org.txm.properties.core.preferences.PropertiesPreferences; |
|
13 |
import org.txm.properties.rcp.messages.PropertiesUIMessages; |
|
14 |
import org.txm.rcp.editors.TXMEditor; |
|
15 |
import org.txm.rcp.swt.GLComposite; |
|
16 |
import org.txm.rcp.swt.widget.LabeledSpinner; |
|
17 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
|
18 |
import org.txm.core.results.Parameter; |
|
19 |
import org.txm.core.results.TXMResult; |
|
20 |
|
|
21 |
public class PropertiesPagedEditor extends TXMEditor<Properties> { |
|
22 |
|
|
23 |
private TabFolder tabFolder; |
|
24 |
protected ArrayList<PropertiesTab> tabs = new ArrayList<PropertiesTab>(); |
|
25 |
|
|
26 |
/** |
|
27 |
* The maximum number of word property values to display. |
|
28 |
*/ |
|
29 |
@Parameter(key = PropertiesPreferences.MAX_PROPERTIES_TO_DISPLAY) |
|
30 |
protected Spinner maxPropertiesToDisplay; |
|
31 |
|
|
32 |
@Override |
|
33 |
public void _createPartControl() throws Exception { |
|
34 |
|
|
35 |
Composite extendedParametersArea = this.getExtendedParametersGroup(); |
|
36 |
LabeledSpinner fMax = new LabeledSpinner(extendedParametersArea, this, PropertiesUIMessages.vMax); |
|
37 |
this.maxPropertiesToDisplay = fMax.getSpinner(); |
|
38 |
this.maxPropertiesToDisplay.setToolTipText(PropertiesUIMessages.theMaximumNumberOfWordPropertyValuesToShow); |
|
39 |
this.maxPropertiesToDisplay.setMinimum(0); |
|
40 |
this.maxPropertiesToDisplay.setMaximum(1000); |
|
41 |
|
|
42 |
|
|
43 |
GLComposite parent = getResultArea(); |
|
44 |
tabFolder = new TabFolder (parent, SWT.BORDER); |
|
45 |
tabFolder.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); |
|
46 |
|
|
47 |
tabs.add(new PropertiesGeneralTab(tabFolder, this)); |
|
48 |
PropertiesTXMResultTab resultTab = new PropertiesTXMResultTab(tabFolder, this); |
|
49 |
tabs.add(resultTab); |
|
50 |
tabs.add(new PropertiesParametersTab(tabFolder, this)); |
|
51 |
|
|
52 |
tabFolder.setSelection(resultTab.getTab()); |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
public void updateResultFromEditor() { |
|
57 |
for (PropertiesTab tab : tabs) { |
|
58 |
tab.updateEditorFromResult(); |
|
59 |
} |
|
60 |
} |
|
61 |
|
|
62 |
@Override |
|
63 |
public void updateEditorFromResult(boolean update) throws Exception { |
|
64 |
for (PropertiesTab tab : tabs) { |
|
65 |
tab.updateEditorFromResult(); |
|
66 |
} |
|
67 |
} |
|
68 |
|
|
69 |
|
|
70 |
} |
|
0 | 71 |
tmp/org.txm.properties.rcp/src/org/txm/properties/rcp/editors/PropertiesParametersTab.java (revision 2247) | ||
---|---|---|
1 |
package org.txm.properties.rcp.editors; |
|
2 |
|
|
3 |
import org.eclipse.jface.layout.GridDataFactory; |
|
4 |
import org.eclipse.swt.SWT; |
|
5 |
import org.eclipse.swt.layout.GridData; |
|
6 |
import org.eclipse.swt.widgets.TabFolder; |
|
7 |
import org.txm.rcp.views.cmdparameters.ParametersComposite; |
|
8 |
|
|
9 |
/** |
|
10 |
* Display the Properties parent parameters stored in the preferences |
|
11 |
* @author mdecorde |
|
12 |
* |
|
13 |
*/ |
|
14 |
public class PropertiesParametersTab extends PropertiesTab { |
|
15 |
private ParametersComposite parametersComposite; |
|
16 |
|
|
17 |
public PropertiesParametersTab(TabFolder folder, PropertiesPagedEditor editor) { |
|
18 |
super(folder, editor); |
|
19 |
tab.setText("Parameters"); |
|
20 |
|
|
21 |
parametersComposite = new ParametersComposite(parent, SWT.NONE); |
|
22 |
parametersComposite.setLayoutData(GridDataFactory.fillDefaults().align(GridData.FILL, GridData.FILL).grab(true, true).create()); |
|
23 |
parametersComposite.updateEditorParameters(editor.getResult().getParent()); |
|
24 |
|
|
25 |
folder.layout(); |
|
26 |
} |
|
27 |
|
|
28 |
@Override |
|
29 |
public void updateResultFromEditor(boolean update) { |
|
30 |
|
|
31 |
} |
|
32 |
|
|
33 |
@Override |
|
34 |
public void updateEditorFromResult() { |
|
35 |
parametersComposite.refresh(); |
|
36 |
} |
|
37 |
} |
|
0 | 38 |
tmp/org.txm.properties.rcp/src/org/txm/properties/rcp/editors/PropertiesTXMResultTab.java (revision 2247) | ||
---|---|---|
1 |
package org.txm.properties.rcp.editors; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.net.MalformedURLException; |
|
5 |
|
|
6 |
import org.eclipse.swt.SWT; |
|
7 |
import org.eclipse.swt.browser.Browser; |
|
8 |
import org.eclipse.swt.layout.GridData; |
|
9 |
import org.eclipse.swt.widgets.Label; |
|
10 |
import org.eclipse.swt.widgets.TabFolder; |
|
11 |
import org.eclipse.swt.widgets.TabItem; |
|
12 |
import org.txm.core.results.TXMResult; |
|
13 |
import org.txm.rcp.swt.GLComposite; |
|
14 |
import org.txm.utils.logger.Log; |
|
15 |
|
|
16 |
/** |
|
17 |
* Page displayed if Properties parent is a Corpus |
|
18 |
* |
|
19 |
* @author mdecorde |
|
20 |
* |
|
21 |
*/ |
|
22 |
public class PropertiesTXMResultTab extends PropertiesTab { |
|
23 |
|
|
24 |
TXMResult result; |
|
25 |
protected Browser browser; |
|
26 |
|
|
27 |
public PropertiesTXMResultTab(TabFolder folder, PropertiesPagedEditor editor) { |
|
28 |
super(folder, editor); |
|
29 |
|
|
30 |
this.result = editor.getResult().getParent(); |
|
31 |
tab.setText(result.getResultType()); |
|
32 |
|
|
33 |
buildContent(parent); |
|
34 |
} |
|
35 |
|
|
36 |
protected void buildContent(GLComposite parent) { |
|
37 |
this.browser = new Browser(parent, SWT.NONE); |
|
38 |
this.browser.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public void updateResultFromEditor(boolean update) throws Exception { |
|
43 |
|
|
44 |
} |
|
45 |
|
|
46 |
@Override |
|
47 |
public void updateEditorFromResult() { |
|
48 |
File file = this.editor.getResult().getHTMLFile(); |
|
49 |
if (file != null && file.exists()) { |
|
50 |
try { |
|
51 |
this.browser.setUrl(file.toURI().toURL().toString()); |
|
52 |
} catch (MalformedURLException e) { |
|
53 |
// TODO Auto-generated catch block |
|
54 |
e.printStackTrace(); |
|
55 |
} |
|
56 |
} else { |
|
57 |
Log.severe("Information HTML file doesn't exist."); //$NON-NLS-1$ |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
public TabItem getTab() { |
|
62 |
return tab; |
|
63 |
} |
|
64 |
} |
|
0 | 65 |
tmp/org.txm.properties.rcp/src/org/txm/properties/rcp/handlers/ComputeProperties.java (revision 2247) | ||
---|---|---|
33 | 33 |
import org.eclipse.core.commands.ExecutionException; |
34 | 34 |
import org.txm.core.results.TXMResult; |
35 | 35 |
import org.txm.properties.core.functions.Properties; |
36 |
import org.txm.properties.rcp.editors.PropertiesEditor; |
|
36 |
import org.txm.properties.rcp.editors.PropertiesPagedEditor;
|
|
37 | 37 |
import org.txm.rcp.editors.TXMEditor; |
38 | 38 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
39 |
import org.txm.rcp.views.corpora.CorporaView; |
|
40 | 39 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
41 | 40 |
|
42 | 41 |
/** |
... | ... | |
47 | 46 |
* @author sjacquot |
48 | 47 |
*/ |
49 | 48 |
public class ComputeProperties extends BaseAbstractHandler { |
50 |
|
|
51 |
|
|
49 |
|
|
50 |
|
|
52 | 51 |
@Override |
53 | 52 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
54 | 53 |
|
55 | 54 |
if (!this.checkCorpusEngine()) { |
56 | 55 |
return false; |
57 | 56 |
} |
58 |
|
|
57 |
|
|
59 | 58 |
Object selection = this.getCorporaViewSelectedObject(event); |
60 | 59 |
Properties information = null; |
61 |
|
|
60 |
|
|
62 | 61 |
// Creating from Corpus |
63 |
if (selection instanceof CQPCorpus) { |
|
64 |
List<Properties> informations = (List<Properties>) ((CQPCorpus)selection).getChildren(Properties.class); |
|
65 |
// only one instance |
|
66 |
if (informations.size() > 0) { |
|
62 |
if(selection instanceof Properties) { |
|
63 |
information = (Properties) selection; |
|
64 |
} else if (selection instanceof TXMResult) { |
|
65 |
List<Properties> informations = (List<Properties>) ((TXMResult)selection).getChildren(Properties.class); |
|
66 |
if (informations.size() > 0) { // we want only one instance of Properties per TXMResult |
|
67 | 67 |
information = informations.get(0); |
68 | 68 |
} |
69 | 69 |
else { |
70 |
information = new Properties((CQPCorpus) selection);
|
|
70 |
information = new Properties((TXMResult) selection);
|
|
71 | 71 |
} |
72 | 72 |
} |
73 | 73 |
// Reopening from existing result |
74 |
else if(selection instanceof Properties) { |
|
75 |
information = (Properties) selection; |
|
76 |
} |
|
77 |
// Error |
|
78 |
else { |
|
74 |
else { |
|
79 | 75 |
return super.logCanNotExecuteCommand(selection); |
80 | 76 |
} |
81 |
|
|
82 |
TXMEditor.openEditor(information, PropertiesEditor.class.getName()); |
|
77 |
|
|
78 |
TXMEditor.openEditor(information, PropertiesPagedEditor.class.getName());
|
|
83 | 79 |
return null; |
84 | 80 |
} |
85 | 81 |
} |
tmp/org.txm.properties.core/src/org/txm/properties/core/messages/messages_fr.properties (revision 2247) | ||
---|---|---|
38 | 38 |
|
39 | 39 |
t = - T |
40 | 40 |
|
41 |
updatedTheP0 = <p>Dernière modification : {0}.</p>
|
|
41 |
updatedTheP0 = <p>Dernière modification : {0}</p> |
|
42 | 42 |
|
43 | 43 |
wordProperties = - Propriétés de mot |
tmp/org.txm.properties.core/src/org/txm/properties/core/functions/CorpusPropertiesComputer.java (revision 2247) | ||
---|---|---|
1 |
package org.txm.properties.core.functions; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.Arrays; |
|
5 |
import java.util.Collections; |
|
6 |
import java.util.HashMap; |
|
7 |
import java.util.LinkedHashMap; |
|
8 |
import java.util.LinkedHashSet; |
|
9 |
import java.util.List; |
|
10 |
import java.util.Locale; |
|
11 |
|
|
12 |
import org.apache.commons.lang.StringUtils; |
|
13 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
14 |
import org.eclipse.osgi.util.NLS; |
|
15 |
import org.txm.core.messages.TXMCoreMessages; |
|
16 |
import org.txm.core.results.TXMResult; |
|
17 |
import org.txm.objects.Project; |
|
18 |
import org.txm.properties.core.messages.PropertiesCoreMessages; |
|
19 |
import org.txm.searchengine.cqp.AbstractCqiClient; |
|
20 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
21 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
|
22 |
import org.txm.searchengine.cqp.corpus.CorpusManager; |
|
23 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
|
24 |
import org.txm.searchengine.cqp.corpus.Property; |
|
25 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
|
26 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
|
27 |
import org.txm.searchengine.cqp.corpus.WordProperty; |
|
28 |
import org.txm.utils.logger.Log; |
|
29 |
|
|
30 |
public class CorpusPropertiesComputer extends PropertiesComputer<CQPCorpus>{ |
|
31 |
|
|
32 |
public CorpusPropertiesComputer(Properties props, CQPCorpus result) { |
|
33 |
super(props, result); |
|
34 |
} |
|
35 |
|
|
36 |
@Override |
|
37 |
public List<String> getComputableInformations() { |
|
38 |
return Arrays.asList("all"); |
|
39 |
} |
|
40 |
|
|
41 |
@Override |
|
42 |
public LinkedHashMap<String, String> getInformation(String name) { |
|
43 |
LinkedHashMap<String, String> data = new LinkedHashMap<String, String>(); |
|
44 |
data.put("all", dump(props.pMaxPropertiesToDisplay)); |
|
45 |
return data; |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
public String getInformationHTML(String info) { |
|
50 |
return htmlDump(); |
|
51 |
} |
|
52 |
|
|
53 |
// Numbers |
|
54 |
/** The T. */ |
|
55 |
int numberOfWords = 0; // number of word |
|
56 |
|
|
57 |
/** The N properties. */ |
|
58 |
int NProperties = 0; // number of word properties |
|
59 |
// HashMap<String, Integer> propertiesCounts = new HashMap<String, Integer>(); |
|
60 |
// // properties counts |
|
61 |
/** The properties values. */ |
|
62 |
HashMap<String, List<String>> propertiesValues = new HashMap<String, List<String>>(); // properties values |
|
63 |
|
|
64 |
/** The N structures. */ |
|
65 |
int NStructures = 0; // number of structures |
|
66 |
|
|
67 |
/** The structures counts. */ |
|
68 |
HashMap<String, Integer> structuresCounts = new HashMap<String, Integer>(); // structures counts |
|
69 |
|
|
70 |
/** The internal architecture. */ |
|
71 |
List<String> internalArchitecture = new ArrayList<String>(); // cqp structures = propertiesCounts keys but ordered |
|
72 |
|
|
73 |
/** The hierarchie counts. */ |
|
74 |
HashMap<String, Integer> hierarchieCounts = new HashMap<String, Integer>(); // hierarchic structures counts |
|
75 |
|
|
76 |
/** The internal architecture properties. */ |
|
77 |
HashMap<String, HashMap<String, List<String>>> internalArchitectureProperties = new HashMap<String, HashMap<String, List<String>>>(); // hierarchic structures counts |
|
78 |
|
|
79 |
/** The internal architecture properties counts. */ |
|
80 |
HashMap<String, HashMap<String, Integer>> internalArchitecturePropertiesCounts = new HashMap<String, HashMap<String, Integer>>(); // hierarchic structures counts |
|
81 |
|
|
82 |
// Annotations description |
|
83 |
/** The annotations types. */ |
|
84 |
HashMap<String, Integer> annotationsTypes = new HashMap<String, Integer>(); // for each annotation its description |
|
85 |
|
|
86 |
/** The annotations origins. */ |
|
87 |
HashMap<String, Integer> annotationsOrigins = new HashMap<String, Integer>(); // for each annoation its origin description |
|
88 |
|
|
89 |
/** The properties. */ |
|
90 |
List<WordProperty> properties; |
|
91 |
|
|
92 |
/** The structures. */ |
|
93 |
List<StructuralUnit> structures; |
|
94 |
|
|
95 |
public String getName() { |
|
96 |
String filename = result.getMainCorpus() + "-" + result.getName(); //$NON-NLS-1$ |
|
97 |
if (result instanceof MainCorpus) { |
|
98 |
filename = result.getID(); // $NON-NLS-1$ |
|
99 |
} |
|
100 |
return filename; |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* Step general infos. |
|
105 |
*/ |
|
106 |
public void stepGeneralInfos() { |
|
107 |
try { |
|
108 |
properties = result.getProperties(); |
|
109 |
List<WordProperty> pproperties = new ArrayList<WordProperty>(properties); |
|
110 |
for (WordProperty p : properties) { |
|
111 |
if (p.getName().equals("id")) { |
|
112 |
pproperties.remove(p); |
|
113 |
} |
|
114 |
} |
|
115 |
properties = pproperties; |
|
116 |
NProperties = properties.size(); |
|
117 |
} catch (CqiClientException e) { |
|
118 |
Log.severe(TXMCoreMessages.bind(PropertiesCoreMessages.error_failedToAccessPropertieOfCorpusP0, result.getName())); |
|
119 |
Log.printStackTrace(e); |
|
120 |
return; |
|
121 |
} |
|
122 |
|
|
123 |
try { |
|
124 |
numberOfWords = result.getSize();// corpus.getLexicon(corpus.getProperty("id")).nbrOfToken(); |
|
125 |
} catch (CqiClientException e) { |
|
126 |
Log.severe(TXMCoreMessages.bind(PropertiesCoreMessages.error_failedToAccessLexiconOfCorpusP0, result.getName())); |
|
127 |
Log.printStackTrace(e); |
|
128 |
return; |
|
129 |
} |
|
130 |
} |
|
131 |
|
|
132 |
/** |
|
133 |
* step2. randomly position are choose |
|
134 |
*/ |
|
135 |
public void stepLexicalProperties() { |
|
136 |
propertiesValues.clear(); |
|
137 |
|
|
138 |
AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient(); |
|
139 |
for (Property p : properties) { |
|
140 |
// int size; |
|
141 |
try { |
|
142 |
// size = |
|
143 |
// CorpusManager.getCorpusManager().getCqiClient().lexiconSize(p.getQualifiedName()); |
|
144 |
// propertiesCounts.put(p.getName(), size); |
|
145 |
// List<String> list = |
|
146 |
// Arrays.asList(corpus.getLexicon(p).getForms(this.maxvalue)); |
|
147 |
|
|
148 |
int[] positions = new int[Math.min(props.pMaxPropertiesToDisplay, numberOfWords)]; |
|
149 |
for (int i = 0; i < Math.min(props.pMaxPropertiesToDisplay, numberOfWords); i++) { |
|
150 |
positions[i] = i; |
|
151 |
} |
|
152 |
|
|
153 |
// ArrayList<String> values = new ArrayList<String>(); |
|
154 |
LinkedHashSet<String> values = new LinkedHashSet<String>(cqiClient.getSingleData(p, positions)); |
|
155 |
propertiesValues.put(p.getName(), new ArrayList<String>(values)); |
|
156 |
} catch (Exception e) { |
|
157 |
Log.printStackTrace(e); |
|
158 |
} |
|
159 |
} |
|
160 |
} |
|
161 |
|
|
162 |
/** |
|
163 |
* Step structural units. |
|
164 |
*/ |
|
165 |
public void stepStructuralUnits() { |
|
166 |
try { |
|
167 |
structures = result.getOrderedStructuralUnits(); |
|
168 |
|
|
169 |
List<StructuralUnit> sstructures = new ArrayList<StructuralUnit>(structures); |
|
170 |
for (StructuralUnit su : structures) { |
|
171 |
if (su.getName().equals("txmcorpus")) { |
|
172 |
sstructures.remove(su); |
|
173 |
} |
|
174 |
} |
|
175 |
structures = sstructures; |
|
176 |
} catch (CqiClientException e) { |
|
177 |
Log.severe(TXMCoreMessages.bind(PropertiesCoreMessages.error_failedToAccessStructuresOfCorpusP0, result.getName())); |
|
178 |
Log.printStackTrace(e); |
|
179 |
return; |
|
180 |
} |
|
181 |
NStructures = structures.size(); |
|
182 |
internalArchitecture.clear(); |
|
183 |
for (StructuralUnit su : structures) { // for each structural unit |
|
184 |
internalArchitecture.add(su.getName()); |
|
185 |
hierarchieCounts.put(su.getName(), -1); |
|
186 |
internalArchitectureProperties.put(su.getName(), new HashMap<String, List<String>>()); |
|
187 |
internalArchitecturePropertiesCounts.put(su.getName(), new HashMap<String, Integer>()); |
|
188 |
|
|
189 |
if (su.getProperties().size() > 0) { |
|
190 |
for (StructuralUnitProperty sup : su.getProperties()) {// for each of its property |
|
191 |
try { |
|
192 |
List<String> allvalues = sup.getValues(result); |
|
193 |
internalArchitectureProperties.get(su.getName()).put(sup.getName(), allvalues.subList(0, Math.min(allvalues.size(), props.pMaxPropertiesToDisplay))); |
|
194 |
internalArchitecturePropertiesCounts.get(su.getName()).put(sup.getName(), allvalues.size()); |
|
195 |
} catch (Exception e) { |
|
196 |
ArrayList<String> list = new ArrayList<String>(1); |
|
197 |
list.add(PropertiesCoreMessages.error); |
|
198 |
internalArchitectureProperties.get(su.getName()).put(sup.getName(), list); |
|
199 |
internalArchitecturePropertiesCounts.get(su.getName()).put(sup.getName(), -1); |
|
200 |
} |
|
201 |
} |
|
202 |
} |
|
203 |
} |
|
204 |
} |
|
205 |
|
|
206 |
/** |
|
207 |
* dump the results of the diagnostic in a String containing HTML code. |
|
208 |
* |
|
209 |
* @return the string |
|
210 |
*/ |
|
211 |
public String htmlDump() { |
|
212 |
StringBuffer buff = new StringBuffer(); |
|
213 |
|
|
214 |
buff.append("<? version=\"1.0\" encoding=\"UTF-8\"?>\n" + //$NON-NLS-1$ |
|
215 |
"<html>" + //$NON-NLS-1$ |
|
216 |
"<head>" + //$NON-NLS-1$ |
|
217 |
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>" + //$NON-NLS-1$ |
|
218 |
"</head>" + //$NON-NLS-1$ |
|
219 |
"<body>\n"); //$NON-NLS-1$ |
|
220 |
buff.append("<h2 style'font-family:\"Arial\";'>" + PropertiesCoreMessages.descriptionOf + this.result.getName() + " (id=" + this.result.getID() + ")</h2>\n"); //$NON-NLS-2$ //$NON-NLS-1$ |
|
221 |
|
|
222 |
Project projet = this.result.getProject(); |
|
223 |
if (projet.getCreationDate() != null) { |
|
224 |
buff.append(NLS.bind(PropertiesCoreMessages.createdTheP0, TXMResult.PRETTY_LOCALIZED_TIME_FORMAT.format(projet.getCreationDate()))); |
|
225 |
} |
|
226 |
if (projet.getLastComputingDate() != null) { |
|
227 |
buff.append(NLS.bind(PropertiesCoreMessages.updatedTheP0, TXMResult.PRETTY_LOCALIZED_TIME_FORMAT.format(projet.getLastComputingDate()))); |
|
228 |
} |
|
229 |
|
|
230 |
if (projet.getDescription() != null && projet.getDescription().length() > 0) { |
|
231 |
buff.append("<p><h3>Description</h3>" + projet.getDescription() + "</p>"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
232 |
} |
|
233 |
|
|
234 |
buff.append("<h3 style'font-family:\"Arial\";'>" + PropertiesCoreMessages.generalStatistics_2 + "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
235 |
|
|
236 |
// counts |
|
237 |
buff.append("<ul>\n"); //$NON-NLS-1$ |
|
238 |
buff.append("<li>" + NLS.bind(PropertiesCoreMessages.numberOfWordsP0, numberOfWords) + "</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
239 |
|
|
240 |
buff.append("<li>" + PropertiesCoreMessages.numberOfWordProperties + (properties.size()) + " ("+StringUtils.join(properties, ", ")+")</li>\n"); //$NON-NLS-2$ //$NON-NLS-1$ |
|
241 |
buff.append("<li>" + PropertiesCoreMessages.numberOfStructuralUnits + (structures.size()) + " ("+StringUtils.join(structures, ", ")+")</li>\n"); //$NON-NLS-2$ //$NON-NLS-1$ |
|
242 |
buff.append("</ul>\n"); //$NON-NLS-1$ |
|
243 |
|
|
244 |
// Propriétés d'occurrences |
|
245 |
buff.append("<h3 style'font-family:\"Arial\";'>" + NLS.bind(PropertiesCoreMessages.lexicalUnitsPropertiesMaxP0Values, props.pMaxPropertiesToDisplay) + "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
246 |
ArrayList<String> properties = new ArrayList<String>(propertiesValues.keySet()); |
|
247 |
Collections.sort(properties); |
|
248 |
buff.append("<ul>\n"); //$NON-NLS-1$ |
|
249 |
for (String s : properties) { |
|
250 |
if (!s.equals("id")) { //$NON-NLS-1$ |
|
251 |
// buff.append("<li> " + s + " (" + propertiesCounts.get(s) + ") : "); |
|
252 |
// //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
253 |
buff.append("<li> " + s + " : "); //$NON-NLS-1$ //$NON-NLS-2$ |
|
254 |
for (String v : propertiesValues.get(s)) |
|
255 |
buff.append(v + ", "); //$NON-NLS-1$ |
|
256 |
if (propertiesValues.get(s).size() >= this.props.pMaxPropertiesToDisplay) { |
|
257 |
buff.append("..."); //$NON-NLS-1$ |
|
258 |
} |
|
259 |
buff.append("</li>\n"); //$NON-NLS-1$ |
|
260 |
} |
|
261 |
} |
|
262 |
buff.append("</ul>\n"); //$NON-NLS-1$ |
|
263 |
|
|
264 |
// Propriété de structures |
|
265 |
buff.append("<h3 style'font-family:\"Arial\";'>" + NLS.bind(PropertiesCoreMessages.structuralUnitsPropertiesMaxP0Values, props.pMaxPropertiesToDisplay) + "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
266 |
buff.append("<ul>\n"); //$NON-NLS-1$ |
|
267 |
for (String s : internalArchitecture) { |
|
268 |
StringBuffer subbuffer = new StringBuffer(); |
|
269 |
if (s.equals("txmcorpus")) //$NON-NLS-1$ |
|
270 |
continue;// ignore the txmcorpus structure |
|
271 |
|
|
272 |
properties = new ArrayList<String>(internalArchitectureProperties.get(s).keySet()); |
|
273 |
|
|
274 |
subbuffer.append("<li> " + s + "\n<ul>\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
275 |
if (internalArchitectureProperties.get(s).keySet().size() == 0) |
|
276 |
subbuffer.append("<li>" + PropertiesCoreMessages.noProperty + "</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
277 |
|
|
278 |
// System.out.println("struct: "+s+" >> "+properties); |
|
279 |
Collections.sort(properties); |
|
280 |
// System.out.println("struct: "+s+" >sort> "+properties); |
|
281 |
int nbOfValues = 0; |
|
282 |
for (String ps : properties) { |
|
283 |
if (!ps.equals("project") && !ps.equals("base")) //$NON-NLS-1$ //$NON-NLS-2$ |
|
284 |
{ |
|
285 |
// System.out.println("struct: "+s+" >> "+ps); |
|
286 |
int valuecount = internalArchitecturePropertiesCounts.get(s).get(ps); |
|
287 |
ArrayList<String> values = new ArrayList<String>(internalArchitectureProperties.get(s).get(ps)); |
|
288 |
subbuffer.append("<li> " + ps + " (" + valuecount + ") = "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
289 |
// System.out.println("VALUES: "+values); |
|
290 |
Collections.sort(values); |
|
291 |
for (int i = 0; i < values.size(); i++) { |
|
292 |
nbOfValues++; |
|
293 |
String psv = values.get(i); |
|
294 |
if (psv != null && psv.length() > 0) |
|
295 |
subbuffer.append(psv.replace("<", "<")); //$NON-NLS-1$ //$NON-NLS-2$ |
|
296 |
else |
|
297 |
subbuffer.append("\"\""); //$NON-NLS-1$ |
|
298 |
|
|
299 |
if (i == values.size() - 1) |
|
300 |
subbuffer.append("."); //$NON-NLS-1$ |
|
301 |
else |
|
302 |
subbuffer.append(", "); //$NON-NLS-1$ |
|
303 |
|
|
304 |
if (i >= props.pMaxPropertiesToDisplay) { |
|
305 |
subbuffer.append("..."); //$NON-NLS-1$ |
|
306 |
break; |
|
307 |
} |
|
308 |
} |
|
309 |
subbuffer.append("</li>\n"); //$NON-NLS-1$ |
|
310 |
} |
|
311 |
} |
|
312 |
|
|
313 |
if (properties.size() == 0) { |
|
314 |
subbuffer.append("<p>--</p>\n"); //$NON-NLS-1$ |
|
315 |
} |
|
316 |
|
|
317 |
subbuffer.append("</ul>\n</li>\n"); //$NON-NLS-1$ |
|
318 |
if (nbOfValues > 0) { |
|
319 |
buff.append(subbuffer); |
|
320 |
} |
|
321 |
} |
|
322 |
buff.append("</ul>\n"); //$NON-NLS-1$ |
|
323 |
buff.append("</body>\n"); //$NON-NLS-1$ |
|
324 |
buff.append("</html>\n"); //$NON-NLS-1$ |
|
325 |
|
|
326 |
return buff.toString(); |
|
327 |
} |
|
328 |
|
|
329 |
/** |
|
330 |
* dump the result in the console. |
|
331 |
* |
|
332 |
* @param maxvalue |
|
333 |
* the maxvalue |
|
334 |
* @return the string |
|
335 |
*/ |
|
336 |
public String dump(int maxvalue) { |
|
337 |
StringBuffer buff = new StringBuffer(); |
|
338 |
|
|
339 |
buff.append(PropertiesCoreMessages.generalStatistics); |
|
340 |
buff.append(PropertiesCoreMessages.t + String.format(Locale.FRANCE, "%,d", numberOfWords) + "\n"); //$NON-NLS-1$ |
|
341 |
buff.append(PropertiesCoreMessages.wordProperties + String.format("%,d", NProperties) + "\n"); //$NON-NLS-1$ |
|
342 |
/* |
|
343 |
* for (String s : propertiesCounts.keySet()) if (!s.equals("id")) //$NON-NLS-1$ |
|
344 |
* buff.append(" - " + s + " " + propertiesCounts.get(s) + "\n"); //$NON-NLS-1$ |
|
345 |
* //$NON-NLS-2$ //$NON-NLS-3$ |
|
346 |
*/ |
|
347 |
buff.append(PropertiesCoreMessages.s + String.format("%,d", NStructures) + "\n"); //$NON-NLS-1$ |
|
348 |
for (String s : structuresCounts.keySet()) |
|
349 |
buff.append(" - " + s + "\n");// +structuresCounts.get(s)+"\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
350 |
|
|
351 |
/* |
|
352 |
* buff.append("* Structural Units counts\n"); for(String s : |
|
353 |
* internalArchitecture) buff.append(" - "+s+" "+hierarchieCounts.get(s)+"\n"); |
|
354 |
*/ |
|
355 |
buff.append(PropertiesCoreMessages.structuralUnitsProperties); |
|
356 |
for (String s : internalArchitecture) { |
|
357 |
buff.append(" - " + s + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
358 |
for (String ps : internalArchitectureProperties.get(s).keySet()) { |
|
359 |
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$ |
|
360 |
{ |
|
361 |
buff.append(" - " + ps + "(" + internalArchitectureProperties.get(s).get(ps).size() + ") = "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
362 |
|
|
363 |
int valuecount = 0; |
|
364 |
for (String psv : internalArchitectureProperties.get(s).get(ps)) { |
|
365 |
buff.append(psv); |
|
366 |
if (valuecount++ >= maxvalue) { |
|
367 |
buff.append("..."); //$NON-NLS-1$ |
|
368 |
break; |
|
369 |
} |
|
370 |
if (valuecount < internalArchitectureProperties.get(s).get(ps).size()) |
|
371 |
buff.append(", "); //$NON-NLS-1$ |
|
372 |
} |
|
373 |
|
|
374 |
buff.append("\n"); //$NON-NLS-1$ |
|
375 |
} |
|
376 |
} |
|
377 |
} |
|
378 |
|
|
379 |
return buff.toString(); |
|
380 |
} |
|
381 |
|
|
382 |
|
|
383 |
/** |
|
384 |
* Gets the t. |
|
385 |
* |
|
386 |
* @return the t |
|
387 |
*/ |
|
388 |
public int getT() { |
|
389 |
return numberOfWords; |
|
390 |
} |
|
391 |
|
|
392 |
/** |
|
393 |
* Gets the n properties. |
|
394 |
* |
|
395 |
* @return the n properties |
|
396 |
*/ |
|
397 |
public int getNProperties() { |
|
398 |
return NProperties; |
|
399 |
} |
|
400 |
|
|
401 |
/** |
|
402 |
* Gets the internal architecture. |
|
403 |
* |
|
404 |
* @return the internal architecture |
|
405 |
*/ |
|
406 |
public List<String> getInternalArchitecture() { |
|
407 |
return internalArchitecture; |
|
408 |
} |
|
409 |
|
|
410 |
/** |
|
411 |
* Gets the n structures. |
|
412 |
* |
|
413 |
* @return the n structures |
|
414 |
*/ |
|
415 |
public int getNStructures() { |
|
416 |
return NStructures; |
|
417 |
} |
|
418 |
|
|
419 |
/** |
|
420 |
* Gets the structures counts. |
|
421 |
* |
|
422 |
* @return the structures counts |
|
423 |
*/ |
|
424 |
public HashMap<String, Integer> getStructuresCounts() { |
|
425 |
return structuresCounts; |
|
426 |
} |
|
427 |
|
|
428 |
/** |
|
429 |
* Gets the annotations types. |
|
430 |
* |
|
431 |
* @return the annotations types |
|
432 |
*/ |
|
433 |
public HashMap<String, Integer> getAnnotationsTypes() { |
|
434 |
return annotationsTypes; |
|
435 |
} |
|
436 |
|
|
437 |
/** |
|
438 |
* Gets the annotations origins. |
|
439 |
* |
|
440 |
* @return the annotations origins |
|
441 |
*/ |
|
442 |
public HashMap<String, Integer> getAnnotationsOrigins() { |
|
443 |
return annotationsOrigins; |
|
444 |
} |
|
445 |
|
|
446 |
@Override |
|
447 |
public boolean _compute(IProgressMonitor monitor) throws Exception { |
|
448 |
|
|
449 |
if (monitor != null) monitor.beginTask(props.getComputingStartMessage(), 3); |
|
450 |
this.stepGeneralInfos(); |
|
451 |
if (monitor != null) monitor.worked(1); |
|
452 |
|
|
453 |
this.stepLexicalProperties(); |
|
454 |
if (monitor != null) monitor.worked(1); |
|
455 |
|
|
456 |
this.stepStructuralUnits(); |
|
457 |
if (monitor != null) monitor.worked(1); |
|
458 |
return true; |
|
459 |
} |
|
460 |
|
|
461 |
public String getDetails() { |
|
462 |
if (numberOfWords >= 0) { |
|
463 |
return NLS.bind(PropertiesCoreMessages.numberOfWordsP0, numberOfWords); |
|
464 |
} else { |
|
465 |
return ""; |
|
466 |
} |
|
467 |
} |
|
468 |
} |
|
0 | 469 |
tmp/org.txm.properties.core/src/org/txm/properties/core/functions/PropertiesComputer.java (revision 2247) | ||
---|---|---|
1 |
package org.txm.properties.core.functions; |
|
2 |
|
|
3 |
import java.util.LinkedHashMap; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
7 |
import org.txm.core.results.TXMResult; |
|
8 |
|
|
9 |
/** |
|
10 |
* Properties use this existing class implementations to retrieve informations to show |
|
11 |
* @author mdecorde |
|
12 |
* |
|
13 |
*/ |
|
14 |
public abstract class PropertiesComputer<T extends TXMResult> { |
|
15 |
|
|
16 |
protected T result; |
|
17 |
protected Properties props; |
|
18 |
|
|
19 |
public PropertiesComputer(Properties props, T result) { |
|
20 |
this.result = result; |
|
21 |
this.props = props; |
|
22 |
} |
|
23 |
|
|
24 |
/** |
|
25 |
* The ordered list of informations to display |
|
26 |
* @return |
|
27 |
*/ |
|
28 |
public abstract List<String> getComputableInformations(); |
|
29 |
|
|
30 |
/** |
|
31 |
* raw informations |
|
32 |
* @param name |
|
33 |
* @return |
|
34 |
*/ |
|
35 |
public abstract LinkedHashMap<String, String> getInformation(String name); |
|
36 |
|
|
37 |
/** |
|
38 |
* HTML formated informations to insert a HTML element |
|
39 |
* @return |
|
40 |
*/ |
|
41 |
public abstract String getInformationHTML(String info); |
|
42 |
|
|
43 |
/** |
|
44 |
* if the PropertiesComputer needs to prepare informations or the compute the available informations |
|
45 |
* @return |
|
46 |
*/ |
|
47 |
public abstract boolean _compute(IProgressMonitor monitor) throws Exception; |
|
48 |
|
|
49 |
public String getName() { |
|
50 |
return result.getClass().getSimpleName()+"-"+result.getName(); |
|
51 |
} |
|
52 |
} |
|
0 | 53 |
tmp/org.txm.properties.core/src/org/txm/properties/core/functions/Properties.java (revision 2247) | ||
---|---|---|
30 | 30 |
import java.io.File; |
31 | 31 |
import java.io.IOException; |
32 | 32 |
import java.io.PrintWriter; |
33 |
import java.util.ArrayList; |
|
34 |
import java.util.Collections; |
|
35 |
import java.util.HashMap; |
|
36 |
import java.util.LinkedHashSet; |
|
33 |
import java.util.Arrays; |
|
34 |
import java.util.LinkedHashMap; |
|
37 | 35 |
import java.util.List; |
38 |
import java.util.Locale; |
|
39 | 36 |
|
40 |
import org.apache.commons.lang.StringUtils; |
|
41 |
import org.eclipse.osgi.util.NLS; |
|
37 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
42 | 38 |
import org.txm.Toolbox; |
43 | 39 |
import org.txm.core.messages.TXMCoreMessages; |
44 | 40 |
import org.txm.core.results.Parameter; |
45 | 41 |
import org.txm.core.results.TXMParameters; |
46 | 42 |
import org.txm.core.results.TXMResult; |
47 |
import org.txm.objects.Project; |
|
48 | 43 |
import org.txm.properties.core.messages.PropertiesCoreMessages; |
49 | 44 |
import org.txm.properties.core.preferences.PropertiesPreferences; |
50 |
import org.txm.searchengine.cqp.AbstractCqiClient; |
|
51 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
52 | 45 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
53 |
import org.txm.searchengine.cqp.corpus.CorpusManager; |
|
54 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
|
55 |
import org.txm.searchengine.cqp.corpus.Property; |
|
56 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
|
57 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
|
58 |
import org.txm.searchengine.cqp.corpus.WordProperty; |
|
59 | 46 |
import org.txm.utils.AsciiUtils; |
60 | 47 |
import org.txm.utils.io.IOUtils; |
61 |
import org.txm.utils.logger.Log; |
|
62 | 48 |
|
63 | 49 |
/** |
64 | 50 |
* Computes a diagnostic of Corpus or Subcorpus. |
... | ... | |
66 | 52 |
* @author mdecorde |
67 | 53 |
*/ |
68 | 54 |
public class Properties extends TXMResult { |
69 |
// Base base; |
|
70 |
/** The corpus. */ |
|
71 |
protected CQPCorpus corpus; |
|
72 | 55 |
|
73 |
// Numbers |
|
74 |
/** The T. */ |
|
75 |
int numberOfWords = 0; // number of word |
|
56 |
PropertiesComputer<? extends TXMResult> computer; |
|
76 | 57 |
|
77 |
/** The N properties. */ |
|
78 |
int NProperties = 0; // number of word properties |
|
79 |
// HashMap<String, Integer> propertiesCounts = new HashMap<String, Integer>(); |
|
80 |
// // properties counts |
|
81 |
/** The properties values. */ |
|
82 |
HashMap<String, List<String>> propertiesValues = new HashMap<String, List<String>>(); // properties values |
|
83 |
|
|
84 |
/** The N structures. */ |
|
85 |
int NStructures = 0; // number of structures |
|
86 |
|
|
87 |
/** The structures counts. */ |
|
88 |
HashMap<String, Integer> structuresCounts = new HashMap<String, Integer>(); // structures counts |
|
89 |
|
|
90 |
/** The internal architecture. */ |
|
91 |
List<String> internalArchitecture = new ArrayList<String>(); // cqp structures = propertiesCounts keys but ordered |
|
92 |
|
|
93 |
/** The hierarchie counts. */ |
|
94 |
HashMap<String, Integer> hierarchieCounts = new HashMap<String, Integer>(); // hierarchic structures counts |
|
95 |
|
|
96 |
/** The internal architecture properties. */ |
|
97 |
HashMap<String, HashMap<String, List<String>>> internalArchitectureProperties = new HashMap<String, HashMap<String, List<String>>>(); // hierarchic structures counts |
|
98 |
|
|
99 |
/** The internal architecture properties counts. */ |
|
100 |
HashMap<String, HashMap<String, Integer>> internalArchitecturePropertiesCounts = new HashMap<String, HashMap<String, Integer>>(); // hierarchic structures counts |
|
101 |
|
|
102 |
// Annotations description |
|
103 |
/** The annotations types. */ |
|
104 |
HashMap<String, Integer> annotationsTypes = new HashMap<String, Integer>(); // for each annotation its description |
|
105 |
|
|
106 |
/** The annotations origins. */ |
|
107 |
HashMap<String, Integer> annotationsOrigins = new HashMap<String, Integer>(); // for each annoation its origin description |
|
108 |
|
|
109 |
/** The properties. */ |
|
110 |
List<WordProperty> properties; |
|
111 |
|
|
112 |
/** The structures. */ |
|
113 |
List<StructuralUnit> structures; |
|
114 |
|
|
115 | 58 |
/** |
116 | 59 |
* The HTML file. |
117 | 60 |
*/ |
... | ... | |
126 | 69 |
/** |
127 | 70 |
* Instantiates a new corpus Properties. |
128 | 71 |
* |
129 |
* @param corpus
|
|
72 |
* @param selection
|
|
130 | 73 |
* a MainCorpus or a SubCorpus |
131 | 74 |
*/ |
132 |
public Properties(CQPCorpus corpus) { |
|
133 |
super(corpus); |
|
75 |
public Properties(TXMResult selection) { |
|
76 |
super(selection); |
|
77 |
|
|
78 |
if (selection instanceof CQPCorpus) { |
|
79 |
computer = new CorpusPropertiesComputer(this, (CQPCorpus)selection); |
|
80 |
} else { |
|
81 |
computer = new PropertiesComputer<TXMResult>(this, selection) { |
|
82 |
|
|
83 |
@Override |
|
84 |
public List getComputableInformations() { |
|
85 |
return Arrays.asList("details"); |
|
86 |
} |
|
87 |
|
|
88 |
@Override |
|
89 |
public LinkedHashMap<String, String> getInformation(String name) { |
|
90 |
LinkedHashMap<String, String> data = new LinkedHashMap<String, String>(); |
|
91 |
data.put("details", result.getDetails()); |
|
92 |
return data; |
|
93 |
} |
|
94 |
|
|
95 |
@Override |
|
96 |
public String getInformationHTML(String info) { |
|
97 |
return result.getDetails(); |
|
98 |
} |
|
99 |
|
|
100 |
@Override |
|
101 |
public boolean _compute(IProgressMonitor monitor) throws Exception{ |
|
102 |
return true; |
|
103 |
} |
|
104 |
}; |
|
105 |
} |
|
134 | 106 |
} |
135 | 107 |
|
136 | 108 |
/** |
... | ... | |
141 | 113 |
super(parametersNodePath); |
142 | 114 |
} |
143 | 115 |
|
116 |
/** |
|
117 |
* |
|
118 |
* @param parametersNodePath |
|
119 |
*/ |
|
120 |
public Properties(String parametersNodePath, TXMResult selection) { |
|
121 |
super(parametersNodePath, selection); |
|
122 |
} |
|
123 |
|
|
144 | 124 |
@Override |
145 | 125 |
public boolean loadParameters() { |
146 |
this.corpus = (CQPCorpus) this.parent; |
|
147 | 126 |
return true; |
148 | 127 |
} |
149 | 128 |
|
... | ... | |
160 | 139 |
this.dirty = true; |
161 | 140 |
} |
162 | 141 |
|
163 |
/** |
|
164 |
* Step general infos. |
|
165 |
*/ |
|
166 |
public void stepGeneralInfos() { |
|
167 |
try { |
|
168 |
properties = corpus.getProperties(); |
|
169 |
List<WordProperty> pproperties = new ArrayList<WordProperty>(properties); |
|
170 |
for (WordProperty p : properties) { |
|
171 |
if (p.getName().equals("id")) { |
|
172 |
pproperties.remove(p); |
|
173 |
} |
|
174 |
} |
|
175 |
properties = pproperties; |
|
176 |
NProperties = properties.size(); |
|
177 |
} catch (CqiClientException e) { |
|
178 |
Log.severe(TXMCoreMessages.bind(PropertiesCoreMessages.error_failedToAccessPropertieOfCorpusP0, corpus.getName())); |
|
179 |
Log.printStackTrace(e); |
|
180 |
return; |
|
181 |
} |
|
182 | 142 |
|
183 |
try { |
|
184 |
numberOfWords = corpus.getSize();// corpus.getLexicon(corpus.getProperty("id")).nbrOfToken(); |
|
185 |
} catch (CqiClientException e) { |
|
186 |
Log.severe(TXMCoreMessages.bind(PropertiesCoreMessages.error_failedToAccessLexiconOfCorpusP0, corpus.getName())); |
|
187 |
Log.printStackTrace(e); |
|
188 |
return; |
|
189 |
} |
|
190 |
} |
|
191 | 143 |
|
192 |
/** |
|
193 |
* step2. randomly position are choose |
|
194 |
*/ |
|
195 |
public void stepLexicalProperties() { |
|
196 |
propertiesValues.clear(); |
|
197 |
|
|
198 |
AbstractCqiClient cqiClient = CorpusManager.getCorpusManager().getCqiClient(); |
|
199 |
for (Property p : properties) { |
|
200 |
// int size; |
|
201 |
try { |
|
202 |
// size = |
|
203 |
// CorpusManager.getCorpusManager().getCqiClient().lexiconSize(p.getQualifiedName()); |
|
204 |
// propertiesCounts.put(p.getName(), size); |
|
205 |
// List<String> list = |
|
206 |
// Arrays.asList(corpus.getLexicon(p).getForms(this.maxvalue)); |
|
207 |
|
|
208 |
int[] positions = new int[Math.min(pMaxPropertiesToDisplay, numberOfWords)]; |
|
209 |
for (int i = 0; i < Math.min(pMaxPropertiesToDisplay, numberOfWords); i++) { |
|
210 |
positions[i] = i; |
|
211 |
} |
|
212 |
|
|
213 |
// ArrayList<String> values = new ArrayList<String>(); |
|
214 |
LinkedHashSet<String> values = new LinkedHashSet<String>(cqiClient.getSingleData(p, positions)); |
|
215 |
propertiesValues.put(p.getName(), new ArrayList<String>(values)); |
|
216 |
} catch (Exception e) { |
|
217 |
Log.printStackTrace(e); |
|
218 |
} |
|
219 |
} |
|
220 |
} |
|
221 |
|
|
222 |
/** |
|
223 |
* Step structural units. |
|
224 |
*/ |
|
225 |
public void stepStructuralUnits() { |
|
226 |
try { |
|
227 |
structures = corpus.getOrderedStructuralUnits(); |
|
228 |
|
|
229 |
List<StructuralUnit> sstructures = new ArrayList<StructuralUnit>(structures); |
|
230 |
for (StructuralUnit su : structures) { |
|
231 |
if (su.getName().equals("txmcorpus")) { |
|
232 |
sstructures.remove(su); |
|
233 |
} |
|
234 |
} |
|
235 |
structures = sstructures; |
|
236 |
|
|
237 |
} catch (CqiClientException e) { |
|
238 |
Log.severe(TXMCoreMessages.bind(PropertiesCoreMessages.error_failedToAccessStructuresOfCorpusP0, corpus.getName())); |
|
239 |
Log.printStackTrace(e); |
|
240 |
return; |
|
241 |
} |
|
242 |
NStructures = structures.size(); |
|
243 |
internalArchitecture.clear(); |
|
244 |
for (StructuralUnit su : structures) { // for each structural unit |
|
245 |
internalArchitecture.add(su.getName()); |
|
246 |
hierarchieCounts.put(su.getName(), -1); |
|
247 |
internalArchitectureProperties.put(su.getName(), new HashMap<String, List<String>>()); |
|
248 |
internalArchitecturePropertiesCounts.put(su.getName(), new HashMap<String, Integer>()); |
|
249 |
|
|
250 |
if (su.getProperties().size() > 0) { |
|
251 |
for (StructuralUnitProperty sup : su.getProperties()) {// for each of its property |
|
252 |
try { |
|
253 |
List<String> allvalues = sup.getValues(corpus); |
|
254 |
internalArchitectureProperties.get(su.getName()).put(sup.getName(), allvalues.subList(0, Math.min(allvalues.size(), pMaxPropertiesToDisplay))); |
|
255 |
internalArchitecturePropertiesCounts.get(su.getName()).put(sup.getName(), allvalues.size()); |
|
256 |
} catch (Exception e) { |
|
257 |
ArrayList<String> list = new ArrayList<String>(1); |
|
258 |
list.add(PropertiesCoreMessages.error); |
|
259 |
internalArchitectureProperties.get(su.getName()).put(sup.getName(), list); |
|
260 |
internalArchitecturePropertiesCounts.get(su.getName()).put(sup.getName(), -1); |
|
261 |
} |
|
262 |
} |
|
263 |
} |
|
264 |
} |
|
265 |
} |
|
266 |
|
|
267 | 144 |
// FIXME: useless? |
268 | 145 |
// /** |
269 | 146 |
// * Instantiates a new diagnostic. |
... | ... | |
288 | 165 |
// } |
289 | 166 |
// } |
290 | 167 |
|
291 |
/** |
|
292 |
* dump the results of the diagnostic in a String containing HTML code. |
|
293 |
* |
|
294 |
* @return the string |
|
295 |
*/ |
|
296 | 168 |
public String htmlDump() { |
297 |
StringBuffer buff = new StringBuffer(); |
|
298 |
|
|
299 |
buff.append("<? version=\"1.0\" encoding=\"UTF-8\"?>\n" + //$NON-NLS-1$ |
|
300 |
"<html>" + //$NON-NLS-1$ |
|
301 |
"<head>" + //$NON-NLS-1$ |
|
302 |
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>" + //$NON-NLS-1$ |
|
303 |
"</head>" + //$NON-NLS-1$ |
|
304 |
"<body>\n"); //$NON-NLS-1$ |
|
305 |
buff.append("<h2 style'font-family:\"Arial\";'>" + PropertiesCoreMessages.descriptionOf + this.corpus.getName() + " (id=" + this.corpus.getID() + ")</h2>\n"); //$NON-NLS-2$ //$NON-NLS-1$ |
|
306 |
|
|
307 |
Project projet = this.corpus.getProject(); |
|
308 |
if (projet.getCreationDate() != null) { |
|
309 |
buff.append(NLS.bind(PropertiesCoreMessages.createdTheP0, TXMResult.PRETTY_LOCALIZED_TIME_FORMAT.format(projet.getCreationDate()))); |
|
169 |
StringBuffer buffer = new StringBuffer(); |
|
170 |
for (String info : computer.getComputableInformations()) { |
|
171 |
buffer.append(computer.getInformationHTML(info)); |
|
310 | 172 |
} |
311 |
if (projet.getLastComputingDate() != null) { |
|
312 |
buff.append(NLS.bind(PropertiesCoreMessages.updatedTheP0, TXMResult.PRETTY_LOCALIZED_TIME_FORMAT.format(projet.getLastComputingDate()))); |
|
313 |
} |
|
314 |
|
|
315 |
if (projet.getDescription() != null && projet.getDescription().length() > 0) { |
|
316 |
buff.append("<p><h3>Description</h3>" + projet.getDescription() + "</p>"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
317 |
} |
|
318 |
|
|
319 |
buff.append("<h3 style'font-family:\"Arial\";'>" + PropertiesCoreMessages.generalStatistics_2 + "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
320 |
|
|
321 |
// counts |
|
322 |
buff.append("<ul>\n"); //$NON-NLS-1$ |
|
323 |
buff.append("<li>" + NLS.bind(PropertiesCoreMessages.numberOfWordsP0, numberOfWords) + "</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
324 |
|
|
325 |
buff.append("<li>" + PropertiesCoreMessages.numberOfWordProperties + (properties.size()) + " ("+StringUtils.join(properties, ", ")+")</li>\n"); //$NON-NLS-2$ //$NON-NLS-1$ |
|
326 |
buff.append("<li>" + PropertiesCoreMessages.numberOfStructuralUnits + (structures.size()) + " ("+StringUtils.join(structures, ", ")+")</li>\n"); //$NON-NLS-2$ //$NON-NLS-1$ |
|
327 |
buff.append("</ul>\n"); //$NON-NLS-1$ |
|
328 |
|
|
329 |
// Propriétés d'occurrences |
|
330 |
buff.append("<h3 style'font-family:\"Arial\";'>" + NLS.bind(PropertiesCoreMessages.lexicalUnitsPropertiesMaxP0Values, pMaxPropertiesToDisplay) + "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
331 |
ArrayList<String> properties = new ArrayList<String>(propertiesValues.keySet()); |
|
332 |
Collections.sort(properties); |
|
333 |
buff.append("<ul>\n"); //$NON-NLS-1$ |
|
334 |
for (String s : properties) { |
|
335 |
if (!s.equals("id")) { //$NON-NLS-1$ |
|
336 |
// buff.append("<li> " + s + " (" + propertiesCounts.get(s) + ") : "); |
|
337 |
// //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
338 |
buff.append("<li> " + s + " : "); //$NON-NLS-1$ //$NON-NLS-2$ |
|
339 |
for (String v : propertiesValues.get(s)) |
|
340 |
buff.append(v + ", "); //$NON-NLS-1$ |
|
341 |
if (propertiesValues.get(s).size() >= this.pMaxPropertiesToDisplay) { |
|
342 |
buff.append("..."); //$NON-NLS-1$ |
|
343 |
} |
|
344 |
buff.append("</li>\n"); //$NON-NLS-1$ |
|
345 |
} |
|
346 |
} |
|
347 |
buff.append("</ul>\n"); //$NON-NLS-1$ |
|
348 |
|
|
349 |
// Propriété de structures |
|
350 |
buff.append("<h3 style'font-family:\"Arial\";'>" + NLS.bind(PropertiesCoreMessages.structuralUnitsPropertiesMaxP0Values, pMaxPropertiesToDisplay) + "</h3>\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
351 |
buff.append("<ul>\n"); //$NON-NLS-1$ |
|
352 |
for (String s : internalArchitecture) { |
|
353 |
StringBuffer subbuffer = new StringBuffer(); |
|
354 |
if (s.equals("txmcorpus")) //$NON-NLS-1$ |
|
355 |
continue;// ignore the txmcorpus structure |
|
356 |
|
|
357 |
properties = new ArrayList<String>(internalArchitectureProperties.get(s).keySet()); |
|
358 |
|
|
359 |
subbuffer.append("<li> " + s + "\n<ul>\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
360 |
if (internalArchitectureProperties.get(s).keySet().size() == 0) |
|
361 |
subbuffer.append("<li>" + PropertiesCoreMessages.noProperty + "</li>\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
362 |
|
|
363 |
// System.out.println("struct: "+s+" >> "+properties); |
|
364 |
Collections.sort(properties); |
|
365 |
// System.out.println("struct: "+s+" >sort> "+properties); |
|
366 |
int nbOfValues = 0; |
|
367 |
for (String ps : properties) { |
|
368 |
if (!ps.equals("project") && !ps.equals("base")) //$NON-NLS-1$ //$NON-NLS-2$ |
|
369 |
{ |
|
370 |
// System.out.println("struct: "+s+" >> "+ps); |
|
371 |
int valuecount = internalArchitecturePropertiesCounts.get(s).get(ps); |
|
372 |
ArrayList<String> values = new ArrayList<String>(internalArchitectureProperties.get(s).get(ps)); |
|
373 |
subbuffer.append("<li> " + ps + " (" + valuecount + ") = "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
374 |
// System.out.println("VALUES: "+values); |
|
375 |
Collections.sort(values); |
|
376 |
for (int i = 0; i < values.size(); i++) { |
|
377 |
nbOfValues++; |
|
378 |
String psv = values.get(i); |
|
379 |
if (psv != null && psv.length() > 0) |
|
380 |
subbuffer.append(psv.replace("<", "<")); //$NON-NLS-1$ //$NON-NLS-2$ |
|
381 |
else |
|
382 |
subbuffer.append("\"\""); //$NON-NLS-1$ |
|
383 |
|
|
384 |
if (i == values.size() - 1) |
|
385 |
subbuffer.append("."); //$NON-NLS-1$ |
|
386 |
else |
|
387 |
subbuffer.append(", "); //$NON-NLS-1$ |
|
388 |
|
|
389 |
if (i >= pMaxPropertiesToDisplay) { |
|
390 |
subbuffer.append("..."); //$NON-NLS-1$ |
|
391 |
break; |
|
392 |
} |
|
393 |
} |
|
394 |
subbuffer.append("</li>\n"); //$NON-NLS-1$ |
|
395 |
} |
|
396 |
} |
|
397 |
|
|
398 |
if (properties.size() == 0) { |
|
399 |
subbuffer.append("<p>--</p>\n"); //$NON-NLS-1$ |
|
400 |
} |
|
401 |
|
|
402 |
subbuffer.append("</ul>\n</li>\n"); //$NON-NLS-1$ |
|
403 |
if (nbOfValues > 0) { |
|
404 |
buff.append(subbuffer); |
|
405 |
} |
|
406 |
} |
|
407 |
buff.append("</ul>\n"); //$NON-NLS-1$ |
|
408 |
buff.append("</body>\n"); //$NON-NLS-1$ |
|
409 |
buff.append("</html>\n"); //$NON-NLS-1$ |
|
410 |
|
|
411 |
return buff.toString(); |
|
173 |
return buffer.toString(); |
|
412 | 174 |
} |
413 | 175 |
|
414 |
/** |
|
415 |
* dump the result in the console. |
|
416 |
* |
|
417 |
* @param maxvalue |
|
418 |
* the maxvalue |
|
419 |
* @return the string |
|
420 |
*/ |
|
421 | 176 |
public String dump(int maxvalue) { |
422 |
StringBuffer buff = new StringBuffer(); |
|
423 |
|
|
424 |
buff.append(PropertiesCoreMessages.generalStatistics); |
|
425 |
buff.append(PropertiesCoreMessages.t + String.format(Locale.FRANCE, "%,d", numberOfWords) + "\n"); //$NON-NLS-1$ |
|
426 |
buff.append(PropertiesCoreMessages.wordProperties + String.format("%,d", NProperties) + "\n"); //$NON-NLS-1$ |
|
427 |
/* |
|
428 |
* for (String s : propertiesCounts.keySet()) if (!s.equals("id")) //$NON-NLS-1$ |
|
429 |
* buff.append(" - " + s + " " + propertiesCounts.get(s) + "\n"); //$NON-NLS-1$ |
|
430 |
* //$NON-NLS-2$ //$NON-NLS-3$ |
|
431 |
*/ |
|
432 |
buff.append(PropertiesCoreMessages.s + String.format("%,d", NStructures) + "\n"); //$NON-NLS-1$ |
|
433 |
for (String s : structuresCounts.keySet()) |
|
434 |
buff.append(" - " + s + "\n");// +structuresCounts.get(s)+"\n"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
435 |
|
|
436 |
/* |
Formats disponibles : Unified diff