diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/LineOrientedPagingStrategy.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/LineOrientedPagingStrategy.java index 0d254b01ec9..3b907fee303 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/LineOrientedPagingStrategy.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/LineOrientedPagingStrategy.java @@ -17,10 +17,14 @@ */ package de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging; -import static org.apache.commons.lang3.StringUtils.splitPreserveAllTokens; +import static java.lang.String.join; +import static java.util.Arrays.asList; +import static java.util.regex.Pattern.compile; +import static java.util.stream.Collectors.joining; import java.util.ArrayList; import java.util.List; +import java.util.regex.Pattern; import org.apache.uima.cas.CAS; import org.apache.wicket.Component; @@ -37,22 +41,45 @@ public class LineOrientedPagingStrategy { private static final long serialVersionUID = -991967885210129525L; + static final String CR = "\r"; // carriage return (CR) (classic Mac) + static final String LF = "\n"; // line feed (LF) (Unix) + static final String CRLF = "\r\n"; // CRLF (Windows) + static final String NEL = "\u0085"; // Next Line (NEL) + static final String LINE_SEPARATOR = "\u2028"; // Line Separator + static final String PARAGRAPH_SEPARATOR = "\u2029"; // Paragraph Separator + + // Mind that CRLF must come before CR and LF here so it matches as a unit! + static final List LINE_SEPARATORS = asList(CRLF, CR, LF, NEL, LINE_SEPARATOR, + PARAGRAPH_SEPARATOR); + + static final Pattern LINE_PATTERN = compile("[^" + join("", LINE_SEPARATORS) + "]+" // + + "|" + join("|", LINE_SEPARATORS)); + static final Pattern LINE_SPLITTER_PATTERN = compile(LINE_SEPARATORS.stream() // + .map(Pattern::quote) // + .collect(joining("|"))); + @Override public List units(CAS aCas, int aFirstIndex, int aLastIndex) { - // We need to preserve all tokens so we can add a +1 for the line breaks of empty lines. - String[] lines = splitPreserveAllTokens(aCas.getDocumentText(), '\n'); + var text = aCas.getDocumentText(); + var matcher = LINE_SPLITTER_PATTERN.matcher(text); - List units = new ArrayList<>(); - int beginOffset = 0; - for (int i = 0; i < Math.min(lines.length, aLastIndex); i++) { + var unitStart = 0; + var unitEnd = 0; + var index = 1; - if (i >= aFirstIndex) { - units.add(new Unit(i + 1, beginOffset, beginOffset + lines[i].length())); - } + var units = new ArrayList(); + while (matcher.find()) { + unitEnd = matcher.start(); + units.add(new Unit(index, unitStart, unitEnd)); + unitStart = matcher.end(); + index++; + } - // The +1 below accounts for the line break which is not included in the token - beginOffset += lines[i].length() + 1; + if (unitStart < text.length()) { + if (!text.substring(unitStart).isBlank()) { + units.add(new Unit(index, unitStart, text.length())); + } } return units; @@ -61,8 +88,8 @@ public List units(CAS aCas, int aFirstIndex, int aLastIndex) @Override public Component createPositionLabel(String aId, IModel aModel) { - Label label = new Label(aId, () -> { - AnnotatorState state = aModel.getObject(); + var label = new Label(aId, () -> { + var state = aModel.getObject(); return String.format("%d-%d / %d lines [doc %d / %d]", state.getFirstVisibleUnitIndex(), state.getLastVisibleUnitIndex(), state.getUnitCount(), state.getDocumentIndex() + 1, state.getNumberOfDocuments()); diff --git a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/TokenWrappingPagingStrategy.java b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/TokenWrappingPagingStrategy.java index 5a9090909b1..ce513b58728 100644 --- a/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/TokenWrappingPagingStrategy.java +++ b/inception/inception-api-annotation/src/main/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/TokenWrappingPagingStrategy.java @@ -17,23 +17,22 @@ */ package de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging; +import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging.LineOrientedPagingStrategy.LINE_SPLITTER_PATTERN; import static java.lang.String.format; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.apache.uima.cas.CAS; -import org.apache.uima.cas.text.AnnotationFS; import org.apache.wicket.Component; import org.apache.wicket.Page; import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.model.IModel; import de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.AnnotationPageBase; +import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState; import de.tudarmstadt.ukp.inception.rendering.paging.Unit; -import de.tudarmstadt.ukp.inception.support.uima.WebAnnoCasUtil; public class TokenWrappingPagingStrategy extends PagingStrategy_ImplBase @@ -50,14 +49,14 @@ public TokenWrappingPagingStrategy(int aMaxLineLength) @Override public List units(CAS aCas, int aFirstIndex, int aLastIndex) { - Iterator tokenIterator = WebAnnoCasUtil.selectTokens(aCas).iterator(); + var tokenIterator = aCas.select(Token.class).iterator(); var units = new ArrayList(); int currentUnitStart = 0; int currentUnitEnd = 0; while (tokenIterator.hasNext()) { - AnnotationFS currentToken = tokenIterator.next(); + var currentToken = tokenIterator.next(); if (currentToken.getBegin() < currentUnitEnd) { throw new IllegalStateException(format( @@ -65,14 +64,14 @@ public List units(CAS aCas, int aFirstIndex, int aLastIndex) currentToken.getBegin(), currentToken.getEnd(), currentUnitEnd)); } + // Add units for each of the lines in the gap var gap = aCas.getDocumentText().substring(currentUnitEnd, currentToken.getBegin()); int gapStart = currentUnitEnd; - int lineBreakIndex = gap.indexOf("\n"); - while (lineBreakIndex > -1) { - currentUnitEnd = gapStart + lineBreakIndex; + var matcher = LINE_SPLITTER_PATTERN.matcher(gap); + while (matcher.find()) { + currentUnitEnd = gapStart + matcher.start(); units.add(new Unit(units.size() + 1, currentUnitStart, currentUnitEnd)); - currentUnitStart = currentUnitEnd + 1; // +1 because of the line break character - lineBreakIndex = gap.indexOf("\n", lineBreakIndex + 1); + currentUnitStart = gapStart + matcher.end(); } var unitNonEmpty = (currentUnitEnd - currentUnitStart) > 0; @@ -92,10 +91,28 @@ public List units(CAS aCas, int aFirstIndex, int aLastIndex) currentUnitEnd = currentToken.getEnd(); } + // Finish current unit if (currentUnitEnd - currentUnitStart > 0) { units.add(new Unit(units.size() + 1, currentUnitStart, currentUnitEnd)); + currentUnitStart = -1; } + // // Add any line breaks at the end of the document + // if (aCas.getDocumentText().length() - currentUnitEnd > 0) { + // var gap = aCas.getDocumentText().substring(currentUnitEnd, + // aCas.getDocumentText().length()); + // int gapStart = currentUnitEnd; + // var matcher = LINE_SPLITTER_PATTERN.matcher(gap); + // while (matcher.find()) { + // currentUnitEnd = gapStart + matcher.start(); + // if (currentUnitStart == -1) { + // currentUnitStart = currentUnitEnd; + // } + // units.add(new Unit(units.size() + 1, currentUnitStart, currentUnitEnd)); + // currentUnitStart = gapStart + matcher.end(); + // } + // } + return units; } diff --git a/inception/inception-api-annotation/src/test/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/LineOrientedPagingStrategyTest.java b/inception/inception-api-annotation/src/test/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/LineOrientedPagingStrategyTest.java new file mode 100644 index 00000000000..3dcd7f05c8d --- /dev/null +++ b/inception/inception-api-annotation/src/test/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/LineOrientedPagingStrategyTest.java @@ -0,0 +1,101 @@ +/* + * Licensed to the Technische Universität Darmstadt under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The Technische Universität Darmstadt + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging; + +import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging.LineOrientedPagingStrategy.CR; +import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging.LineOrientedPagingStrategy.CRLF; +import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging.LineOrientedPagingStrategy.LF; +import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging.LineOrientedPagingStrategy.LINE_SEPARATOR; +import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging.LineOrientedPagingStrategy.NEL; +import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging.LineOrientedPagingStrategy.PARAGRAPH_SEPARATOR; +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.uima.fit.factory.JCasFactory; +import org.junit.jupiter.api.Test; + +class LineOrientedPagingStrategyTest +{ + @Test + void testMixedLineBreaks() throws Exception + { + var sut = new LineOrientedPagingStrategy(); + + var jcas = JCasFactory.createJCas(); + jcas.setDocumentText( // + "Line1" + CR + // + "Line2" + LF + // + "Line3" + CRLF + // + "Line4" + NEL + // + "Line5" + LINE_SEPARATOR + // + "Line6" + PARAGRAPH_SEPARATOR + // + "Line7"); + + assertThat(sut.units(jcas.getCas())) + .extracting(u -> jcas.getDocumentText().substring(u.getBegin(), u.getEnd())) + .containsExactly( // + "Line1", // + "Line2", // + "Line3", // + "Line4", // + "Line5", // + "Line6", // + "Line7"); + } + + @Test + void testConsecutiveLineBreaks() throws Exception + { + var sut = new LineOrientedPagingStrategy(); + + var jcas = JCasFactory.createJCas(); + jcas.setDocumentText( // + "Line1" + CR + CR + // + "Line2" + LF + LF + // + "Line3" + CRLF + CRLF + // + "Line4" + NEL + NEL + // + "Line5" + LINE_SEPARATOR + LINE_SEPARATOR + // + "Line6" + PARAGRAPH_SEPARATOR + PARAGRAPH_SEPARATOR + // + "Line7"); + + assertThat(sut.units(jcas.getCas())) + .extracting(u -> jcas.getDocumentText().substring(u.getBegin(), u.getEnd())) + .containsExactly( // + "Line1", "", // + "Line2", "", // + "Line3", "", // + "Line4", "", // + "Line5", "", // + "Line6", "", // + "Line7"); + } + + @Test + void testEndingWithNewline() throws Exception + { + var sut = new LineOrientedPagingStrategy(); + + var jcas = JCasFactory.createJCas(); + jcas.setDocumentText( // + "Line1" + CR + CR); + + assertThat(sut.units(jcas.getCas())) + .extracting(u -> jcas.getDocumentText().substring(u.getBegin(), u.getEnd())) + .containsExactly( // + "Line1", ""); + } +} diff --git a/inception/inception-api-annotation/src/test/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/TokenWrappingPagingStrategyTest.java b/inception/inception-api-annotation/src/test/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/TokenWrappingPagingStrategyTest.java index 8f80b10759c..c054868b723 100644 --- a/inception/inception-api-annotation/src/test/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/TokenWrappingPagingStrategyTest.java +++ b/inception/inception-api-annotation/src/test/java/de/tudarmstadt/ukp/clarin/webanno/api/annotation/paging/TokenWrappingPagingStrategyTest.java @@ -17,13 +17,14 @@ */ package de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging; +import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging.LineOrientedPagingStrategy.CR; +import static de.tudarmstadt.ukp.clarin.webanno.api.annotation.paging.LineOrientedPagingStrategy.LINE_SEPARATORS; +import static org.apache.commons.lang3.StringUtils.repeat; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.tuple; -import org.apache.commons.lang3.StringUtils; import org.apache.uima.fit.factory.JCasBuilder; import org.apache.uima.fit.factory.JCasFactory; -import org.apache.uima.jcas.JCas; import org.junit.jupiter.api.Test; import de.tudarmstadt.ukp.dkpro.core.api.segmentation.type.Token; @@ -34,10 +35,10 @@ public class TokenWrappingPagingStrategyTest @Test public void thatMultipleConsecutiveLineBreaksWork() throws Exception { - TokenWrappingPagingStrategy sut = new TokenWrappingPagingStrategy(120); + var sut = new TokenWrappingPagingStrategy(120); - JCas jcas = JCasFactory.createJCas(); - JCasBuilder builder = new JCasBuilder(jcas); + var jcas = JCasFactory.createJCas(); + var builder = new JCasBuilder(jcas); builder.add("See-", Token.class); builder.add("\n"); builder.add("\n"); @@ -57,22 +58,23 @@ public void thatMultipleConsecutiveLineBreaksWork() throws Exception @Test public void thatLinesOfDifferntLenghtsWork() throws Exception { - TokenWrappingPagingStrategy sut = new TokenWrappingPagingStrategy(10); + var sut = new TokenWrappingPagingStrategy(10); - JCas jcas = JCasFactory.createJCas(); - JCasBuilder builder = new JCasBuilder(jcas); - builder.add(StringUtils.repeat("a", 20), Token.class); + var jcas = JCasFactory.createJCas(); + var builder = new JCasBuilder(jcas); + builder.add(repeat("a", 20), Token.class); builder.add("\n"); - builder.add(StringUtils.repeat("b", 15), Token.class); + builder.add(repeat("b", 15), Token.class); builder.add("\n"); - builder.add(StringUtils.repeat("c", 11), Token.class); + builder.add(repeat("c", 11), Token.class); builder.add("\n"); - builder.add(StringUtils.repeat("d", 10), Token.class); + builder.add(repeat("d", 10), Token.class); builder.add("\n"); - builder.add(StringUtils.repeat("e", 9), Token.class); + builder.add(repeat("e", 9), Token.class); builder.add("\n"); - builder.add(StringUtils.repeat("f", 1), Token.class); + builder.add(repeat("f", 1), Token.class); builder.add("\n"); + builder.add(repeat("g", 1), Token.class); builder.close(); assertThat(sut.units(jcas.getCas())) // @@ -86,18 +88,19 @@ public void thatLinesOfDifferntLenghtsWork() throws Exception tuple(37, 48, "ccccccccccc"), // tuple(49, 59, "dddddddddd"), // tuple(60, 69, "eeeeeeeee"), // - tuple(70, 71, "f")); + tuple(70, 71, "f"), // + tuple(72, 73, "g")); } @Test public void thatWrappingWork() throws Exception { - TokenWrappingPagingStrategy sut = new TokenWrappingPagingStrategy(11); + var sut = new TokenWrappingPagingStrategy(11); - JCas jcas = JCasFactory.createJCas(); - JCasBuilder builder = new JCasBuilder(jcas); + var jcas = JCasFactory.createJCas(); + var builder = new JCasBuilder(jcas); for (int n = 0; n < 10; n++) { - builder.add(StringUtils.repeat("a", 3), Token.class); + builder.add(repeat("a", 3), Token.class); builder.add(" "); } builder.close(); @@ -113,4 +116,54 @@ public void thatWrappingWork() throws Exception tuple(24, 35, "aaa aaa aaa"), // tuple(36, 39, "aaa")); } + + @Test + void testMixedLineBreaks() throws Exception + { + var sut = new TokenWrappingPagingStrategy(10); + + var jcas = JCasFactory.createJCas(); + var builder = new JCasBuilder(jcas); + var i = 1; + for (var sep : LINE_SEPARATORS) { + builder.add(repeat("a", 3) + i, Token.class); + builder.add(" "); + builder.add(repeat("b", 3) + i, Token.class); + builder.add(" "); + builder.add(repeat("c", 3) + i, Token.class); + builder.add(sep); + i++; + } + builder.add("end", Token.class); + builder.close(); + + assertThat(sut.units(jcas.getCas())) + .extracting(u -> jcas.getDocumentText().substring(u.getBegin(), u.getEnd())) + .containsExactly( // + "aaa1 bbb1", "ccc1", // + "aaa2 bbb2", "ccc2", // + "aaa3 bbb3", "ccc3", // + "aaa4 bbb4", "ccc4", // + "aaa5 bbb5", "ccc5", // + "aaa6 bbb6", "ccc6", // + "end"); + } + + @Test + void testEndingWithNewline() throws Exception + { + var sut = new TokenWrappingPagingStrategy(10); + + var jcas = JCasFactory.createJCas(); + var builder = new JCasBuilder(jcas); + builder.add(repeat("a", 3), Token.class); + builder.add(CR); + builder.add(CR); + builder.close(); + + assertThat(sut.units(jcas.getCas())) + .extracting(u -> jcas.getDocumentText().substring(u.getBegin(), u.getEnd())) + .containsExactly( // + "aaa"); + } } diff --git a/inception/inception-brat-editor/src/test/java/de/tudarmstadt/ukp/clarin/webanno/brat/message/JsonDiffTest.java b/inception/inception-brat-editor/src/test/java/de/tudarmstadt/ukp/clarin/webanno/brat/message/JsonDiffTest.java index f752709e4c7..8cec79c13c4 100644 --- a/inception/inception-brat-editor/src/test/java/de/tudarmstadt/ukp/clarin/webanno/brat/message/JsonDiffTest.java +++ b/inception/inception-brat-editor/src/test/java/de/tudarmstadt/ukp/clarin/webanno/brat/message/JsonDiffTest.java @@ -17,13 +17,13 @@ */ package de.tudarmstadt.ukp.clarin.webanno.brat.message; +import static org.assertj.core.api.Assertions.assertThat; + import java.io.File; import org.junit.jupiter.api.Test; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import com.flipkart.zjsonpatch.JsonDiff; public class JsonDiffTest @@ -31,26 +31,31 @@ public class JsonDiffTest @Test public void testJsonDiff() throws Exception { - String f_base = "src/test/resources/brat_normal.json"; - String f_addedMiddle = "src/test/resources/brat_added_entity_near_middle.json"; - String f_removedMiddle = "src/test/resources/brat_removed_entity_in_middle.json"; - String f_removedEnd = "src/test/resources/brat_removed_entity_near_end.json"; - - MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter(); - - ObjectMapper mapper = jsonConverter.getObjectMapper(); - - JsonNode base = mapper.readTree(new File(f_base)); - JsonNode addedMiddle = mapper.readTree(new File(f_addedMiddle)); - JsonNode removedMiddle = mapper.readTree(new File(f_removedMiddle)); - JsonNode removedEnd = mapper.readTree(new File(f_removedEnd)); - - JsonNode d_addedMiddle = JsonDiff.asJson(base, addedMiddle); - JsonNode d_removedMiddle = JsonDiff.asJson(base, removedMiddle); - JsonNode d_removedEnd = JsonDiff.asJson(base, removedEnd); - - System.out.println(d_addedMiddle); - System.out.println(d_removedMiddle); - System.out.println(d_removedEnd); + var f_base = "src/test/resources/brat_normal.json"; + var f_addedMiddle = "src/test/resources/brat_added_entity_near_middle.json"; + var f_removedMiddle = "src/test/resources/brat_removed_entity_in_middle.json"; + var f_removedEnd = "src/test/resources/brat_removed_entity_near_end.json"; + + var jsonConverter = new MappingJackson2HttpMessageConverter(); + + var mapper = jsonConverter.getObjectMapper(); + + var base = mapper.readTree(new File(f_base)); + var addedMiddle = mapper.readTree(new File(f_addedMiddle)); + var removedMiddle = mapper.readTree(new File(f_removedMiddle)); + var removedEnd = mapper.readTree(new File(f_removedEnd)); + + var d_addedMiddle = JsonDiff.asJson(base, addedMiddle); + var d_removedMiddle = JsonDiff.asJson(base, removedMiddle); + var d_removedEnd = JsonDiff.asJson(base, removedEnd); + + assertThat(d_addedMiddle.toString()) // + .isEqualTo("[{\"op\":\"add\",\"path\":\"/entities/7\",\"value\":" // + + "[\"198\",\"0_de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS\"," // + + "[[29,32]],\"LALA\",\"#8dd3c7\",null]}]"); + assertThat(d_removedMiddle.toString()) // + .isEqualTo("[{\"op\":\"remove\",\"path\":\"/entities/5\"}]"); + assertThat(d_removedEnd.toString()) // + .isEqualTo("[{\"op\":\"remove\",\"path\":\"/entities/10\"}]"); } } diff --git a/inception/inception-brat-editor/src/test/java/de/tudarmstadt/ukp/clarin/webanno/brat/render/BratSerializerImplTest.java b/inception/inception-brat-editor/src/test/java/de/tudarmstadt/ukp/clarin/webanno/brat/render/BratSerializerImplTest.java index 147b20f4608..afa991cd324 100644 --- a/inception/inception-brat-editor/src/test/java/de/tudarmstadt/ukp/clarin/webanno/brat/render/BratSerializerImplTest.java +++ b/inception/inception-brat-editor/src/test/java/de/tudarmstadt/ukp/clarin/webanno/brat/render/BratSerializerImplTest.java @@ -171,7 +171,7 @@ void thatSentenceOrientedStrategyRenderCorrectly() throws Exception () -> asList(posFeature)); }); - var jsonFilePath = "target/test-output/output-sentence-oriented.json"; + var jsonFilePath = "target/test-output/paging-sentence-oriented.json"; var file = "src/test/resources/tcf04-karin-wl.xml"; var cas = JCasFactory.createJCas().getCas(); @@ -201,15 +201,15 @@ void thatSentenceOrientedStrategyRenderCorrectly() throws Exception JSONUtil.generatePrettyJson(response, new File(jsonFilePath)); - assertThat(contentOf(new File("src/test/resources/output-sentence-oriented.json"), UTF_8)) + assertThat(contentOf(new File("src/test/resources/paging-sentence-oriented.json"), UTF_8)) .isEqualToNormalizingNewlines(contentOf(new File(jsonFilePath), UTF_8)); } @Test void thatLineOrientedStrategyRenderCorrectly() throws Exception { - var jsonFilePath = "target/test-output/multiline.json"; - var file = "src/test/resources/multiline.txt"; + var jsonFilePath = "target/test-output/paging-line-oriented.json"; + var file = "src/test/resources/paging-line-oriented.txt"; var cas = JCasFactory.createJCas().getCas(); var reader = createReader(TextReader.class, TextReader.PARAM_SOURCE_LOCATION, file); @@ -239,15 +239,15 @@ void thatLineOrientedStrategyRenderCorrectly() throws Exception JSONUtil.generatePrettyJson(response, new File(jsonFilePath)); - assertThat(contentOf(new File("src/test/resources/multiline.json"), UTF_8)) - .isEqualToNormalizingNewlines(contentOf(new File(jsonFilePath), UTF_8)); + assertThat(contentOf(new File(jsonFilePath), UTF_8)).isEqualToNormalizingNewlines( + contentOf(new File("src/test/resources/paging-line-oriented.json"), UTF_8)); } @Test void thatTokenWrappingStrategyRenderCorrectly() throws Exception { - var jsonFilePath = "target/test-output/longlines.json"; - var file = "src/test/resources/longlines.txt"; + var jsonFilePath = "target/test-output/paging-token-wrapping.json"; + var file = "src/test/resources/paging-token-wrapping.txt"; var cas = JCasFactory.createJCas().getCas(); var reader = createReader(TextReader.class, TextReader.PARAM_SOURCE_LOCATION, file); @@ -277,7 +277,7 @@ void thatTokenWrappingStrategyRenderCorrectly() throws Exception JSONUtil.generatePrettyJson(response, new File(jsonFilePath)); - assertThat(contentOf(new File("src/test/resources/longlines.json"), UTF_8)) + assertThat(contentOf(new File("src/test/resources/paging-token-wrapping.json"), UTF_8)) .isEqualToNormalizingNewlines(contentOf(new File(jsonFilePath), UTF_8)); } diff --git a/inception/inception-brat-editor/src/test/resources/multiline.json b/inception/inception-brat-editor/src/test/resources/paging-line-oriented.json similarity index 79% rename from inception/inception-brat-editor/src/test/resources/multiline.json rename to inception/inception-brat-editor/src/test/resources/paging-line-oriented.json index 483a7016da4..ba431850487 100644 --- a/inception/inception-brat-editor/src/test/resources/multiline.json +++ b/inception/inception-brat-editor/src/test/resources/paging-line-oriented.json @@ -1,12 +1,12 @@ { "action" : "getDocument", - "text" : "This is line 1. This is line 3. This is line 4. ", + "text" : "This is line 1. This is line 3. This is line 4.", "windowBegin" : 0, - "windowEnd" : 49, + "windowEnd" : 48, "args" : { }, "rtl_mode" : false, "font_zoom" : 100, "sentence_number_offset" : 1, "token_offsets" : [ [ 0, 4 ], [ 5, 7 ], [ 8, 12 ], [ 13, 14 ], [ 14, 15 ], [ 17, 21 ], [ 22, 24 ], [ 25, 29 ], [ 30, 31 ], [ 31, 32 ], [ 33, 37 ], [ 38, 40 ], [ 41, 45 ], [ 46, 47 ], [ 47, 48 ] ], - "sentence_offsets" : [ [ 0, 15 ], [ 16, 16 ], [ 17, 32 ], [ 33, 48 ], [ 49, 49 ] ] + "sentence_offsets" : [ [ 0, 15 ], [ 16, 16 ], [ 17, 32 ], [ 33, 48 ] ] } \ No newline at end of file diff --git a/inception/inception-brat-editor/src/test/resources/multiline.tsv b/inception/inception-brat-editor/src/test/resources/paging-line-oriented.tsv similarity index 100% rename from inception/inception-brat-editor/src/test/resources/multiline.tsv rename to inception/inception-brat-editor/src/test/resources/paging-line-oriented.tsv diff --git a/inception/inception-brat-editor/src/test/resources/multiline.txt b/inception/inception-brat-editor/src/test/resources/paging-line-oriented.txt similarity index 100% rename from inception/inception-brat-editor/src/test/resources/multiline.txt rename to inception/inception-brat-editor/src/test/resources/paging-line-oriented.txt diff --git a/inception/inception-brat-editor/src/test/resources/output-sentence-oriented.json b/inception/inception-brat-editor/src/test/resources/paging-sentence-oriented.json similarity index 100% rename from inception/inception-brat-editor/src/test/resources/output-sentence-oriented.json rename to inception/inception-brat-editor/src/test/resources/paging-sentence-oriented.json diff --git a/inception/inception-brat-editor/src/test/resources/longlines.json b/inception/inception-brat-editor/src/test/resources/paging-token-wrapping.json similarity index 100% rename from inception/inception-brat-editor/src/test/resources/longlines.json rename to inception/inception-brat-editor/src/test/resources/paging-token-wrapping.json diff --git a/inception/inception-brat-editor/src/test/resources/longlines.txt b/inception/inception-brat-editor/src/test/resources/paging-token-wrapping.txt similarity index 100% rename from inception/inception-brat-editor/src/test/resources/longlines.txt rename to inception/inception-brat-editor/src/test/resources/paging-token-wrapping.txt diff --git a/inception/inception-doc/src/main/resources/META-INF/asciidoc/user-guide/getting-started.adoc b/inception/inception-doc/src/main/resources/META-INF/asciidoc/user-guide/getting-started.adoc index 360e63f8dcb..7ded11c3af5 100644 --- a/inception/inception-doc/src/main/resources/META-INF/asciidoc/user-guide/getting-started.adoc +++ b/inception/inception-doc/src/main/resources/META-INF/asciidoc/user-guide/getting-started.adoc @@ -494,9 +494,6 @@ For details, see <> in the main documentation. image::images/getting_started_monitoring.png[align="center"] -=== Evaluation -The evaluation page shows a learning curve diagram of each recommender (see xref:recommenders_in_getting_started[Recommender]). - === Settings Here, you can organize, manage and adjust all the details of your project. We had a look at those you need to get started for your own projects in the section <> already. diff --git a/inception/inception-html-apache-annotator-editor/src/main/java/de/tudarmstadt/ukp/inception/apacheannotatoreditor/ApacheAnnotatorHtmlAnnotationEditorFactoryUserPreferences.schema.json b/inception/inception-html-apache-annotator-editor/src/main/java/de/tudarmstadt/ukp/inception/apacheannotatoreditor/ApacheAnnotatorHtmlAnnotationEditorFactoryUserPreferences.schema.json index a96ebace1eb..813f7cc8526 100644 --- a/inception/inception-html-apache-annotator-editor/src/main/java/de/tudarmstadt/ukp/inception/apacheannotatoreditor/ApacheAnnotatorHtmlAnnotationEditorFactoryUserPreferences.schema.json +++ b/inception/inception-html-apache-annotator-editor/src/main/java/de/tudarmstadt/ukp/inception/apacheannotatoreditor/ApacheAnnotatorHtmlAnnotationEditorFactoryUserPreferences.schema.json @@ -8,6 +8,12 @@ "showAggregatedLabels": { "type": "boolean" }, + "showImages": { + "type": "boolean" + }, + "showTables": { + "type": "boolean" + }, "showEmptyHighlights": { "type": "boolean" }, diff --git a/inception/inception-recommendation/src/main/resources/META-INF/asciidoc/admin-guide/settings_recommender.adoc b/inception/inception-recommendation/src/main/resources/META-INF/asciidoc/admin-guide/settings_recommender.adoc index 5fb149c7ddf..833b61b7b53 100644 --- a/inception/inception-recommendation/src/main/resources/META-INF/asciidoc/admin-guide/settings_recommender.adoc +++ b/inception/inception-recommendation/src/main/resources/META-INF/asciidoc/admin-guide/settings_recommender.adoc @@ -32,11 +32,6 @@ This section describes the global settings related to the recommender module. | `true` | `false` -| `recommender.evaluation-page.enabled` -| enable/disable evaluation page -| `true` -| `false` - | `recommender.sidebar.enabled` | enable/disable recommender sidebar on annotation page | `true`