From bf90d2225e9d94ed741a19ce2200dd80c49a17b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Kottmann?= Date: Thu, 12 Jan 2017 01:20:48 +0100 Subject: [PATCH] OPENNLP-923: Wrap all lines longer than 110 chars --- .../builder/POSDictionayBuilderTest.java | 3 +- .../tools/chunker/ChunkSampleTest.java | 7 ++- .../doccat/DocumentCategorizerNBTest.java | 3 +- .../tools/eval/Conll02NameFinderEval.java | 60 ++++++++++++------- .../formats/ad/ADParagraphStreamTest.java | 3 +- .../tools/formats/muc/SgmlParserTest.java | 3 +- .../languagemodel/LanguageModelTestUtils.java | 6 +- .../languagemodel/NgramLanguageModelTest.java | 33 ++++++---- .../tools/ml/maxent/RealValueModelTest.java | 20 ++++--- .../naivebayes/NaiveBayesCorrectnessTest.java | 14 +++-- .../tools/namefind/NameFinderMETest.java | 3 +- .../tools/namefind/NameSampleTest.java | 4 +- .../opennlp/tools/ngram/NGramModelTest.java | 7 ++- .../opennlp/tools/ngram/NGramUtilsTest.java | 9 ++- .../java/opennlp/tools/parser/ParseTest.java | 8 ++- .../tools/parser/chunking/ParserTest.java | 3 +- .../uima/AnnotatorsInitializationTest.java | 3 +- 17 files changed, 124 insertions(+), 65 deletions(-) diff --git a/opennlp-morfologik-addon/src/test/java/opennlp/morfologik/builder/POSDictionayBuilderTest.java b/opennlp-morfologik-addon/src/test/java/opennlp/morfologik/builder/POSDictionayBuilderTest.java index c3a93f624..d644da029 100644 --- a/opennlp-morfologik-addon/src/test/java/opennlp/morfologik/builder/POSDictionayBuilderTest.java +++ b/opennlp-morfologik-addon/src/test/java/opennlp/morfologik/builder/POSDictionayBuilderTest.java @@ -63,7 +63,8 @@ public static void main(String[] args) throws Exception { // we need the tabular dictionary. It is mandatory to have info // file with same name, but .info extension - Path textLemmaDictionary = Paths.get("/Users/wcolen/git/opennlp/opennlp-morfologik-addon/src/test/resources/dictionaryWithLemma.txt"); + Path textLemmaDictionary = Paths.get( + "/Users/wcolen/git/opennlp/opennlp-morfologik-addon/src/test/resources/dictionaryWithLemma.txt"); // this will build a binary dictionary located in compiledLemmaDictionary Path compiledLemmaDictionary = new MorfologikDictionayBuilder() diff --git a/opennlp-tools/src/test/java/opennlp/tools/chunker/ChunkSampleTest.java b/opennlp-tools/src/test/java/opennlp/tools/chunker/ChunkSampleTest.java index f7832fa44..c2561eecb 100644 --- a/opennlp-tools/src/test/java/opennlp/tools/chunker/ChunkSampleTest.java +++ b/opennlp-tools/src/test/java/opennlp/tools/chunker/ChunkSampleTest.java @@ -141,9 +141,10 @@ public void testNicePrint() { ChunkSample sample = new ChunkSample(createSentence(), createTags(), createChunks()); - assertEquals(" [NP Forecasts_NNS ] [PP for_IN ] [NP the_DT trade_NN figures_NNS ] " + - "[VP range_VBP ] [ADVP widely_RB ] ,_, [NP Forecasts_NNS ] [PP for_IN ] [NP the_DT trade_NN figures_NNS ] " + - "[VP range_VBP ] [ADVP widely_RB ] ._.", sample.nicePrint()); + assertEquals(" [NP Forecasts_NNS ] [PP for_IN ] [NP the_DT trade_NN figures_NNS ] " + + "[VP range_VBP ] [ADVP widely_RB ] ,_, [NP Forecasts_NNS ] [PP for_IN ] " + + "[NP the_DT trade_NN figures_NNS ] " + + "[VP range_VBP ] [ADVP widely_RB ] ._.", sample.nicePrint()); } @Test diff --git a/opennlp-tools/src/test/java/opennlp/tools/doccat/DocumentCategorizerNBTest.java b/opennlp-tools/src/test/java/opennlp/tools/doccat/DocumentCategorizerNBTest.java index 99586931e..ad30f4a6a 100644 --- a/opennlp-tools/src/test/java/opennlp/tools/doccat/DocumentCategorizerNBTest.java +++ b/opennlp-tools/src/test/java/opennlp/tools/doccat/DocumentCategorizerNBTest.java @@ -36,7 +36,8 @@ public class DocumentCategorizerNBTest { @Test public void testSimpleTraining() throws IOException { - ObjectStream samples = ObjectStreamUtils.createObjectStream(new DocumentSample("1", new String[]{"a", "b", "c"}), + ObjectStream samples = ObjectStreamUtils.createObjectStream( + new DocumentSample("1", new String[]{"a", "b", "c"}), new DocumentSample("1", new String[]{"a", "b", "c", "1", "2"}), new DocumentSample("1", new String[]{"a", "b", "c", "3", "4"}), new DocumentSample("0", new String[]{"x", "y", "z"}), diff --git a/opennlp-tools/src/test/java/opennlp/tools/eval/Conll02NameFinderEval.java b/opennlp-tools/src/test/java/opennlp/tools/eval/Conll02NameFinderEval.java index f51e7ff5d..da579bb0f 100644 --- a/opennlp-tools/src/test/java/opennlp/tools/eval/Conll02NameFinderEval.java +++ b/opennlp-tools/src/test/java/opennlp/tools/eval/Conll02NameFinderEval.java @@ -82,10 +82,12 @@ public void evalDutchPerson() throws IOException { Conll02NameSampleStream.GENERATE_PERSON_ENTITIES); eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(), - "conll02/ner/data/ned.testa"), LANGUAGE.NL, Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.5696539485359361d); + "conll02/ner/data/ned.testa"), LANGUAGE.NL, + Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.5696539485359361d); eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(), - "conll02/ner/data/ned.testb"), LANGUAGE.NL, Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.7127771911298839d); + "conll02/ner/data/ned.testb"), LANGUAGE.NL, + Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.7127771911298839d); } @Test @@ -97,10 +99,12 @@ public void evalDutchOrganization() throws IOException { Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES); eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(), - "conll02/ner/data/ned.testa"), LANGUAGE.NL, Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.5197969543147207d); + "conll02/ner/data/ned.testa"), LANGUAGE.NL, + Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.5197969543147207d); eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(), - "conll02/ner/data/ned.testb"), LANGUAGE.NL, Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.5753228120516498d); + "conll02/ner/data/ned.testb"), LANGUAGE.NL, + Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.5753228120516498d); } @Test @@ -112,10 +116,12 @@ public void evalDutchLocation() throws IOException { Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES); eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(), - "conll02/ner/data/ned.testa"), LANGUAGE.NL, Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.5451977401129944d); + "conll02/ner/data/ned.testa"), LANGUAGE.NL, + Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.5451977401129944d); eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(), - "conll02/ner/data/ned.testb"), LANGUAGE.NL, Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.680952380952381d); + "conll02/ner/data/ned.testb"), LANGUAGE.NL, + Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.680952380952381d); } @Test @@ -127,18 +133,22 @@ public void evalDutchMisc() throws IOException { Conll02NameSampleStream.GENERATE_MISC_ENTITIES); eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(), - "conll02/ner/data/ned.testa"), LANGUAGE.NL, Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.5831157528285466d); + "conll02/ner/data/ned.testa"), LANGUAGE.NL, + Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.5831157528285466d); eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(), - "conll02/ner/data/ned.testb"), LANGUAGE.NL, Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.5762897914379803d); + "conll02/ner/data/ned.testb"), LANGUAGE.NL, + Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.5762897914379803d); } @Test public void evalDutchCombined() throws IOException { TrainingParameters params = ModelUtil.createDefaultTrainingParameters(); - int combinedType = Conll02NameSampleStream.GENERATE_PERSON_ENTITIES | Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES - | Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES | Conll02NameSampleStream.GENERATE_MISC_ENTITIES; + int combinedType = Conll02NameSampleStream.GENERATE_PERSON_ENTITIES + | Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES + | Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES + | Conll02NameSampleStream.GENERATE_MISC_ENTITIES; TokenNameFinderModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(), "conll02/ner/data/ned.train"), LANGUAGE.NL, params, @@ -160,10 +170,12 @@ public void evalSpanishPerson() throws IOException { Conll02NameSampleStream.GENERATE_PERSON_ENTITIES); eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(), - "conll02/ner/data/esp.testa"), LANGUAGE.ES, Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.686960933536276d); + "conll02/ner/data/esp.testa"), LANGUAGE.ES, + Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.686960933536276d); eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(), - "conll02/ner/data/esp.testb"), LANGUAGE.ES, Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.8132033008252063d); + "conll02/ner/data/esp.testb"), LANGUAGE.ES, + Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.8132033008252063d); } @Test @@ -175,10 +187,12 @@ public void evalSpanishOrganization() throws IOException { Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES); eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(), - "conll02/ner/data/esp.testa"), LANGUAGE.ES, Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.6982288828337874d); + "conll02/ner/data/esp.testa"), LANGUAGE.ES, + Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.6982288828337874d); eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(), - "conll02/ner/data/esp.testb"), LANGUAGE.ES, Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.7640449438202247d); + "conll02/ner/data/esp.testb"), LANGUAGE.ES, + Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.7640449438202247d); } @Test @@ -190,10 +204,12 @@ public void evalSpanishLocation() throws IOException { Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES); eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(), - "conll02/ner/data/esp.testa"), LANGUAGE.ES, Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.7386907929749867d); + "conll02/ner/data/esp.testa"), LANGUAGE.ES, + Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.7386907929749867d); eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(), - "conll02/ner/data/esp.testb"), LANGUAGE.ES, Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.6772777167947311d); + "conll02/ner/data/esp.testb"), LANGUAGE.ES, + Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.6772777167947311d); } @Test @@ -205,18 +221,22 @@ public void evalSpanishMisc() throws IOException { Conll02NameSampleStream.GENERATE_MISC_ENTITIES); eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(), - "conll02/ner/data/esp.testa"), LANGUAGE.ES, Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.40971168437025796d); + "conll02/ner/data/esp.testa"), LANGUAGE.ES, + Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.40971168437025796d); eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(), - "conll02/ner/data/esp.testb"), LANGUAGE.ES, Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.45703124999999994d); + "conll02/ner/data/esp.testb"), LANGUAGE.ES, + Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.45703124999999994d); } @Test public void evalSpanishCombined() throws IOException { TrainingParameters params = ModelUtil.createDefaultTrainingParameters(); - int combinedType = Conll02NameSampleStream.GENERATE_PERSON_ENTITIES | Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES - | Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES | Conll02NameSampleStream.GENERATE_MISC_ENTITIES; + int combinedType = Conll02NameSampleStream.GENERATE_PERSON_ENTITIES + | Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES + | Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES + | Conll02NameSampleStream.GENERATE_MISC_ENTITIES; TokenNameFinderModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(), "conll02/ner/data/esp.train"), LANGUAGE.ES, params, diff --git a/opennlp-tools/src/test/java/opennlp/tools/formats/ad/ADParagraphStreamTest.java b/opennlp-tools/src/test/java/opennlp/tools/formats/ad/ADParagraphStreamTest.java index 469eb6523..f3a95b93f 100644 --- a/opennlp-tools/src/test/java/opennlp/tools/formats/ad/ADParagraphStreamTest.java +++ b/opennlp-tools/src/test/java/opennlp/tools/formats/ad/ADParagraphStreamTest.java @@ -65,7 +65,8 @@ public void testLeadingWithContraction() throws IOException { } private static ADSentenceStream openData() throws IOException { - InputStreamFactory in = new ResourceAsStreamFactory(ADParagraphStreamTest.class, "/opennlp/tools/formats/ad.sample"); + InputStreamFactory in = new ResourceAsStreamFactory(ADParagraphStreamTest.class, + "/opennlp/tools/formats/ad.sample"); return new ADSentenceStream(new PlainTextByLineStream(in, "UTF-8")); } diff --git a/opennlp-tools/src/test/java/opennlp/tools/formats/muc/SgmlParserTest.java b/opennlp-tools/src/test/java/opennlp/tools/formats/muc/SgmlParserTest.java index 87aad7cbe..b69f01ef5 100644 --- a/opennlp-tools/src/test/java/opennlp/tools/formats/muc/SgmlParserTest.java +++ b/opennlp-tools/src/test/java/opennlp/tools/formats/muc/SgmlParserTest.java @@ -28,7 +28,8 @@ public class SgmlParserTest { @Test public void testParse1() throws IOException { - try (Reader in = new InputStreamReader(SgmlParserTest.class.getResourceAsStream("parsertest1.sgml"), "UTF-8")) { + try (Reader in = new InputStreamReader( + SgmlParserTest.class.getResourceAsStream("parsertest1.sgml"), "UTF-8")) { SgmlParser parser = new SgmlParser(); parser.parse(in, new SgmlParser.ContentHandler() { }); diff --git a/opennlp-tools/src/test/java/opennlp/tools/languagemodel/LanguageModelTestUtils.java b/opennlp-tools/src/test/java/opennlp/tools/languagemodel/LanguageModelTestUtils.java index ec16cf448..c1490dfc2 100644 --- a/opennlp-tools/src/test/java/opennlp/tools/languagemodel/LanguageModelTestUtils.java +++ b/opennlp-tools/src/test/java/opennlp/tools/languagemodel/LanguageModelTestUtils.java @@ -60,13 +60,15 @@ public static StringList generateRandomSentence() { return new StringList(sentence); } - public static double getPerplexity(LanguageModel lm, Collection testSet, int ngramSize) throws ArithmeticException { + public static double getPerplexity(LanguageModel lm, Collection testSet, int ngramSize) + throws ArithmeticException { BigDecimal perplexity = new BigDecimal(1d); for (StringList sentence : testSet) { for (StringList ngram : NGramUtils.getNGrams(sentence, ngramSize)) { double ngramProbability = lm.calculateProbability(ngram); - perplexity = perplexity.multiply(new BigDecimal(1d).divide(new BigDecimal(ngramProbability), CONTEXT)); + perplexity = perplexity.multiply(new BigDecimal(1d).divide( + new BigDecimal(ngramProbability), CONTEXT)); } } diff --git a/opennlp-tools/src/test/java/opennlp/tools/languagemodel/NgramLanguageModelTest.java b/opennlp-tools/src/test/java/opennlp/tools/languagemodel/NgramLanguageModelTest.java index 4bff0a408..62162b8e5 100644 --- a/opennlp-tools/src/test/java/opennlp/tools/languagemodel/NgramLanguageModelTest.java +++ b/opennlp-tools/src/test/java/opennlp/tools/languagemodel/NgramLanguageModelTest.java @@ -40,8 +40,10 @@ public class NgramLanguageModelTest { @Test public void testEmptyVocabularyProbability() throws Exception { NGramLanguageModel model = new NGramLanguageModel(); - assertEquals("probability with an empty vocabulary is always 0", 0d, model.calculateProbability(new StringList("")), 0d); - assertEquals("probability with an empty vocabulary is always 0", 0d, model.calculateProbability(new StringList("1", "2", "3")), 0d); + assertEquals("probability with an empty vocabulary is always 0", + 0d, model.calculateProbability(new StringList("")), 0d); + assertEquals("probability with an empty vocabulary is always 0", + 0d, model.calculateProbability(new StringList("1", "2", "3")), 0d); } @Test @@ -51,7 +53,8 @@ public void testRandomVocabularyAndSentence() throws Exception { model.add(sentence, 2, 3); } double probability = model.calculateProbability(LanguageModelTestUtils.generateRandomSentence()); - assertTrue("a probability measure should be between 0 and 1 [was " + probability + "]", probability >= 0 && probability <= 1); + assertTrue("a probability measure should be between 0 and 1 [was " + + probability + "]", probability >= 0 && probability <= 1); } @Test @@ -61,7 +64,8 @@ public void testNgramModel() throws Exception { model.add(new StringList("the", "red", "house"), 1, 4); model.add(new StringList("I", "saw", "something", "nice"), 1, 2); double probability = model.calculateProbability(new StringList("I", "saw", "the", "red", "house")); - assertTrue("a probability measure should be between 0 and 1 [was " + probability + "]", probability >= 0 && probability <= 1); + assertTrue("a probability measure should be between 0 and 1 [was " + + probability + "]", probability >= 0 && probability <= 1); StringList tokens = model.predictNextTokens(new StringList("I", "saw")); assertNotNull(tokens); @@ -97,7 +101,8 @@ public void testTrigram() throws Exception { model.add(new StringList("the", "red", "house"), 2, 3); model.add(new StringList("I", "saw", "something", "nice"), 2, 3); double probability = model.calculateProbability(new StringList("I", "saw", "the", "red", "house")); - assertTrue("a probability measure should be between 0 and 1 [was " + probability + "]", probability >= 0 && probability <= 1); + assertTrue("a probability measure should be between 0 and 1 [was " + + probability + "]", probability >= 0 && probability <= 1); StringList tokens = model.predictNextTokens(new StringList("I", "saw")); assertNotNull(tokens); @@ -111,7 +116,8 @@ public void testBigram() throws Exception { model.add(new StringList("the", "red", "house"), 1, 2); model.add(new StringList("I", "saw", "something", "nice"), 1, 2); double probability = model.calculateProbability(new StringList("I", "saw", "the", "red", "house")); - assertTrue("a probability measure should be between 0 and 1 [was " + probability + "]", probability >= 0 && probability <= 1); + assertTrue("a probability measure should be between 0 and 1 [was " + probability + "]", + probability >= 0 && probability <= 1); StringList tokens = model.predictNextTokens(new StringList("I", "saw")); assertNotNull(tokens); @@ -120,9 +126,11 @@ public void testBigram() throws Exception { @Test public void testSerializedNGramLanguageModel() throws Exception { - NGramLanguageModel languageModel = new NGramLanguageModel(getClass().getResourceAsStream("/opennlp/tools/ngram/ngram-model.xml"), 3); + NGramLanguageModel languageModel = new NGramLanguageModel(getClass().getResourceAsStream( + "/opennlp/tools/ngram/ngram-model.xml"), 3); double probability = languageModel.calculateProbability(new StringList("The", "brown", "fox", "jumped")); - assertTrue("a probability measure should be between 0 and 1 [was " + probability + "]", probability >= 0 && probability <= 1); + assertTrue("a probability measure should be between 0 and 1 [was " + probability + "]", + probability >= 0 && probability <= 1); StringList tokens = languageModel.predictNextTokens(new StringList("fox")); assertNotNull(tokens); assertEquals(new StringList("jumped"), tokens); @@ -144,11 +152,14 @@ public void testTrigramLanguageModelCreationFromText() throws Exception { } } } - StringList tokens = languageModel.predictNextTokens(new StringList("neural", "network", "language")); + StringList tokens = languageModel.predictNextTokens(new StringList("neural", + "network", "language")); assertNotNull(tokens); assertEquals(new StringList("models"), tokens); - double p1 = languageModel.calculateProbability(new StringList("neural", "network", "language", "models")); - double p2 = languageModel.calculateProbability(new StringList("neural", "network", "language", "model")); + double p1 = languageModel.calculateProbability(new StringList("neural", "network", + "language", "models")); + double p2 = languageModel.calculateProbability(new StringList("neural", "network", + "language", "model")); assertTrue(p1 > p2); } } diff --git a/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/RealValueModelTest.java b/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/RealValueModelTest.java index a841964dc..a8e96c3c8 100644 --- a/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/RealValueModelTest.java +++ b/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/RealValueModelTest.java @@ -30,14 +30,14 @@ public class RealValueModelTest { @Test public void testRealValuedWeightsVsRepeatWeighting() throws IOException { GISModel realModel; - try (RealValueFileEventStream rvfes1 = - new RealValueFileEventStream("src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt")) { + try (RealValueFileEventStream rvfes1 = new RealValueFileEventStream( + "src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt")) { realModel = GIS.trainModel(100, new OnePassRealValueDataIndexer(rvfes1, 1)); } GISModel repeatModel; - try (FileEventStream rvfes2 = - new FileEventStream("src/test/resources/data/opennlp/maxent/repeat-weighting-training-data.txt")) { + try (FileEventStream rvfes2 = new FileEventStream( + "src/test/resources/data/opennlp/maxent/repeat-weighting-training-data.txt")) { repeatModel = GIS.trainModel(100, new OnePassRealValueDataIndexer(rvfes2, 1)); } @@ -47,8 +47,10 @@ public void testRealValuedWeightsVsRepeatWeighting() throws IOException { Assert.assertEquals(realResults.length, repeatResults.length); for (int i = 0; i < realResults.length; i++) { - System.out.println(String.format("classifiy with realModel: %1$s = %2$f", realModel.getOutcome(i), realResults[i])); - System.out.println(String.format("classifiy with repeatModel: %1$s = %2$f", repeatModel.getOutcome(i), repeatResults[i])); + System.out.println(String.format("classifiy with realModel: %1$s = %2$f", + realModel.getOutcome(i), realResults[i])); + System.out.println(String.format("classifiy with repeatModel: %1$s = %2$f", + repeatModel.getOutcome(i), repeatResults[i])); Assert.assertEquals(realResults[i], repeatResults[i], 0.01f); } @@ -59,8 +61,10 @@ public void testRealValuedWeightsVsRepeatWeighting() throws IOException { System.out.println(); Assert.assertEquals(realResults.length, repeatResults.length); for (int i = 0; i < realResults.length; i++) { - System.out.println(String.format("classifiy with realModel: %1$s = %2$f", realModel.getOutcome(i), realResults[i])); - System.out.println(String.format("classifiy with repeatModel: %1$s = %2$f", repeatModel.getOutcome(i), repeatResults[i])); + System.out.println(String.format("classifiy with realModel: %1$s = %2$f", + realModel.getOutcome(i), realResults[i])); + System.out.println(String.format("classifiy with repeatModel: %1$s = %2$f", + repeatModel.getOutcome(i), repeatResults[i])); Assert.assertEquals(realResults[i], repeatResults[i], 0.01f); } diff --git a/opennlp-tools/src/test/java/opennlp/tools/ml/naivebayes/NaiveBayesCorrectnessTest.java b/opennlp-tools/src/test/java/opennlp/tools/ml/naivebayes/NaiveBayesCorrectnessTest.java index e0f659c03..f115e8b08 100644 --- a/opennlp-tools/src/test/java/opennlp/tools/ml/naivebayes/NaiveBayesCorrectnessTest.java +++ b/opennlp-tools/src/test/java/opennlp/tools/ml/naivebayes/NaiveBayesCorrectnessTest.java @@ -39,7 +39,8 @@ public class NaiveBayesCorrectnessTest { public void testNaiveBayes1() throws IOException { NaiveBayesModel model = - (NaiveBayesModel) new NaiveBayesTrainer().trainModel(new TwoPassDataIndexer(createTrainingStream(), 1, false)); + (NaiveBayesModel) new NaiveBayesTrainer().trainModel( + new TwoPassDataIndexer(createTrainingStream(), 1, false)); String label = "politics"; String[] context = {"bow=united", "bow=nations"}; @@ -54,7 +55,8 @@ public void testNaiveBayes1() throws IOException { public void testNaiveBayes2() throws IOException { NaiveBayesModel model = - (NaiveBayesModel) new NaiveBayesTrainer().trainModel(new TwoPassDataIndexer(createTrainingStream(), 1, false)); + (NaiveBayesModel) new NaiveBayesTrainer().trainModel( + new TwoPassDataIndexer(createTrainingStream(), 1, false)); String label = "sports"; String[] context = {"bow=manchester", "bow=united"}; @@ -69,7 +71,8 @@ public void testNaiveBayes2() throws IOException { public void testNaiveBayes3() throws IOException { NaiveBayesModel model = - (NaiveBayesModel) new NaiveBayesTrainer().trainModel(new TwoPassDataIndexer(createTrainingStream(), 1, false)); + (NaiveBayesModel) new NaiveBayesTrainer().trainModel( + new TwoPassDataIndexer(createTrainingStream(), 1, false)); String label = "politics"; String[] context = {"bow=united"}; @@ -84,7 +87,8 @@ public void testNaiveBayes3() throws IOException { public void testNaiveBayes4() throws IOException { NaiveBayesModel model = - (NaiveBayesModel) new NaiveBayesTrainer().trainModel(new TwoPassDataIndexer(createTrainingStream(), 1, false)); + (NaiveBayesModel) new NaiveBayesTrainer().trainModel( + new TwoPassDataIndexer(createTrainingStream(), 1, false)); String label = "politics"; String[] context = {}; @@ -135,4 +139,4 @@ public static ObjectStream createTrainingStream() throws IOException { return ObjectStreamUtils.createObjectStream(trainingEvents); } -} \ No newline at end of file +} diff --git a/opennlp-tools/src/test/java/opennlp/tools/namefind/NameFinderMETest.java b/opennlp-tools/src/test/java/opennlp/tools/namefind/NameFinderMETest.java index bf1125010..010969485 100644 --- a/opennlp-tools/src/test/java/opennlp/tools/namefind/NameFinderMETest.java +++ b/opennlp-tools/src/test/java/opennlp/tools/namefind/NameFinderMETest.java @@ -232,7 +232,8 @@ public void testOnlyWithNamesTypeOverride() throws Exception { } /** - * Train NamefinderME using OnlyWithNamesWithTypes.train. The goal is to check if the model validator accepts it. + * Train NamefinderME using OnlyWithNamesWithTypes.train. + * The goal is to check if the model validator accepts it. * This is related to the issue OPENNLP-9 */ @Test diff --git a/opennlp-tools/src/test/java/opennlp/tools/namefind/NameSampleTest.java b/opennlp-tools/src/test/java/opennlp/tools/namefind/NameSampleTest.java index 4fb9ab736..3da8a69d6 100644 --- a/opennlp-tools/src/test/java/opennlp/tools/namefind/NameSampleTest.java +++ b/opennlp-tools/src/test/java/opennlp/tools/namefind/NameSampleTest.java @@ -84,7 +84,9 @@ public void testNoTypesToString() { @Test public void testWithTypesToString() throws Exception { String nameSampleStr = createSimpleNameSample(true).toString(); - assertEquals(" U . S . President Barack Obama is considering sending additional American forces to Afghanistan .", nameSampleStr); + assertEquals(" U . S . President Barack Obama " + + "is considering sending additional American forces to Afghanistan .", + nameSampleStr); NameSample parsedSample = NameSample.parse(" U . S . " + "President Barack Obama is considering sending " + diff --git a/opennlp-tools/src/test/java/opennlp/tools/ngram/NGramModelTest.java b/opennlp-tools/src/test/java/opennlp/tools/ngram/NGramModelTest.java index 190232066..308cfcf1a 100644 --- a/opennlp-tools/src/test/java/opennlp/tools/ngram/NGramModelTest.java +++ b/opennlp-tools/src/test/java/opennlp/tools/ngram/NGramModelTest.java @@ -195,7 +195,8 @@ public void testSerialize() throws Exception { String asfHeaderString = modelString.substring(start, end + 3); modelString = modelString.replace(asfHeaderString, ""); String outputString = out.toString(Charset.forName("UTF-8").name()); - assertEquals(modelString.replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", "").replaceAll(" ", ""), - outputString.replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", "").replaceAll(" ", "")); + assertEquals( + modelString.replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", "").replaceAll(" ", ""), + outputString.replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", "").replaceAll(" ", "")); } -} \ No newline at end of file +} diff --git a/opennlp-tools/src/test/java/opennlp/tools/ngram/NGramUtilsTest.java b/opennlp-tools/src/test/java/opennlp/tools/ngram/NGramUtilsTest.java index 29115b1bb..3d4f95b6d 100644 --- a/opennlp-tools/src/test/java/opennlp/tools/ngram/NGramUtilsTest.java +++ b/opennlp-tools/src/test/java/opennlp/tools/ngram/NGramUtilsTest.java @@ -82,7 +82,8 @@ public void testLinearInterpolation() throws Exception { set.add(new StringList("his", "green", "house", "STOP")); set.add(new StringList("book", "STOP")); Double lambda = 1d / 3d; - Double d = NGramUtils.calculateTrigramLinearInterpolationProbability("the", "green", "book", set, lambda, lambda, lambda); + Double d = NGramUtils.calculateTrigramLinearInterpolationProbability("the", "green", + "book", set, lambda, lambda, lambda); assertNotNull(d); assertEquals("wrong result", Double.valueOf(0.5714285714285714d), d); } @@ -93,14 +94,16 @@ public void testLinearInterpolation2() throws Exception { set.add(new StringList("D", "N", "V", "STOP")); set.add(new StringList("D", "N", "V", "STOP")); Double lambda = 1d / 3d; - Double d = NGramUtils.calculateTrigramLinearInterpolationProbability("N", "V", "STOP", set, lambda, lambda, lambda); + Double d = NGramUtils.calculateTrigramLinearInterpolationProbability("N", "V", + "STOP", set, lambda, lambda, lambda); assertNotNull(d); assertEquals("wrong result", Double.valueOf(0.75d), d); } @Test public void testGetNGrams() throws Exception { - Collection nGrams = NGramUtils.getNGrams(new StringList("I", "saw", "brown", "fox"), 2); + Collection nGrams = NGramUtils.getNGrams(new StringList("I", + "saw", "brown", "fox"), 2); assertEquals(3, nGrams.size()); nGrams = NGramUtils.getNGrams(new StringList("I", "saw", "brown", "fox"), 3); assertEquals(2, nGrams.size()); diff --git a/opennlp-tools/src/test/java/opennlp/tools/parser/ParseTest.java b/opennlp-tools/src/test/java/opennlp/tools/parser/ParseTest.java index e9645ad33..e0cea8c4c 100644 --- a/opennlp-tools/src/test/java/opennlp/tools/parser/ParseTest.java +++ b/opennlp-tools/src/test/java/opennlp/tools/parser/ParseTest.java @@ -27,7 +27,10 @@ */ public class ParseTest { - public static final String PARSE_STRING = "(TOP (S (S (NP-SBJ (PRP She) )(VP (VBD was) (ADVP (RB just) )(NP-PRD (NP (DT another) (NN freighter) )(PP (IN from) (NP (DT the) (NNPS States) )))))(, ,) (CC and) (S (NP-SBJ (PRP she) )(VP (VBD seemed) (ADJP-PRD (ADJP (RB as) (JJ commonplace) )(PP (IN as) (NP (PRP$ her) (NN name) )))))(. .) ))"; + public static final String PARSE_STRING = "(TOP (S (S (NP-SBJ (PRP She) )(VP (VBD was) " + + "(ADVP (RB just) )(NP-PRD (NP (DT another) (NN freighter) )(PP (IN from) (NP (DT the) " + + "(NNPS States) )))))(, ,) (CC and) (S (NP-SBJ (PRP she) )(VP (VBD seemed) " + + "(ADJP-PRD (ADJP (RB as) (JJ commonplace) )(PP (IN as) (NP (PRP$ her) (NN name) )))))(. .) ))"; @Test public void testToHashCode() { @@ -60,7 +63,8 @@ public void testGetText() { Parse p = Parse.parseParse(PARSE_STRING); // TODO: Why does parse attaches a space to the end of the text ??? - String expectedText = "She was just another freighter from the States , and she seemed as commonplace as her name . "; + String expectedText = "She was just another freighter from the States , " + + "and she seemed as commonplace as her name . "; assertEquals(expectedText, p.getText()); } diff --git a/opennlp-tools/src/test/java/opennlp/tools/parser/chunking/ParserTest.java b/opennlp-tools/src/test/java/opennlp/tools/parser/chunking/ParserTest.java index 9aed029b8..e681ad056 100644 --- a/opennlp-tools/src/test/java/opennlp/tools/parser/chunking/ParserTest.java +++ b/opennlp-tools/src/test/java/opennlp/tools/parser/chunking/ParserTest.java @@ -45,7 +45,8 @@ public void testChunkingParserTraining() throws Exception { ObjectStream parseSamples = ParserTestUtil.openTestTrainingData(); HeadRules headRules = ParserTestUtil.createTestHeadRules(); - ParserModel model = Parser.train("en", parseSamples, headRules, TrainingParameters.defaultParams()); + ParserModel model = Parser.train("en", parseSamples, headRules, + TrainingParameters.defaultParams()); opennlp.tools.parser.Parser parser = ParserFactory.create(model); diff --git a/opennlp-uima/src/test/java/opennlp/uima/AnnotatorsInitializationTest.java b/opennlp-uima/src/test/java/opennlp/uima/AnnotatorsInitializationTest.java index 7e77a6dd6..95248a2a4 100644 --- a/opennlp-uima/src/test/java/opennlp/uima/AnnotatorsInitializationTest.java +++ b/opennlp-uima/src/test/java/opennlp/uima/AnnotatorsInitializationTest.java @@ -56,7 +56,8 @@ public void testInitializationExecutionAndReconfigure() { } } - private AnalysisEngine produceAE(String descName) throws IOException, InvalidXMLException, ResourceInitializationException { + private AnalysisEngine produceAE(String descName) + throws IOException, InvalidXMLException, ResourceInitializationException { File descFile = new File(PATHNAME + descName); XMLInputSource in = new XMLInputSource(descFile); ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(in);