Skip to content

Commit

Permalink
Merge branch 'release/2.1.0'
Browse files Browse the repository at this point in the history
* release/2.1.0:
  Updated changelog
  2.1.0 and updated Changelog
  Fix #380
  Downgrade slf4j-nop to match managed version of log4j
  Fix reflection warning by adding multi-release manifest entry
  Fix #381
  Implement CSV export for ExportMultipleFiles tool
  Update dependencies
  Use Java 11 and fix duplicate dependencies appropriately
  • Loading branch information
nilsreiter committed Apr 8, 2022
2 parents 088d6a9 + f798114 commit b3f2db8
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 83 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
Issue numbers (e.g., #43) refer to GitHub issues:
https://github.com/nilsreiter/CorefAnnotator/issues

## 2.1.0

- New: Multiple files can be exported at once into CSV format #370
- Fixes an issue that made deleted annotations to re-appear if the file is re-opened #380
- Fixes an issue that caused a freeze when deleting an annotation #381
- Updated some dependencies

Thanks Börge for taking care of these!

## 2.0.1

- Fixes an issue that prevented expanding the tree properly in some imported files #373
Expand Down
39 changes: 29 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.unistuttgart.ims</groupId>
<artifactId>coref.annotator</artifactId>
<version>2.0.1</version>
<version>2.1.0</version>
<packaging>jar</packaging>
<name>CorefAnnotator</name>
<url>https://github.com/nilsreiter/CorefAnnotator/</url>
Expand All @@ -13,12 +13,18 @@
<version.dkpro>2.2.0</version.dkpro>
<version.ikonli>12.2.0</version.ikonli>
<version.eclipse>10.2.0</version.eclipse>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<version.javafx>14.0.2.1</version.javafx>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.uima</groupId>
<artifactId>jcasgen-maven-plugin</artifactId>
Expand Down Expand Up @@ -80,6 +86,7 @@
<manifestEntries>
<Main-Class>de.unistuttgart.ims.coref.annotator.Annotator</Main-Class>
<Build-Number>${project.version}</Build-Number>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</transformer>
<transformer
Expand Down Expand Up @@ -436,7 +443,7 @@
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.12</version>
<version>0.10.2</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down Expand Up @@ -471,16 +478,22 @@
<dependency>
<groupId>org.dkpro.core</groupId>
<artifactId>dkpro-core-stanfordnlp-gpl</artifactId>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20151123</version>
<version>20210307</version>
</dependency>
<dependency>
<groupId>de.unistuttgart.ims.uima.io</groupId>
<artifactId>generic-xml-reader</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.lexicalscope.jewelcli</groupId>
Expand All @@ -490,7 +503,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.4.4</version>
<version>4.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -506,12 +519,18 @@
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
<version>5.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
<version>5.1.0</version>
<exclusions>
<exclusion>
<artifactId>xml-apis</artifactId>
<groupId>xml-apis</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.knowm.xchart</groupId>
Expand All @@ -521,7 +540,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.8</version>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,7 @@ private MutableList<File> getRecentFilesFromPreferences() {

private void recentFiles2Preferences(MutableList<File> recentFiles) {
StringBuilder sb = new StringBuilder();
for (int index = 0; index < recentFiles.size(); index++) {
File file = recentFiles.get(index);
for (File file : recentFiles) {
if (sb.length() > 0) {
sb.append(File.pathSeparator);
}
Expand All @@ -481,7 +480,6 @@ public JMenu getRecentFilesMenu() {
for (int i = 0; i < Math.min(20, recentFiles.size()); i++)
m.add(new SelectedFileOpenAction(this, recentFiles.get(i)));
return m;

}

public Preferences getPreferences() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1610,27 +1610,33 @@ protected JMenu getMentionItem(Mention m) {
StringBuilder b = new StringBuilder();
b.append(m.getAddress());

String surf = UimaUtil.getCoveredText(m);
surf = StringUtils.abbreviateMiddle(surf, "...", 20);

if (m.getEntity().getLabel() != null)
b.append(": ")
.append(StringUtils.abbreviateMiddle(
getDocumentModel().getCoreferenceModel().getLabel(m.getEntity()), "...",
Constants.UI_MAX_STRING_WIDTH_IN_MENU));

String mention = StringUtils
.abbreviateMiddle(UimaUtil.getCoveredText(m), "...", 20);

if (m.getEntity().getLabel() != null) {
String entity = StringUtils.abbreviateMiddle(
getDocumentModel().getCoreferenceModel().getLabel(m.getEntity()), "...",
Constants.UI_MAX_STRING_WIDTH_IN_MENU / 2);
b.append(String.format(": %s (%s)", mention, entity));
}

JMenu mentionMenu = new JMenu(b.toString());
mentionMenu.setIcon(FontIcon.of(MaterialDesign.MDI_ACCOUNT, new Color(m.getEntity().getColor())));
Action a = new ShowMentionInTreeAction(DocumentWindow.this, m);
mentionMenu.add('"' + surf + '"');
mentionMenu.add(String.format("\"%s\"", mention));
mentionMenu.getItem(mentionMenu.getItemCount() - 1).setEnabled(false);
mentionMenu.add(a);
mentionMenu.add(new DeleteAction(DocumentWindow.this, m));
if (m.getSurface().size() > 0)

if (m.getSurface().size() > 1) {
for (MentionSurface ms : m.getSurface()) {
JMenu mentionSurfaceMenu = new JMenu(StringUtils.abbreviateMiddle(ms.getCoveredText(), "...", 20));
JMenu mentionSurfaceMenu = new JMenu(StringUtils.abbreviateMiddle(
ms.getCoveredText(), "...",
Constants.UI_MAX_STRING_WIDTH_IN_MENU));
mentionSurfaceMenu.add(new DeleteAction(DocumentWindow.this, ms));
mentionMenu.add(mentionSurfaceMenu);
}
}

return mentionMenu;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected Entity createEntity(String l) {
e.setLabel(l);
e.setFlags(new EmptyFSList<Flag>(documentModel.getJcas()));
e.setMembers(new FSArray<Entity>(documentModel.getJcas(), 0));
e.addToIndexes();
e.addToIndexes(getJCas());
return e;
}

Expand Down Expand Up @@ -257,8 +257,8 @@ protected synchronized void edit(CoreferenceModelOperation operation) {
for (; i < arr.size(); i++) {
arr.set(i, newMembers.get(i - oldSize));
}
arr.addToIndexes();
op.getEntityGroup().removeFromIndexes();
arr.addToIndexes(getJCas());
op.getEntityGroup().removeFromIndexes(getJCas());
op.getEntityGroup().setMembers(arr);
updateEntityGroupLabel(op.getEntityGroup());
fireEvent(Event.get(this, Event.Type.Add, op.getEntityGroup(), op.getEntities()));
Expand Down Expand Up @@ -454,7 +454,7 @@ protected void edit(RemoveMentionSurface op) {
fireEvent(Event.get(this, Type.Remove, m, ms));
mentions.add(m);
spans.add(new Span(ms));
ms.removeFromIndexes();
ms.removeFromIndexes(getJCas());
characterPosition2AnnotationMap.remove(ms);
});
op.setMention(mentions.toImmutable());
Expand Down Expand Up @@ -737,7 +737,7 @@ public void initialPainting() {
}
for (Mention mention : JCasUtil.select(documentModel.getJcas(), Mention.class)) {
entityMentionMap.put(mention.getEntity(), mention);
mention.getEntity().addToIndexes();
mention.getEntity().addToIndexes(getJCas());
registerAnnotation(mention);
fireEvent(Event.get(this, Event.Type.Add, mention.getEntity(), mention));

Expand All @@ -763,7 +763,7 @@ private Entity merge(Iterable<Entity> nodes) {
entityMentionMap.get(n).toSet().forEach(m -> moveTo(tgt, m));

entityMentionMap.removeAll(n);
n.removeFromIndexes();
n.removeFromIndexes(getJCas());
}
}
return biggest;
Expand Down Expand Up @@ -809,7 +809,7 @@ private void remove(Entity entity) {
for (Mention m : entityMentionMap.get(entity)) {
for (MentionSurface ms : m.getSurface())
characterPosition2AnnotationMap.remove(ms);
m.removeFromIndexes();
m.removeFromIndexes(getJCas());
// TODO: remove parts
}
for (Entity group : entityEntityGroupMap.get(entity)) {
Expand All @@ -822,7 +822,7 @@ private void remove(Entity entity) {

fireEvent(Event.get(this, Event.Type.Remove, null, entity));
entityMentionMap.removeAll(entity);
entity.removeFromIndexes();
entity.removeFromIndexes(getJCas());
Annotator.logger.traceExit();
}

Expand All @@ -831,7 +831,7 @@ private void remove(Mention m, boolean autoRemove) {
for (MentionSurface ms : m.getSurface())
characterPosition2AnnotationMap.remove(ms);
entityMentionMap.remove(entity, m);
m.removeFromIndexes();
m.removeFromIndexes(getJCas());
if (autoRemove && entityMentionMap.get(entity).isEmpty() && getPreferences()
.getBoolean(Constants.CFG_DELETE_EMPTY_ENTITIES, Defaults.CFG_DELETE_EMPTY_ENTITIES)) {
remove(entity);
Expand Down Expand Up @@ -869,7 +869,7 @@ protected void undo(AddSpanToMention op) {
MentionSurface ms = op.getMentionSurface();
UimaUtil.removeMentionSurface(ms.getMention(), ms);
fireEvent(Event.get(this, Event.Type.Remove, ms.getMention(), ms));
ms.removeFromIndexes();
ms.removeFromIndexes(getJCas());
characterPosition2AnnotationMap.remove(ms);
}

Expand Down Expand Up @@ -933,7 +933,7 @@ protected void undo(CoreferenceModelOperation operation) {
RemoveDuplicateMentionsInEntities op = (RemoveDuplicateMentionsInEntities) operation;

op.getFeatureStructures().forEach(m -> {
m.addToIndexes();
m.addToIndexes(getJCas());
entityMentionMap.put(m.getEntity(), m);
registerAnnotation(m);
fireEvent(Event.get(this, Type.Add, m.getEntity(), m));
Expand All @@ -943,7 +943,7 @@ protected void undo(CoreferenceModelOperation operation) {
} else if (operation instanceof RemoveEntities) {
RemoveEntities op = (RemoveEntities) operation;
op.getFeatureStructures().forEach(e -> {
e.addToIndexes();
e.addToIndexes(getJCas());
if (op.entityEntityGroupMap.containsKey(e)) {
for (Entity group : op.entityEntityGroupMap.get(e)) {
group.setMembers(UimaUtil.addTo(documentModel.getJcas(), group.getMembers(), e));
Expand All @@ -967,15 +967,15 @@ protected void undo(CoreferenceModelOperation operation) {
}
op.getEntityGroup().setMembers(newArr);
updateEntityGroupLabel(op.getEntityGroup());
newArr.addToIndexes();
oldArr.removeFromIndexes();
newArr.addToIndexes(getJCas());
oldArr.removeFromIndexes(getJCas());
} else if (operation instanceof RemoveSingletons) {
undo((RemoveSingletons) operation);
} else if (operation instanceof MergeEntities) {
MergeEntities op = (MergeEntities) operation;
for (Entity oldEntity : op.getEntities()) {
if (op.getEntity() != oldEntity) {
oldEntity.addToIndexes();
oldEntity.addToIndexes(getJCas());
fireEvent(Event.get(this, Event.Type.Add, null, oldEntity));
for (Mention m : op.getPreviousState().get(oldEntity)) {
moveTo(oldEntity, m);
Expand Down Expand Up @@ -1008,13 +1008,13 @@ private void undo(DuplicateMentions op) {

private void undo(RemoveMention op) {
if (op.isEntityAutoDeleted()) {
op.getEntity().addToIndexes();
op.getEntity().addToIndexes(getJCas());
fireEvent(Event.get(this, Event.Type.Add, null, op.getEntity()));
}

// re-create all mentions and set them to the op
op.getFeatureStructures().forEach(m -> {
m.addToIndexes();
m.addToIndexes(getJCas());
m.setEntity(op.getEntity());
entityMentionMap.put(op.getEntity(), m);
for (MentionSurface ms : m.getSurface())
Expand All @@ -1038,13 +1038,13 @@ private void undo(RemoveMentionSurface op) {
}

private void undo(RemoveSingletons op) {
op.getFeatureStructures().forEach(e -> e.addToIndexes());
op.getFeatureStructures().forEach(e -> e.addToIndexes(getJCas()));
op.getMentions().forEach(m -> {
entityMentionMap.put(m.getEntity(), m);
for (MentionSurface ms : m.getSurface())
characterPosition2AnnotationMap.add(ms);
m.addToIndexes();
m.getEntity().addToIndexes();
m.addToIndexes(getJCas());
m.getEntity().addToIndexes(getJCas());
fireEvent(Event.get(this, Event.Type.Add, null, m.getEntity()));
fireEvent(Event.get(this, Event.Type.Add, m.getEntity(), m));
});
Expand Down Expand Up @@ -1076,7 +1076,7 @@ protected void undo(RenameAllEntities operation) {
*/
protected void undo(MergeMentions operation) {
operation.getMentions().forEach(m -> {
m.addToIndexes();
m.addToIndexes(getJCas());
entityMentionMap.put(operation.getNewMention().getEntity(), m);
fireEvent(Event.get(this, Type.Add, m.getEntity(), m));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ public void entityEvent(FeatureStructureEvent event) {
if (etn != null) {
etn.removeAllChildren();
removeNodeFromParent(etn);
etn.modify();
}
fsMap.remove(event.getArgument(i));
etn.modify();
}
optResort();
break;
Expand Down
Loading

0 comments on commit b3f2db8

Please sign in to comment.