Commit 6ecd36d8 authored by Christos Christodoulopoulos's avatar Christos Christodoulopoulos
Browse files

Added annotation position indicator

Shows the position of the current annotation with respect to the rest of the annotations of the current utterance
parent 909bd7f0
No preview for this file type
......@@ -271,6 +271,16 @@ public class JBCorpus {
return contextToAnnotation.get(contextInd);
}
public int getAnnotationPosition(JBDataStructure annotation) {
List<JBDataStructure> otherAnnotations = getAnnotationsFromContext(annotation.getIndexInContext());
int position = 0;
for (JBDataStructure other : otherAnnotations) {
position++;
if (other.getPredicateIndex() == annotation.getPredicateIndex()) break;
}
return position;
}
public boolean isAnnotationFinished() {
return annotationFinished;
}
......
......@@ -239,7 +239,7 @@ public class JBToolkit extends JFrame implements ActionListener, ItemListener, L
lm_gold = new DefaultListModel<String>();
ls_gold = new JList<String>(lm_gold);
ls_gold.setFont(new Font("Courier", Font.PLAIN, 12));
ls_gold.setFont(new Font("Courier", Font.PLAIN, 11));
ls_gold.addListSelectionListener(this);
ls_gold.setVisibleRowCount(4);
ls_gold.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
......@@ -364,8 +364,11 @@ public class JBToolkit extends JFrame implements ActionListener, ItemListener, L
checkboxApprove.setSelected(false);
corpus.backup(corpus.getCurrentAnnotation());
updateAll();
updateGoldList();
}
if (isGold()) {
updateGoldList();
updateGoldTopList();
}
}
}
public void valueChanged(ListSelectionEvent e) {
......@@ -377,8 +380,11 @@ public class JBToolkit extends JFrame implements ActionListener, ItemListener, L
corpus.copyCurrent(alignedAnnotation);
corpus.getCurrentAnnotation().setAnnotator(DataManager.GOLD_ID);
corpus.getCurrentAnnotation().hasChanged(true);
updateGoldTopList();
updateAll();
if (isGold()) {
updateGoldList();
updateGoldTopList();
}
}
}
......@@ -432,27 +438,34 @@ public class JBToolkit extends JFrame implements ActionListener, ItemListener, L
}
private void updateGoldList() {
if (isGold()) {
lm_gold.removeAllElements();
int maxLength = maxAnnotationLength();
JBDataStructure annotation = corpus.getCurrentAnnotation();
lm_gold.addElement(StringManager.addIndent("GOLD", 12) +
StringManager.addIndent(annotation.getPropbankTree(), maxLength + 3) +
annotation.getTbTree().toTextTreeCompact());
for (JBCorpus otherCorpus : moreCorpora) {
JBDataStructure otherAnnotation = findAlignedAnnotation(otherCorpus, annotation);
// Check for deleted annotations
if (otherAnnotation == null) {
lm_gold.addElement(GOLD_MISSING);
}
else {
lm_gold.addElement(StringManager.addIndent(otherAnnotation.getAnnotator(), 12) +
StringManager.addIndent(otherAnnotation.getPropbankTree(), maxLength + 3) +
otherAnnotation.getTbTree().toTextTreeCompact());
}
lm_gold.removeAllElements();
int maxLength = maxAnnotationLength();
JBDataStructure annotation = corpus.getCurrentAnnotation();
lm_gold.addElement(StringManager.addIndent("GOLD", 12) +
StringManager.addIndent(annotation.getPropbankTree(), maxLength + 3) +
annotation.getTbTree().toTextTreeCompact());
for (JBCorpus otherCorpus : moreCorpora) {
JBDataStructure otherAnnotation = findAlignedAnnotation(otherCorpus, annotation);
// Check for deleted annotations
if (otherAnnotation == null) {
lm_gold.addElement(GOLD_MISSING);
}
else {
lm_gold.addElement(StringManager.addIndent(otherAnnotation.getAnnotator(), 12) +
StringManager.addIndent(otherAnnotation.getPropbankTree(), maxLength + 3) +
otherAnnotation.getTbTree().toTextTreeCompact());
}
ls_gold.invalidate();
}
ls_gold.invalidate();
}
public void updateGoldTopList() {
int maxLength = maxAnnotationLength();
JBDataStructure annotation = corpus.getCurrentAnnotation();
lm_gold.setElementAt(StringManager.addIndent("GOLD", 12) +
StringManager.addIndent(annotation.getPropbankTree(), maxLength + 3) +
annotation.getTbTree().toTextTreeCompact(), 0);
ls_gold.invalidate();
}
private JBDataStructure findAlignedAnnotation(JBCorpus otherCorpus, JBDataStructure annotation) {
......@@ -479,17 +492,6 @@ public class JBToolkit extends JFrame implements ActionListener, ItemListener, L
return max;
}
void updateGoldTopList() {
if (isGold()) {
int maxLength = maxAnnotationLength();
JBDataStructure annotation = corpus.getCurrentAnnotation();
lm_gold.setElementAt(StringManager.addIndent("GOLD", 12) +
StringManager.addIndent(annotation.getPropbankTree(), maxLength + 3) +
annotation.getTbTree().toTextTreeCompact(), 0);
ls_gold.invalidate();
}
}
private void actionButtonTreeEdit() {
new JBTreeEditPanel(this, corpus.getCurrentAnnotation());
}
......@@ -569,8 +571,11 @@ public class JBToolkit extends JFrame implements ActionListener, ItemListener, L
for (int i = 0; i < corpus.getSize(); i++) {
JBDataStructure annotation = corpus.getAnnotation(i);
String contextId = corpus.getContext(annotation.getIndexInContext());
int annotationPosition = corpus.getAnnotationPosition(annotation);
int totalSentAnnotations = corpus.getAnnotationsFromContext(annotation.getIndexInContext()).size();
String predicate = annotation.getRoleset().split("\\.")[0];
String item = contextId.substring(0, contextId.indexOf(":")) + " - " + predicate;
item += " [" + annotationPosition + "/" + totalSentAnnotations + "]";
if (showIDs) item = "(" + i + ") " + item;
comboJump.insertItemAt(item, i);
}
......@@ -751,27 +756,23 @@ public class JBToolkit extends JFrame implements ActionListener, ItemListener, L
new JOptionPane().showMessageDialog(this, msg, "About", JOptionPane.INFORMATION_MESSAGE);
}
public String getTerminalsList() {
public String getListStr(ArrayList<String[]> items) {
String listStr = "";
for (String[] strings : terminalsList) {
for (String[] strings : items) {
listStr += strings[0] + "\t" + strings[1] + " ";
if (strings.length > 2) {
for (int i = 2; i < strings.length; i++) listStr += strings[i] + " ";
}
listStr = listStr.trim() + "\n";
}
return listStr;
return listStr.trim();
}
public String getTerminalsList() {
return getListStr(terminalsList);
}
public String getNonTerminalsList() {
String listStr = "";
for (String[] strings : nonTerminalsList) {
listStr += strings[0] + "\t" + strings[1] + " ";
if (strings.length > 2) {
for (int i = 2; i < strings.length; i++) listStr += strings[i] + " ";
}
listStr = listStr.trim() + "\n";
}
return listStr.trim();
return getListStr(nonTerminalsList);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment