From 07fdfee75f2b344942581eba269752efbed03020 Mon Sep 17 00:00:00 2001 From: bkis Date: Mon, 22 Nov 2021 16:23:49 +0100 Subject: [PATCH 1/9] Use Java 11 and fix duplicate dependencies appropriately Java 11 is a LTS version that's already 3 years old. It should be okay to expect at least Java 11. Also, the code already uses methods that were only introduced with Java 11 (e.g. String.isBlank()) and thus depends on it anyway. --- pom.xml | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index cffd1b03..715f4d82 100644 --- a/pom.xml +++ b/pom.xml @@ -13,12 +13,18 @@ 2.2.0 12.2.0 10.2.0 - 1.8 - 1.8 14.0.2.1 + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 11 + + org.apache.uima jcasgen-maven-plugin @@ -471,6 +477,12 @@ org.dkpro.core dkpro-core-stanfordnlp-gpl + + + xml-apis + xml-apis + + org.json @@ -512,6 +524,12 @@ org.apache.poi poi-ooxml 4.1.2 + + + xml-apis + xml-apis + + org.knowm.xchart From 8af3f99457f0cfcaa060a59c0bfc82e56f02e548 Mon Sep 17 00:00:00 2001 From: bkis Date: Tue, 23 Nov 2021 13:48:31 +0100 Subject: [PATCH 2/9] Update dependencies All deps without breaking changes updated to the newest release. This excludes org.knowm.xchart, as there seem to be plenty breaking changes that'd need additional attention. --- pom.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 715f4d82..2db6575d 100644 --- a/pom.xml +++ b/pom.xml @@ -442,7 +442,7 @@ org.reflections reflections - 0.9.12 + 0.10.2 org.apache.commons @@ -487,12 +487,12 @@ org.json json - 20151123 + 20210307 de.unistuttgart.ims.uima.io generic-xml-reader - 2.0.0 + 2.0.1 com.lexicalscope.jewelcli @@ -502,7 +502,7 @@ org.mockito mockito-core - 3.4.4 + 4.1.0 test @@ -518,12 +518,12 @@ org.apache.poi poi - 4.1.2 + 5.1.0 org.apache.poi poi-ooxml - 4.1.2 + 5.1.0 xml-apis @@ -539,12 +539,12 @@ org.apache.commons commons-csv - 1.8 + 1.9.0 org.slf4j slf4j-nop - 1.7.30 + 2.0.0-alpha5 From 7bbca7cc5e84eeacd94a769c9c1be132e1d7cd57 Mon Sep 17 00:00:00 2001 From: bkis Date: Mon, 13 Dec 2021 11:09:49 +0100 Subject: [PATCH 3/9] Implement CSV export for ExportMultipleFiles tool closes #370 --- .../annotator/plugin/csv/CsvExportPlugin.java | 123 +++++++++++++----- .../coref/annotator/plugin/csv/Defaults.java | 1 + .../annotator/tools/ExportMultipleFiles.java | 18 ++- 3 files changed, 106 insertions(+), 36 deletions(-) diff --git a/src/main/java/de/unistuttgart/ims/coref/annotator/plugin/csv/CsvExportPlugin.java b/src/main/java/de/unistuttgart/ims/coref/annotator/plugin/csv/CsvExportPlugin.java index 2985528c..40d2a18a 100644 --- a/src/main/java/de/unistuttgart/ims/coref/annotator/plugin/csv/CsvExportPlugin.java +++ b/src/main/java/de/unistuttgart/ims/coref/annotator/plugin/csv/CsvExportPlugin.java @@ -32,8 +32,12 @@ import de.unistuttgart.ims.coref.annotator.plugins.UimaExportPlugin; import javafx.stage.FileChooser.ExtensionFilter; -public class CsvExportPlugin extends AbstractExportPlugin implements UimaExportPlugin, ConfigurableExportPlugin { +public class CsvExportPlugin + extends AbstractExportPlugin + implements UimaExportPlugin, ConfigurableExportPlugin { + + public static enum ContextUnit { CHARACTER, TOKEN, LINE; @@ -66,13 +70,26 @@ public AnalysisEngineDescription getExporter() throws ResourceInitializationExce @Override public AnalysisEngineDescription getWriter(File f) throws ResourceInitializationException { + AggregateBuilder b = new AggregateBuilder(); - b.add(AnalysisEngineFactory.createEngineDescription(CSVWriter.class, CSVWriter.PARAM_FILE, f.getAbsolutePath(), - CSVWriter.PARAM_CONTEXTWIDTH, getOptionContextWidth(), CSVWriter.PARAM_REPLACE_NEWLINES, - isOptionReplaceNewlines(), CSVWriter.PARAM_TRIM_WHITESPACE, isOptionTrimWhitespace(), - CSVWriter.PARAM_CONTEXT_UNIT, getOptionContextUnit(), CSVWriter.PARAM_INCLUDE_LINE_NUMBERS, - Annotator.app.getPreferences().getBoolean(Constants.PLUGIN_CSV_INCLUDE_LINE_NUMBERS, - Defaults.CFG_OPTION_INCLUDE_LINE_NUMBERS))); + b.add(AnalysisEngineFactory.createEngineDescription( + CSVWriter.class, + CSVWriter.PARAM_FILE, + f.getAbsolutePath(), + CSVWriter.PARAM_CONTEXTWIDTH, + getOptionContextWidth(), + CSVWriter.PARAM_REPLACE_NEWLINES, + isOptionReplaceNewlines(), + CSVWriter.PARAM_TRIM_WHITESPACE, + isOptionTrimWhitespace(), + CSVWriter.PARAM_CONTEXT_UNIT, + getOptionContextUnit(), + CSVWriter.PARAM_INCLUDE_LINE_NUMBERS, + Annotator.app != null + ? Annotator.app.getPreferences().getBoolean( + Constants.PLUGIN_CSV_INCLUDE_LINE_NUMBERS, + Defaults.CFG_OPTION_INCLUDE_LINE_NUMBERS) + : Defaults.CFG_OPTION_INCLUDE_LINE_NUMBERS)); return b.createAggregateDescription(); } @@ -104,57 +121,101 @@ public ExtensionFilter getExtensionFilter() { } @Override - public void showExportConfigurationDialog(JFrame parent, DocumentModel documentModel, + public void showExportConfigurationDialog( + JFrame parent, + DocumentModel documentModel, Consumer callback) { ImmutableList options = Lists.immutable.of( - new PluginOption.IntegerPluginOption(Annotator.app.getPreferences(), Constants.PLUGIN_CSV_CONTEXT_WIDTH, - Defaults.CFG_OPTION_CONTEXT_WIDTH, "dialog.export_options.context_width", - "dialog.export_options.context_width.tooltip", 0, 500, 25), - (PluginOption) new PluginOption.EnumPluginOption(ContextUnit.class, - Annotator.app.getPreferences(), Constants.PLUGIN_CSV_CONTEXT_UNIT, - Defaults.CFG_OPTION_CONTEXT_UNIT, "dialog.export_options.context_unit", - "dialog.export_options.context_unit.tooltip", Lists.immutable.of(ContextUnit.values()) - .select(cu -> cu.isPossible(documentModel.getJcas())).toArray(new ContextUnit[] {}), + new PluginOption.IntegerPluginOption( + Annotator.app.getPreferences(), + Constants.PLUGIN_CSV_CONTEXT_WIDTH, + Defaults.CFG_OPTION_CONTEXT_WIDTH, + "dialog.export_options.context_width", + "dialog.export_options.context_width.tooltip", + 0, + 500, + 25), + (PluginOption) new PluginOption.EnumPluginOption( + ContextUnit.class, + Annotator.app.getPreferences(), + Constants.PLUGIN_CSV_CONTEXT_UNIT, + Defaults.CFG_OPTION_CONTEXT_UNIT, + "dialog.export_options.context_unit", + "dialog.export_options.context_unit.tooltip", + Lists.immutable.of(ContextUnit.values()) + .select(cu -> cu.isPossible( + documentModel.getJcas())) + .toArray(new ContextUnit[] {}), new DefaultListCellRenderer() { private static final long serialVersionUID = 1L; @Override - public Component getListCellRendererComponent(JList list, Object value, int index, - boolean isSelected, boolean cellHasFocus) { - super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - setText(Annotator.getString("dialog.export_options.context_unit." + value.toString())); + public Component getListCellRendererComponent( + JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus) { + super.getListCellRendererComponent( + list, value, index, isSelected, cellHasFocus); + setText(Annotator.getString( + "dialog.export_options.context_unit." + value.toString())); return this; } }), - new BooleanPluginOption(Annotator.app.getPreferences(), Constants.PLUGIN_CSV_TRIM, - Defaults.CFG_OPTION_TRIM, "dialog.export_options.trim_whitespace", + new BooleanPluginOption( + Annotator.app.getPreferences(), + Constants.PLUGIN_CSV_TRIM, + Defaults.CFG_OPTION_TRIM, + "dialog.export_options.trim_whitespace", "dialog.export_options.trim_whitespace.tooltip"), - new BooleanPluginOption(Annotator.app.getPreferences(), Constants.PLUGIN_CSV_REPLACE_NEWLINES, - Defaults.CFG_OPTION_REPLACE_NEWLINES, "dialog.export_options.replace_newline", + new BooleanPluginOption( + Annotator.app.getPreferences(), + Constants.PLUGIN_CSV_REPLACE_NEWLINES, + Defaults.CFG_OPTION_REPLACE_NEWLINES, + "dialog.export_options.replace_newline", "dialog.export_options.replace_newline.tooltip"), - new BooleanPluginOption(Annotator.app.getPreferences(), Constants.PLUGIN_CSV_INCLUDE_LINE_NUMBERS, - Defaults.CFG_OPTION_INCLUDE_LINE_NUMBERS, "dialog.export_options.include_line_numbers", + new BooleanPluginOption( + Annotator.app.getPreferences(), + Constants.PLUGIN_CSV_INCLUDE_LINE_NUMBERS, + Defaults.CFG_OPTION_INCLUDE_LINE_NUMBERS, + "dialog.export_options.include_line_numbers", "dialog.export_options.include_line_numbers.tooltip")); new PluginConfigurationDialog(parent, this, callback, options).setVisible(true); } public int getOptionContextWidth() { - return Annotator.app.getPreferences().getInt((Constants.PLUGIN_CSV_CONTEXT_WIDTH), 30); + return Annotator.app != null + ? Annotator.app.getPreferences().getInt( + Constants.PLUGIN_CSV_CONTEXT_WIDTH, + Defaults.CFG_OPTION_CONTEXT_WIDTH) + : Defaults.CFG_OPTION_CONTEXT_WIDTH; } public boolean isOptionTrimWhitespace() { - return Annotator.app.getPreferences().getBoolean((Constants.PLUGIN_CSV_TRIM), true); + return Annotator.app != null + ? Annotator.app.getPreferences().getBoolean( + Constants.PLUGIN_CSV_TRIM, + Defaults.CFG_OPTION_TRIM) + : Defaults.CFG_OPTION_TRIM; } public boolean isOptionReplaceNewlines() { - return Annotator.app.getPreferences().getBoolean((Constants.PLUGIN_CSV_REPLACE_NEWLINES), true); + return Annotator.app != null + ? Annotator.app.getPreferences().getBoolean( + Constants.PLUGIN_CSV_REPLACE_NEWLINES, + Defaults.CFG_OPTION_REPLACE_NEWLINES) + : Defaults.CFG_OPTION_REPLACE_NEWLINES; } public ContextUnit getOptionContextUnit() { - return ContextUnit.valueOf( - Annotator.app.getPreferences().get((Constants.PLUGIN_CSV_CONTEXT_UNIT), ContextUnit.CHARACTER.name())); + return Annotator.app != null + ? ContextUnit.valueOf(Annotator.app.getPreferences().get( + Constants.PLUGIN_CSV_CONTEXT_UNIT, + Defaults.CFG_OPTION_CONTEXT_UNIT.name())) + : ContextUnit.valueOf(Defaults.CFG_OPTION_CONTEXT_UNIT.name()); } } diff --git a/src/main/java/de/unistuttgart/ims/coref/annotator/plugin/csv/Defaults.java b/src/main/java/de/unistuttgart/ims/coref/annotator/plugin/csv/Defaults.java index 85696248..7caa6824 100644 --- a/src/main/java/de/unistuttgart/ims/coref/annotator/plugin/csv/Defaults.java +++ b/src/main/java/de/unistuttgart/ims/coref/annotator/plugin/csv/Defaults.java @@ -3,6 +3,7 @@ import de.unistuttgart.ims.coref.annotator.plugin.csv.CsvExportPlugin.ContextUnit; public class Defaults { + public static final int CFG_OPTION_CONTEXT_WIDTH = 30; public static final ContextUnit CFG_OPTION_CONTEXT_UNIT = ContextUnit.CHARACTER; public static final boolean CFG_OPTION_TRIM = true; diff --git a/src/main/java/de/unistuttgart/ims/coref/annotator/tools/ExportMultipleFiles.java b/src/main/java/de/unistuttgart/ims/coref/annotator/tools/ExportMultipleFiles.java index c129cfa3..9e207136 100644 --- a/src/main/java/de/unistuttgart/ims/coref/annotator/tools/ExportMultipleFiles.java +++ b/src/main/java/de/unistuttgart/ims/coref/annotator/tools/ExportMultipleFiles.java @@ -36,13 +36,12 @@ * */ public class ExportMultipleFiles { + static Options options; - static ExportPlugin outputPlugin; - static Pattern filenamePattern = Pattern.compile("^(.*)\\.xmi(\\.gz)?"); - static PluginManager pluginManager; + public static void main(String[] args) throws ResourceInitializationException, ClassNotFoundException, InterruptedException, ExecutionException { @@ -80,6 +79,7 @@ public boolean accept(File pathname) { } } + /** * This function processes a single file. * @@ -123,9 +123,12 @@ public static void convertFile(File file, Options options) throws InterruptedExc w.get(); } + public enum OutputFormat { - tei, conll2012, json, qdtei, stats; + + tei, conll2012, json, csv, qdtei, stats; + @SuppressWarnings("unchecked") Class getPluginClass() { switch (this) { case stats: @@ -136,6 +139,8 @@ Class getPluginClass() { return de.unistuttgart.ims.coref.annotator.plugin.json.Plugin.class; case tei: return de.unistuttgart.ims.coref.annotator.plugin.tei.TeiExportPlugin.class; + case csv: + return de.unistuttgart.ims.coref.annotator.plugin.csv.CsvExportPlugin.class; case qdtei: // This is a temporary workaround try { @@ -152,16 +157,18 @@ Class getPluginClass() { } + public enum OutputFilename { input, documentId } + @CommandLineInterface(application = "ExportMultipleFiles") public interface Options { @Option(description = "Input file or directory.", shortName = "i") List getInput(); - @Option(defaultValue = "tei", description = "Target format. One of [tei, conll2012, json].") + @Option(defaultValue = "tei", description = "Target format. One of [tei, conll2012, json, csv, stats].") OutputFormat getOutputFormat(); @Option(defaultValue = ".", description = "Output directory. Defaults to current.", shortName = "o") @@ -173,4 +180,5 @@ public interface Options { @Option(helpRequest = true, shortName = "h", description = "Show help") boolean getHelp(); } + } From 1cb4053c16f269bcb1c09128b4351c6ca2bf3a91 Mon Sep 17 00:00:00 2001 From: bkis Date: Mon, 13 Dec 2021 14:16:35 +0100 Subject: [PATCH 4/9] Fix #381 --- .../ims/coref/annotator/Annotator.java | 4 +-- .../ims/coref/annotator/DocumentWindow.java | 30 +++++++++++-------- .../annotator/document/EntityTreeModel.java | 2 +- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/main/java/de/unistuttgart/ims/coref/annotator/Annotator.java b/src/main/java/de/unistuttgart/ims/coref/annotator/Annotator.java index 1b5949c6..a66cc912 100644 --- a/src/main/java/de/unistuttgart/ims/coref/annotator/Annotator.java +++ b/src/main/java/de/unistuttgart/ims/coref/annotator/Annotator.java @@ -465,8 +465,7 @@ private MutableList getRecentFilesFromPreferences() { private void recentFiles2Preferences(MutableList 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); } @@ -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() { diff --git a/src/main/java/de/unistuttgart/ims/coref/annotator/DocumentWindow.java b/src/main/java/de/unistuttgart/ims/coref/annotator/DocumentWindow.java index 03d717ca..ba0ae481 100644 --- a/src/main/java/de/unistuttgart/ims/coref/annotator/DocumentWindow.java +++ b/src/main/java/de/unistuttgart/ims/coref/annotator/DocumentWindow.java @@ -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; } diff --git a/src/main/java/de/unistuttgart/ims/coref/annotator/document/EntityTreeModel.java b/src/main/java/de/unistuttgart/ims/coref/annotator/document/EntityTreeModel.java index 0a93390b..6712dc7a 100644 --- a/src/main/java/de/unistuttgart/ims/coref/annotator/document/EntityTreeModel.java +++ b/src/main/java/de/unistuttgart/ims/coref/annotator/document/EntityTreeModel.java @@ -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; From 5843f19d315f08b7007258033db4e86233b69fff Mon Sep 17 00:00:00 2001 From: bkis Date: Thu, 16 Dec 2021 11:49:11 +0100 Subject: [PATCH 5/9] Fix reflection warning by adding multi-release manifest entry --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index 2db6575d..b0b15397 100644 --- a/pom.xml +++ b/pom.xml @@ -86,6 +86,7 @@ de.unistuttgart.ims.coref.annotator.Annotator ${project.version} + true Date: Thu, 16 Dec 2021 11:50:34 +0100 Subject: [PATCH 6/9] Downgrade slf4j-nop to match managed version of log4j ...this fixes the SLF4J warnings on startup --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b0b15397..2a7f0d18 100644 --- a/pom.xml +++ b/pom.xml @@ -545,7 +545,7 @@ org.slf4j slf4j-nop - 2.0.0-alpha5 + 1.7.30 From 5e3426076832402f52f53811b2cb04725572b26a Mon Sep 17 00:00:00 2001 From: bkis Date: Tue, 15 Feb 2022 14:54:56 +0100 Subject: [PATCH 7/9] Fix #380 closes #380 --- .../annotator/document/CoreferenceModel.java | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main/java/de/unistuttgart/ims/coref/annotator/document/CoreferenceModel.java b/src/main/java/de/unistuttgart/ims/coref/annotator/document/CoreferenceModel.java index 0a489b9f..3b7acb62 100644 --- a/src/main/java/de/unistuttgart/ims/coref/annotator/document/CoreferenceModel.java +++ b/src/main/java/de/unistuttgart/ims/coref/annotator/document/CoreferenceModel.java @@ -153,7 +153,7 @@ protected Entity createEntity(String l) { e.setLabel(l); e.setFlags(new EmptyFSList(documentModel.getJcas())); e.setMembers(new FSArray(documentModel.getJcas(), 0)); - e.addToIndexes(); + e.addToIndexes(getJCas()); return e; } @@ -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())); @@ -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()); @@ -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)); @@ -763,7 +763,7 @@ private Entity merge(Iterable nodes) { entityMentionMap.get(n).toSet().forEach(m -> moveTo(tgt, m)); entityMentionMap.removeAll(n); - n.removeFromIndexes(); + n.removeFromIndexes(getJCas()); } } return biggest; @@ -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)) { @@ -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(); } @@ -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); @@ -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); } @@ -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)); @@ -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)); @@ -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); @@ -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()) @@ -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)); }); @@ -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)); }); From 0ce5e5239cb5e17a31024118dc22d810839ec7e5 Mon Sep 17 00:00:00 2001 From: Nils Reiter Date: Fri, 8 Apr 2022 17:29:01 +0200 Subject: [PATCH 8/9] 2.1.0 and updated Changelog --- CHANGELOG.md | 7 +++++++ pom.xml | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92e7a75b..8cdfada2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ 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 + ## 2.0.1 - Fixes an issue that prevented expanding the tree properly in some imported files #373 diff --git a/pom.xml b/pom.xml index 2a7f0d18..c0743c65 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 de.unistuttgart.ims coref.annotator - 2.0.1 + 2.1.0 jar CorefAnnotator https://github.com/nilsreiter/CorefAnnotator/ From f7981148090ef900fff9304dcdb3f3fdf00fe485 Mon Sep 17 00:00:00 2001 From: Nils Reiter Date: Fri, 8 Apr 2022 17:31:34 +0200 Subject: [PATCH 9/9] Updated changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cdfada2..e84189cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ https://github.com/nilsreiter/CorefAnnotator/issues - 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