From 7441a2af058ede180964b9df3c0aa54fd420ba48 Mon Sep 17 00:00:00 2001 From: David Suarez Date: Fri, 6 Apr 2018 20:18:41 +0200 Subject: [PATCH] Minor changes - Remove some redundant final modifiers - Remove redundant semicolons - Remove redundant continue - Add default resources path Signed-off-by: David Suarez --- src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java | 7 ++++--- src/main/java/eus/ixa/ixa/pipe/ml/utils/Span.java | 8 ++++---- src/main/java/eus/ixa/ixa/pipe/ml/utils/StringUtils.java | 6 +----- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java b/src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java index 51df8f3..99ac7bc 100644 --- a/src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java +++ b/src/main/java/eus/ixa/ixa/pipe/ml/utils/IOUtils.java @@ -63,6 +63,7 @@ public final class IOUtils { public static final int BUFFER_SIZE = 65536; public static final String SPACE_DELIMITER = " "; public static final String TAB_DELIMITER = "\t"; + private static final String DEFAULT_RESOURCES_PATH = "src/main/resources"; /** * Private constructor. This class should only be used statically. @@ -77,7 +78,7 @@ private IOUtils() { * the dictionary path * @return the dictionary path without punctuation */ - public static final String normalizeLexiconName(String resource) { + public static String normalizeLexiconName(String resource) { resource = resource.replaceAll("\\p{P}", ""); return resource; } @@ -91,7 +92,7 @@ public static final String normalizeLexiconName(String resource) { * the name of the resource (absolute path with no starting /) * @return the inputstream of the dictionary */ - public static final InputStream getDictionaryResource(final String resource) { + public static InputStream getDictionaryResource(final String resource) { InputStream dictInputStream; final Path resourcePath = Paths.get(resource); @@ -117,7 +118,7 @@ public static final InputStream getDictionaryResource(final String resource) { private static InputStream getStreamFromClassPath( final String normalizedPath) { InputStream dictInputStream = null; - final String[] dictPaths = normalizedPath.split("src/main/resources"); + final String[] dictPaths = normalizedPath.split(DEFAULT_RESOURCES_PATH); if (dictPaths.length == 2) { dictInputStream = IOUtils.class.getClassLoader() .getResourceAsStream(dictPaths[1]); diff --git a/src/main/java/eus/ixa/ixa/pipe/ml/utils/Span.java b/src/main/java/eus/ixa/ixa/pipe/ml/utils/Span.java index af2d56a..fd1e4eb 100644 --- a/src/main/java/eus/ixa/ixa/pipe/ml/utils/Span.java +++ b/src/main/java/eus/ixa/ixa/pipe/ml/utils/Span.java @@ -455,8 +455,8 @@ public static String[] getTypesFromSpans(final Span[] spans, * @param postList * the list of spans to do the post-processing */ - public static final void postProcessDuplicatedSpans(final List preList, - final Span[] postList) { + public static void postProcessDuplicatedSpans(final List preList, + final Span[] postList) { final List duplicatedSpans = new ArrayList(); for (final Span span1 : preList) { for (final Span span2 : postList) { @@ -479,8 +479,8 @@ public static final void postProcessDuplicatedSpans(final List preList, * @param neSpans * the spans to be added to allSpans */ - public static final void concatenateSpans(final List allSpans, - final Span[] neSpans) { + public static void concatenateSpans(final List allSpans, + final Span[] neSpans) { for (final Span span : neSpans) { allSpans.add(span); } diff --git a/src/main/java/eus/ixa/ixa/pipe/ml/utils/StringUtils.java b/src/main/java/eus/ixa/ixa/pipe/ml/utils/StringUtils.java index 12535cb..1900aec 100644 --- a/src/main/java/eus/ixa/ixa/pipe/ml/utils/StringUtils.java +++ b/src/main/java/eus/ixa/ixa/pipe/ml/utils/StringUtils.java @@ -38,7 +38,7 @@ public final class StringUtils { /** * Pattern to remove double bars from disjunct regex. */ - public static Pattern doubleBar = Pattern.compile("\\|\\|"); + public static final Pattern doubleBar = Pattern.compile("\\|\\|"); /** * Private constructor. @@ -67,7 +67,6 @@ public static List exactTokenFinderIgnoreCase(final String pattern, for (j = 0; j <= sentenceLength - patternLength; ++j) { for (i = 0; i < patternLength && patternTokens[i].equalsIgnoreCase(tokens[i + j]); ++i) { - ; } if (i >= patternLength) { neTokens.add(j); @@ -97,7 +96,6 @@ public static List exactTokenFinder(final String pattern, for (j = 0; j <= sentenceLength - patternLength; ++j) { for (i = 0; i < patternLength && patternTokens[i].equals(tokens[i + j]); ++i) { - ; } if (i >= patternLength) { neTokens.add(j); @@ -130,7 +128,6 @@ public static List exactStringFinder(final String pattern, for (j = 0; j <= sentenceLength - patternLength; ++j) { for (i = 0; i < patternLength && patternArray[i] == sentenceArray[i + j]; ++i) { - ; } if (i >= patternLength) { neChars.add(j); @@ -326,7 +323,6 @@ public static void computeShortestEditScript(final String wordForm, if (lemmaLength > 0 && distance[wordFormLength][lemmaLength - 1] == distance[wordFormLength][lemmaLength]) { lemmaLength--; - continue; } } }