Author: joern
Date: Fri Apr 17 10:24:11 2015
New Revision: 1674263
URL: http://svn.apache.org/r1674263
Log:
OPENNLP-767 Removed trailing white spaces on all lines
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/io/RealValueFileEventStreamTest.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/LineSearchTest.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/NegLogLikelihoodTest.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/QNMinimizerTest.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/QNPrepAttachTest.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/QNTrainerTest.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/parser/chunking/ParserTest.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/parser/lang/en/HeadRulesTest.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/parser/treeinsert/ParserTest.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/eval/CrossValidationPartitionerTest.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/eval/FMeasureTest.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/eval/MeanTest.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/ext/ExtensionLoaderTest.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/CachedFeatureGeneratorTest.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/FeatureGenWithSerializerMapping.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/GeneratorFactoryTest.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/PreviousMapFeatureGeneratorTest.java
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/StringPatternTest.java
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/io/RealValueFileEventStreamTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/io/RealValueFileEventStreamTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/io/RealValueFileEventStreamTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/io/RealValueFileEventStreamTest.java
Fri Apr 17 10:24:11 2015
@@ -28,7 +28,7 @@ public class RealValueFileEventStreamTes
public void testLastLineBug() throws IOException {
OnePassRealValueDataIndexer indexer;
RealValueFileEventStream rvfes;
-
+
rvfes = new RealValueFileEventStream(
"src/test/resources/data/opennlp/maxent/io/rvfes-bug-data-ok.txt");
try {
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/LineSearchTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/LineSearchTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/LineSearchTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/LineSearchTest.java
Fri Apr 17 10:24:11 2015
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* 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
@@ -169,7 +169,7 @@ public class LineSearchTest {
assertFalse(succCond);
assertEquals(0.0, stepSize, TOLERANCE);
}
-
+
/**
* Quadratic function: f(x) = (x-2)^2 + 4
*/
@@ -189,15 +189,15 @@ public class LineSearchTest {
return 1;
}
}
-
+
/**
* Quadratic function: f(x) = x^2
*/
public class QuadraticFunction2 implements Function {
-
+
public double valueAt(double[] x) {
// x^2;
- return Math.pow(x[0], 2);
+ return Math.pow(x[0], 2);
}
public double[] gradientAt(double[] x) {
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/NegLogLikelihoodTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/NegLogLikelihoodTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/NegLogLikelihoodTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/NegLogLikelihoodTest.java
Fri Apr 17 10:24:11 2015
@@ -39,11 +39,11 @@ public class NegLogLikelihoodTest {
public void testDomainDimensionSanity() throws IOException {
// given
RealValueFileEventStream rvfes1 = new RealValueFileEventStream(
-
"src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt",
"UTF-8");
+
"src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt",
"UTF-8");
DataIndexer testDataIndexer = new OnePassRealValueDataIndexer(rvfes1,1);
NegLogLikelihood objectFunction = new NegLogLikelihood(testDataIndexer);
// when
- int correctDomainDimension = testDataIndexer.getPredLabels().length
+ int correctDomainDimension = testDataIndexer.getPredLabels().length
* testDataIndexer.getOutcomeLabels().length;
// then
assertEquals(correctDomainDimension, objectFunction.getDimension());
@@ -53,7 +53,7 @@ public class NegLogLikelihoodTest {
public void testInitialSanity() throws IOException {
// given
RealValueFileEventStream rvfes1 = new RealValueFileEventStream(
-
"src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt",
"UTF-8");
+
"src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt",
"UTF-8");
DataIndexer testDataIndexer = new OnePassRealValueDataIndexer(rvfes1,1);
NegLogLikelihood objectFunction = new NegLogLikelihood(testDataIndexer);
// when
@@ -68,7 +68,7 @@ public class NegLogLikelihoodTest {
public void testGradientSanity() throws IOException {
// given
RealValueFileEventStream rvfes1 = new RealValueFileEventStream(
-
"src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt",
"UTF-8");
+
"src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt",
"UTF-8");
DataIndexer testDataIndexer = new OnePassRealValueDataIndexer(rvfes1,1);
NegLogLikelihood objectFunction = new NegLogLikelihood(testDataIndexer);
// when
@@ -117,14 +117,14 @@ public class NegLogLikelihoodTest {
// when
double[] nonInitialPoint = new double[] { 3, 2, 3, 2, 3, 2, 3, 2, 3, 2 };
double value =
objectFunction.valueAt(dealignDoubleArrayForTestData(nonInitialPoint,
- testDataIndexer.getPredLabels(),
+ testDataIndexer.getPredLabels(),
testDataIndexer.getOutcomeLabels()));
double expectedValue = 53.163219721099026;
// then
assertEquals(expectedValue, value, TOLERANCE02);
}
- @Test
+ @Test
public void testGradientAtInitialPoint() throws IOException {
// given
RealValueFileEventStream rvfes1 = new RealValueFileEventStream(
@@ -135,7 +135,7 @@ public class NegLogLikelihoodTest {
double[] gradientAtInitialPoint =
objectFunction.gradientAt(objectFunction.getInitialPoint());
double[] expectedGradient = new double[] { -9.0, -14.0, -17.0, 20.0, 8.5,
9.0, 14.0, 17.0, -20.0, -8.5 };
// then
- assertTrue(compareDoubleArray(expectedGradient, gradientAtInitialPoint,
+ assertTrue(compareDoubleArray(expectedGradient, gradientAtInitialPoint,
testDataIndexer, TOLERANCE01));
}
@@ -148,30 +148,30 @@ public class NegLogLikelihoodTest {
NegLogLikelihood objectFunction = new NegLogLikelihood(testDataIndexer);
// when
double[] nonInitialPoint = new double[] { 0.2, 0.5, 0.2, 0.5, 0.2, 0.5,
0.2, 0.5, 0.2, 0.5 };
- double[] gradientAtNonInitialPoint =
+ double[] gradientAtNonInitialPoint =
objectFunction.gradientAt(dealignDoubleArrayForTestData(nonInitialPoint,
- testDataIndexer.getPredLabels(),
+ testDataIndexer.getPredLabels(),
testDataIndexer.getOutcomeLabels()));
- double[] expectedGradient =
+ double[] expectedGradient =
new double[] { -12.755042847945553, -21.227127506102434,
-72.57790706276435, 38.03525795198456,
15.348650889354925, 12.755042847945557,
21.22712750610244, 72.57790706276438,
- -38.03525795198456, -15.348650889354925 };
+ -38.03525795198456, -15.348650889354925 };
// then
- assertTrue(compareDoubleArray(expectedGradient, gradientAtNonInitialPoint,
+ assertTrue(compareDoubleArray(expectedGradient, gradientAtNonInitialPoint,
testDataIndexer, TOLERANCE01));
}
-
- private double[] alignDoubleArrayForTestData(double[] expected,
+
+ private double[] alignDoubleArrayForTestData(double[] expected,
String[] predLabels, String[] outcomeLabels) {
double[] aligned = new double[predLabels.length * outcomeLabels.length];
-
+
String[] sortedPredLabels = predLabels.clone();
String[] sortedOutcomeLabels = outcomeLabels.clone();
Arrays.sort(sortedPredLabels);
Arrays.sort(sortedOutcomeLabels);
-
+
Map<String, Integer> invertedPredIndex = new HashMap<String, Integer>();
Map<String, Integer> invertedOutcomeIndex = new HashMap<String,
Integer>();
for (int i = 0; i < predLabels.length; i++) {
@@ -180,7 +180,7 @@ public class NegLogLikelihoodTest {
for (int i = 0; i < outcomeLabels.length; i++) {
invertedOutcomeIndex.put(outcomeLabels[i], i);
}
-
+
for (int i = 0; i < sortedOutcomeLabels.length; i++) {
for (int j = 0; j < sortedPredLabels.length; j++) {
aligned[i * sortedPredLabels.length + j] =
expected[invertedOutcomeIndex
@@ -191,7 +191,7 @@ public class NegLogLikelihoodTest {
}
return aligned;
}
-
+
private double[] dealignDoubleArrayForTestData(double[] expected,
String[] predLabels, String[] outcomeLabels) {
double[] dealigned = new double[predLabels.length * outcomeLabels.length];
@@ -221,9 +221,9 @@ public class NegLogLikelihoodTest {
return dealigned;
}
-
- private boolean compareDoubleArray(double[] expected, double[] actual,
- DataIndexer indexer, double tolerance)
+
+ private boolean compareDoubleArray(double[] expected, double[] actual,
+ DataIndexer indexer, double tolerance)
{
double[] alignedActual = alignDoubleArrayForTestData(
actual, indexer.getPredLabels(), indexer.getOutcomeLabels());
@@ -231,7 +231,7 @@ public class NegLogLikelihoodTest {
if (expected.length != alignedActual.length) {
return false;
}
-
+
for (int i = 0; i < alignedActual.length; i++) {
if (Math.abs(alignedActual[i] - expected[i]) > tolerance) {
return false;
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/QNMinimizerTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/QNMinimizerTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/QNMinimizerTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/QNMinimizerTest.java
Fri Apr 17 10:24:11 2015
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* 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
@@ -31,39 +31,39 @@ public class QNMinimizerTest {
Function f = new QuadraticFunction();
double[] x = minimizer.minimize(f);
double minValue = f.valueAt(x);
-
+
assertEquals(x[0], 1.0, 1e-5);
assertEquals(x[1], 5.0, 1e-5);
assertEquals(minValue, 10.0, 1e-10);
}
-
+
@Test
public void testRosenbrockFunction() {
QNMinimizer minimizer = new QNMinimizer();
Function f = new Rosenbrock();
double[] x = minimizer.minimize(f);
double minValue = f.valueAt(x);
-
+
assertEquals(x[0], 1.0, 1e-5);
assertEquals(x[1], 1.0, 1e-5);
assertEquals(minValue, 0, 1e-10);
}
-
+
/**
* Quadratic function: f(x,y) = (x-1)^2 + (y-5)^2 + 10
*/
public class QuadraticFunction implements Function {
-
+
@Override
- public int getDimension() {
- return 2;
+ public int getDimension() {
+ return 2;
}
-
+
@Override
- public double valueAt(double[] x) {
- return pow(x[0] - 1, 2) + pow(x[1] - 5, 2) + 10;
+ public double valueAt(double[] x) {
+ return pow(x[0] - 1, 2) + pow(x[1] - 5, 2) + 10;
}
-
+
@Override
public double[] gradientAt(double[] x) {
return new double[] { 2 * (x[0] - 1), 2 * (x[1] - 5) };
@@ -74,7 +74,7 @@ public class QNMinimizerTest {
* Rosenbrock function (http://en.wikipedia.org/wiki/Rosenbrock_function)
* f(x,y) = (1-x)^2 + 100*(y-x^2)^2
* f(x,y) is non-convex and has global minimum at (x,y) = (1,1) where f(x,y)
= 0
- *
+ *
* f_x = -2*(1-x) - 400*(y-x^2)*x
* f_y = 200*(y-x^2)
*/
@@ -97,6 +97,6 @@ public class QNMinimizerTest {
g[1] = 200 * (x[1] - pow(x[0], 2));
return g;
}
-
+
}
}
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/QNPrepAttachTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/QNPrepAttachTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/QNPrepAttachTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/QNPrepAttachTest.java
Fri Apr 17 10:24:11 2015
@@ -37,28 +37,28 @@ public class QNPrepAttachTest {
@Test
public void testQNOnPrepAttachData() throws IOException {
- AbstractModel model =
+ AbstractModel model =
new QNTrainer(true).trainModel(
100, new TwoPassDataIndexer(createTrainingStream(), 1));
testModel(model, 0.8155484030700668);
}
-
+
@Test
public void testQNOnPrepAttachDataWithParamsDefault() throws IOException {
-
+
Map<String, String> trainParams = new HashMap<String, String>();
trainParams.put(AbstractTrainer.ALGORITHM_PARAM,
QNTrainer.MAXENT_QN_VALUE);
-
+
MaxentModel model = TrainerFactory.getEventTrainer(trainParams, null)
.train(createTrainingStream());
-
+
testModel(model, 0.8115870264917059);
}
@Test
public void testQNOnPrepAttachDataWithElasticNetParams() throws IOException {
-
+
Map<String, String> trainParams = new HashMap<String, String>();
trainParams.put(AbstractTrainer.ALGORITHM_PARAM,
QNTrainer.MAXENT_QN_VALUE);
trainParams.put(AbstractEventTrainer.DATA_INDEXER_PARAM,
@@ -66,16 +66,16 @@ public class QNPrepAttachTest {
trainParams.put(AbstractTrainer.CUTOFF_PARAM, Integer.toString(1));
trainParams.put(QNTrainer.L1COST_PARAM, Double.toString(0.25));
trainParams.put(QNTrainer.L2COST_PARAM, Double.toString(1.0));
-
+
MaxentModel model = TrainerFactory.getEventTrainer(trainParams, null)
.train(createTrainingStream());
-
+
testModel(model, 0.8229759841544937);
}
-
+
@Test
public void testQNOnPrepAttachDataWithL1Params() throws IOException {
-
+
Map<String, String> trainParams = new HashMap<String, String>();
trainParams.put(AbstractTrainer.ALGORITHM_PARAM,
QNTrainer.MAXENT_QN_VALUE);
trainParams.put(AbstractEventTrainer.DATA_INDEXER_PARAM,
@@ -83,16 +83,16 @@ public class QNPrepAttachTest {
trainParams.put(AbstractTrainer.CUTOFF_PARAM, Integer.toString(1));
trainParams.put(QNTrainer.L1COST_PARAM, Double.toString(1.0));
trainParams.put(QNTrainer.L2COST_PARAM, Double.toString(0));
-
+
MaxentModel model = TrainerFactory.getEventTrainer(trainParams, null)
.train(createTrainingStream());
-
+
testModel(model, 0.8180242634315424);
}
-
+
@Test
public void testQNOnPrepAttachDataWithL2Params() throws IOException {
-
+
Map<String, String> trainParams = new HashMap<String, String>();
trainParams.put(AbstractTrainer.ALGORITHM_PARAM,
QNTrainer.MAXENT_QN_VALUE);
trainParams.put(AbstractEventTrainer.DATA_INDEXER_PARAM,
@@ -100,23 +100,23 @@ public class QNPrepAttachTest {
trainParams.put(AbstractTrainer.CUTOFF_PARAM, Integer.toString(1));
trainParams.put(QNTrainer.L1COST_PARAM, Double.toString(0));
trainParams.put(QNTrainer.L2COST_PARAM, Double.toString(1.0));
-
+
MaxentModel model = TrainerFactory.getEventTrainer(trainParams, null)
.train(createTrainingStream());
-
+
testModel(model, 0.8227283981183461);
}
-
+
@Test
public void testQNOnPrepAttachDataInParallel() throws IOException {
-
+
Map<String, String> trainParams = new HashMap<String, String>();
trainParams.put(AbstractTrainer.ALGORITHM_PARAM,
QNTrainer.MAXENT_QN_VALUE);
trainParams.put("Threads", Integer.toString(2));
-
+
MaxentModel model = TrainerFactory.getEventTrainer(trainParams, null)
.train(createTrainingStream());
-
+
testModel(model, 0.8115870264917059);
}
}
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/QNTrainerTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/QNTrainerTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/QNTrainerTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/ml/maxent/quasinewton/QNTrainerTest.java
Fri Apr 17 10:24:11 2015
@@ -37,14 +37,14 @@ import opennlp.tools.ml.model.RealValueF
import org.junit.Test;
public class QNTrainerTest {
-
+
private static int ITERATIONS = 50;
-
+
@Test
public void testTrainModelReturnsAQNModel() throws Exception {
// given
RealValueFileEventStream rvfes1 = new RealValueFileEventStream(
-
"src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt");
+
"src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt");
DataIndexer testDataIndexer = new OnePassRealValueDataIndexer(rvfes1,1);
// when
QNModel trainedModel = new QNTrainer(false).trainModel(ITERATIONS,
testDataIndexer);
@@ -56,64 +56,64 @@ public class QNTrainerTest {
public void testInTinyDevSet() throws Exception {
// given
RealValueFileEventStream rvfes1 = new RealValueFileEventStream(
-
"src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt");
+
"src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt");
DataIndexer testDataIndexer = new OnePassRealValueDataIndexer(rvfes1,1);
// when
QNModel trainedModel = new QNTrainer(15, true).trainModel(ITERATIONS,
testDataIndexer);
String[] features2Classify = new String[] {
- "feature2","feature3", "feature3",
- "feature3","feature3", "feature3",
- "feature3","feature3", "feature3",
+ "feature2","feature3", "feature3",
+ "feature3","feature3", "feature3",
+ "feature3","feature3", "feature3",
"feature3","feature3", "feature3"};
double[] eval = trainedModel.eval(features2Classify);
// then
assertNotNull(eval);
}
-
+
@Test
public void testModel() throws IOException {
// given
RealValueFileEventStream rvfes1 = new RealValueFileEventStream(
-
"src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt");
+
"src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt");
DataIndexer testDataIndexer = new
OnePassRealValueDataIndexer(rvfes1,1);
// when
QNModel trainedModel = new QNTrainer(15, true).trainModel(
ITERATIONS, testDataIndexer);
-
- assertTrue(trainedModel.equals(trainedModel));
+
+ assertTrue(trainedModel.equals(trainedModel));
assertFalse(trainedModel.equals(null));
}
-
+
@Test
public void testSerdeModel() throws IOException {
// given
RealValueFileEventStream rvfes1 = new RealValueFileEventStream(
-
"src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt");
+
"src/test/resources/data/opennlp/maxent/real-valued-weights-training-data.txt");
DataIndexer testDataIndexer = new
OnePassRealValueDataIndexer(rvfes1,1);
// when
QNModel trainedModel = new QNTrainer(5, 700,
true).trainModel(ITERATIONS, testDataIndexer);
-
+
ByteArrayOutputStream modelBytes = new ByteArrayOutputStream();
- GenericModelWriter modelWriter = new
GenericModelWriter(trainedModel,
+ GenericModelWriter modelWriter = new
GenericModelWriter(trainedModel,
new DataOutputStream(modelBytes));
modelWriter.persist();
modelWriter.close();
-
+
GenericModelReader modelReader = new GenericModelReader(new
BinaryFileDataReader(
new ByteArrayInputStream(modelBytes.toByteArray())));
AbstractModel readModel = modelReader.getModel();
QNModel deserModel = (QNModel) readModel;
-
- assertTrue(trainedModel.equals(deserModel));
-
+
+ assertTrue(trainedModel.equals(deserModel));
+
String[] features2Classify = new String[] {
- "feature2","feature3", "feature3",
- "feature3","feature3", "feature3",
- "feature3","feature3", "feature3",
+ "feature2","feature3", "feature3",
+ "feature3","feature3", "feature3",
+ "feature3","feature3", "feature3",
"feature3","feature3", "feature3"};
double[] eval01 = trainedModel.eval(features2Classify);
double[] eval02 = deserModel.eval(features2Classify);
-
+
assertEquals(eval01.length, eval02.length);
for (int i = 0; i < eval01.length; i++) {
assertEquals(eval01[i], eval02[i], 0.00000001);
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/parser/chunking/ParserTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/parser/chunking/ParserTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/parser/chunking/ParserTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/parser/chunking/ParserTest.java
Fri Apr 17 10:24:11 2015
@@ -33,34 +33,34 @@ import org.junit.Test;
* Tests for the {@link Parser} class.
*/
public class ParserTest {
-
+
/**
* Verify that training and tagging does not cause
* runtime problems.
*/
@Test
public void testChunkingParserTraining() throws Exception {
-
+
ObjectStream<Parse> parseSamples = ParserTestUtil.openTestTrainingData();
HeadRules headRules = ParserTestUtil.createTestHeadRules();
-
+
ParserModel model = Parser.train("en", parseSamples, headRules, 100, 0);
-
+
opennlp.tools.parser.Parser parser = ParserFactory.create(model);
-
+
// TODO:
// Tests parsing to make sure the code does not has
// a bug which fails always with a runtime exception
// parser.parse(Parse.parseParse("She was just another freighter from the "
+
// "States and she seemed as commonplace as her name ."));
-
+
// Test serializing and de-serializing model
ByteArrayOutputStream outArray = new ByteArrayOutputStream();
model.serialize(outArray);
outArray.close();
-
+
new ParserModel(new ByteArrayInputStream(outArray.toByteArray()));
-
+
// TODO: compare both models
}
}
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/parser/lang/en/HeadRulesTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/parser/lang/en/HeadRulesTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/parser/lang/en/HeadRulesTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/parser/lang/en/HeadRulesTest.java
Fri Apr 17 10:24:11 2015
@@ -32,18 +32,18 @@ public class HeadRulesTest {
@Test
public void testSerialization() throws IOException {
- InputStream headRulesIn =
+ InputStream headRulesIn =
HeadRulesTest.class.getResourceAsStream("/opennlp/tools/parser/en_head_rules");
-
+
HeadRules headRulesOrginal = new HeadRules(new
InputStreamReader(headRulesIn, "UTF-8"));
-
+
ByteArrayOutputStream out = new ByteArrayOutputStream();
headRulesOrginal.serialize(new OutputStreamWriter(out, "UTF-8"));
out.close();
-
+
HeadRules headRulesRecreated = new HeadRules(new InputStreamReader(
new ByteArrayInputStream(out.toByteArray()), "UTF-8"));
-
+
assertEquals(headRulesOrginal, headRulesRecreated);
}
}
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/parser/treeinsert/ParserTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/parser/treeinsert/ParserTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/parser/treeinsert/ParserTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/parser/treeinsert/ParserTest.java
Fri Apr 17 10:24:11 2015
@@ -33,33 +33,33 @@ import org.junit.Test;
* Tests for the {@link Parser} class.
*/
public class ParserTest {
-
+
/**
* Verify that training and tagging does not cause
* runtime problems.
*/
@Test
public void testTreeInsertParserTraining() throws Exception {
-
+
ObjectStream<Parse> parseSamples = ParserTestUtil.openTestTrainingData();
HeadRules headRules = ParserTestUtil.createTestHeadRules();
-
+
ParserModel model = Parser.train("en", parseSamples, headRules, 100, 0);
-
+
opennlp.tools.parser.Parser parser = ParserFactory.create(model);
-
+
// Tests parsing to make sure the code does not has
// a bug which fails always with a runtime exception
parser.parse(Parse.parseParse("She was just another freighter from the " +
"States and she seemed as commonplace as her name ."));
-
+
// Test serializing and de-serializing model
ByteArrayOutputStream outArray = new ByteArrayOutputStream();
model.serialize(outArray);
outArray.close();
-
+
new ParserModel(new ByteArrayInputStream(outArray.toByteArray()));
-
+
// TODO: compare both models
}
}
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/eval/CrossValidationPartitionerTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/eval/CrossValidationPartitionerTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/eval/CrossValidationPartitionerTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/eval/CrossValidationPartitionerTest.java
Fri Apr 17 10:24:11 2015
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
package opennlp.tools.util.eval;
@@ -44,22 +44,22 @@ public class CrossValidationPartitionerT
@Test
public void testEmptyDataSet() throws IOException {
Collection<String> emptyCollection = Collections.emptySet();
-
- CrossValidationPartitioner<String> partitioner =
+
+ CrossValidationPartitioner<String> partitioner =
new CrossValidationPartitioner<String>(emptyCollection, 2);
-
+
assertTrue(partitioner.hasNext());
assertNull(partitioner.next().read());
-
+
assertTrue(partitioner.hasNext());
assertNull(partitioner.next().read());
-
+
assertFalse(partitioner.hasNext());
-
+
try {
// Should throw NoSuchElementException
partitioner.next();
-
+
// ups, hasn't thrown one
fail();
}
@@ -67,7 +67,7 @@ public class CrossValidationPartitionerT
// expected
}
}
-
+
/**
* Test 3-fold cross validation on a small sample data set.
*/
@@ -84,13 +84,13 @@ public class CrossValidationPartitionerT
data.add("08");
data.add("09");
data.add("10");
-
+
CrossValidationPartitioner<String> partitioner = new
CrossValidationPartitioner<String>(data, 3);
-
+
// first partition
assertTrue(partitioner.hasNext());
TrainingSampleStream<String> firstTraining = partitioner.next();
-
+
assertEquals("02", firstTraining.read());
assertEquals("03", firstTraining.read());
assertEquals("05", firstTraining.read());
@@ -98,19 +98,19 @@ public class CrossValidationPartitionerT
assertEquals("08", firstTraining.read());
assertEquals("09", firstTraining.read());
assertNull(firstTraining.read());
-
+
ObjectStream<String> firstTest = firstTraining.getTestSampleStream();
-
+
assertEquals("01", firstTest.read());
assertEquals("04", firstTest.read());
assertEquals("07", firstTest.read());
assertEquals("10", firstTest.read());
assertNull(firstTest.read());
-
+
// second partition
assertTrue(partitioner.hasNext());
TrainingSampleStream<String> secondTraining = partitioner.next();
-
+
assertEquals("01", secondTraining.read());
assertEquals("03", secondTraining.read());
assertEquals("04", secondTraining.read());
@@ -118,20 +118,20 @@ public class CrossValidationPartitionerT
assertEquals("07", secondTraining.read());
assertEquals("09", secondTraining.read());
assertEquals("10", secondTraining.read());
-
+
assertNull(secondTraining.read());
-
+
ObjectStream<String> secondTest = secondTraining.getTestSampleStream();
assertEquals("02", secondTest.read());
assertEquals("05", secondTest.read());
assertEquals("08", secondTest.read());
assertNull(secondTest.read());
-
+
// third partition
assertTrue(partitioner.hasNext());
TrainingSampleStream<String> thirdTraining = partitioner.next();
-
+
assertEquals("01", thirdTraining.read());
assertEquals("02", thirdTraining.read());
assertEquals("04", thirdTraining.read());
@@ -140,14 +140,14 @@ public class CrossValidationPartitionerT
assertEquals("08", thirdTraining.read());
assertEquals("10", thirdTraining.read());
assertNull(thirdTraining.read());
-
+
ObjectStream<String> thirdTest = thirdTraining.getTestSampleStream();
-
+
assertEquals("03", thirdTest.read());
assertEquals("06", thirdTest.read());
assertEquals("09", thirdTest.read());
assertNull(thirdTest.read());
-
+
assertFalse(partitioner.hasNext());
}
@@ -158,16 +158,16 @@ public class CrossValidationPartitionerT
data.add("02");
data.add("03");
data.add("04");
-
+
CrossValidationPartitioner<String> partitioner = new
CrossValidationPartitioner<String>(data, 4);
-
+
// Test that iterator from previous partition fails
// if it is accessed
TrainingSampleStream<String> firstTraining = partitioner.next();
assertEquals("02", firstTraining.read());
-
+
TrainingSampleStream<String> secondTraining = partitioner.next();
-
+
try {
firstTraining.read();
fail();
@@ -179,31 +179,31 @@ public class CrossValidationPartitionerT
fail();
}
catch (IllegalStateException e) {}
-
+
// Test that training iterator fails if there is a test iterator
secondTraining.getTestSampleStream();
-
+
try {
secondTraining.read();
fail();
}
catch (IllegalStateException e) {}
-
+
// Test that test iterator from previous partition fails
// if there is a new partition
TrainingSampleStream<String> thirdTraining = partitioner.next();
ObjectStream<String> thridTest = thirdTraining.getTestSampleStream();
-
+
assertTrue(partitioner.hasNext());
partitioner.next();
-
+
try {
thridTest.read();
fail();
}
catch (IllegalStateException e) {}
}
-
+
@Test
public void testToString() {
Collection<String> emptyCollection = Collections.emptySet();
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/eval/FMeasureTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/eval/FMeasureTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/eval/FMeasureTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/eval/FMeasureTest.java
Fri Apr 17 10:24:11 2015
@@ -28,7 +28,7 @@ import org.junit.Test;
public class FMeasureTest {
private static final double DELTA = 1.0E-9d;
-
+
private Span gold[] = {
new Span(8, 9),
new Span(9, 10),
@@ -45,7 +45,7 @@ public class FMeasureTest {
new Span(210, 220),
new Span(220, 230)
};
-
+
private Span predictedCompletelyDistinct[] = {
new Span(100, 120),
new Span(210, 220),
@@ -53,7 +53,7 @@ public class FMeasureTest {
new Span(212, 220),
new Span(220, 230)
};
-
+
private Span goldToMerge[] = {
new Span(8, 9),
new Span(9, 10),
@@ -72,8 +72,8 @@ public class FMeasureTest {
new Span(210, 220),
new Span(220, 230)
};
-
-
+
+
/**
* Test for the {@link EvaluatorUtil#countTruePositives(Span[], Span[])}
method.
@@ -109,7 +109,7 @@ public class FMeasureTest {
assertEquals(Double.NaN, FMeasure.recall(new Object[]{}, gold), DELTA);
assertEquals(2d / gold.length, FMeasure.recall(gold, predicted), DELTA);
}
-
+
@Test
public void testEmpty() {
FMeasure fm = new FMeasure();
@@ -117,7 +117,7 @@ public class FMeasureTest {
assertEquals(0, fm.getRecallScore(), DELTA);
assertEquals(0, fm.getPrecisionScore(), DELTA);
}
-
+
@Test
public void testPerfect() {
FMeasure fm = new FMeasure();
@@ -126,31 +126,31 @@ public class FMeasureTest {
assertEquals(1, fm.getRecallScore(), DELTA);
assertEquals(1, fm.getPrecisionScore(), DELTA);
}
-
+
@Test
public void testMerge() {
FMeasure fm = new FMeasure();
fm.updateScores(gold, predicted);
fm.updateScores(goldToMerge, predictedToMerge);
-
+
FMeasure fmMerge = new FMeasure();
fmMerge.updateScores(gold, predicted);
FMeasure toMerge = new FMeasure();
toMerge.updateScores(goldToMerge, predictedToMerge);
fmMerge.mergeInto(toMerge);
-
+
double selected1 = predicted.length;
double target1 = gold.length;
double tp1 = FMeasure.countTruePositives(gold, predicted);
-
+
double selected2 = predictedToMerge.length;
double target2 = goldToMerge.length;
double tp2 = FMeasure.countTruePositives(goldToMerge,
predictedToMerge);
-
-
+
+
assertEquals((tp1 + tp2) / (target1 + target2), fm.getRecallScore(),
DELTA);
assertEquals((tp1 + tp2) / (selected1 + selected2),
fm.getPrecisionScore(), DELTA);
-
+
assertEquals(fm.getRecallScore(), fmMerge.getRecallScore(), DELTA);
assertEquals(fm.getPrecisionScore(), fmMerge.getPrecisionScore(),
DELTA);
}
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/eval/MeanTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/eval/MeanTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/eval/MeanTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/eval/MeanTest.java
Fri Apr 17 10:24:11 2015
@@ -32,26 +32,26 @@ public class MeanTest {
a.add(1);
assertEquals(1, a.count());
assertEquals(1d, a.mean(), 0.00001d);
-
+
a.add(1);
assertEquals(2, a.count());
assertEquals(1d, a.mean(), 0.00001d);
a.toString();
-
+
Mean b = new Mean();
b.add(0.5);
assertEquals(1, b.count());
assertEquals(0.5d, b.mean(), 0.00001d);
-
+
b.add(2);
assertEquals(2, b.count());
assertEquals(1.25d, b.mean(), 0.00001d);
b.toString();
-
+
Mean c = new Mean();
assertEquals(0, c.count());
assertEquals(0d, c.mean(), 0.00001d);
c.toString();
}
-
+
}
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/ext/ExtensionLoaderTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/ext/ExtensionLoaderTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/ext/ExtensionLoaderTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/ext/ExtensionLoaderTest.java
Fri Apr 17 10:24:11 2015
@@ -27,18 +27,18 @@ public class ExtensionLoaderTest {
interface TestStringGenerator {
String generateTestString();
}
-
+
static class TestStringGeneratorImpl implements TestStringGenerator {
public String generateTestString() {
return "test";
}
}
-
+
@Test
public void testLoadingStringGenerator() throws ClassNotFoundException {
TestStringGenerator g =
ExtensionLoader.instantiateExtension(TestStringGenerator.class,
TestStringGeneratorImpl.class.getName());
Assert.assertEquals("test", g.generateTestString());
}
-
+
}
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/CachedFeatureGeneratorTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/CachedFeatureGeneratorTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/CachedFeatureGeneratorTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/CachedFeatureGeneratorTest.java
Fri Apr 17 10:24:11 2015
@@ -105,7 +105,7 @@ public class CachedFeatureGeneratorTest
assertTrue(features.contains(expectedToken));
}
-
+
/**
* Tests if the cache was cleared after the sentence changed.
*/
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/FeatureGenWithSerializerMapping.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/FeatureGenWithSerializerMapping.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/FeatureGenWithSerializerMapping.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/FeatureGenWithSerializerMapping.java
Fri Apr 17 10:24:11 2015
@@ -25,7 +25,7 @@ import java.util.Map;
import opennlp.tools.util.InvalidFormatException;
import opennlp.tools.util.model.ArtifactSerializer;
-public class FeatureGenWithSerializerMapping extends CustomFeatureGenerator
+public class FeatureGenWithSerializerMapping extends CustomFeatureGenerator
implements ArtifactToSerializerMapper {
@Override
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/GeneratorFactoryTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/GeneratorFactoryTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/GeneratorFactoryTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/GeneratorFactoryTest.java
Fri Apr 17 10:24:11 2015
@@ -40,7 +40,7 @@ public class GeneratorFactoryTest {
public void testCreationWihtSimpleDescriptor() throws Exception {
InputStream generatorDescriptorIn = getClass().getResourceAsStream(
"/opennlp/tools/util/featuregen/TestFeatureGeneratorConfig.xml");
-
+
// If this fails the generator descriptor could not be found
// at the expected location
assertNotNull(generatorDescriptorIn);
@@ -65,28 +65,28 @@ public class GeneratorFactoryTest {
// removed from the expected generators collection
assertEquals(0, expectedGenerators.size());
}
-
+
@Test
public void testCreationWithCustomGenerator() throws Exception {
InputStream generatorDescriptorIn = getClass().getResourceAsStream(
"/opennlp/tools/util/featuregen/CustomClassLoading.xml");
-
+
// If this fails the generator descriptor could not be found
// at the expected location
assertNotNull(generatorDescriptorIn);
-
+
AggregatedFeatureGenerator aggregatedGenerator =
(AggregatedFeatureGenerator)
GeneratorFactory.create(generatorDescriptorIn, null);
-
+
Collection<AdaptiveFeatureGenerator> embeddedGenerator =
aggregatedGenerator.getGenerators();
-
+
assertEquals(1, embeddedGenerator.size());
-
+
for (AdaptiveFeatureGenerator generator : embeddedGenerator) {
assertEquals(TokenFeatureGenerator.class.getName(),
generator.getClass().getName());
}
}
-
+
/**
* Tests the creation from a descriptor which contains an unkown element.
* The creation should fail with an {@link InvalidFormatException}
@@ -95,7 +95,7 @@ public class GeneratorFactoryTest {
public void testCreationWithUnkownElement() throws IOException {
InputStream descIn = getClass().getResourceAsStream(
"/opennlp/tools/util/featuregen/FeatureGeneratorConfigWithUnkownElement.xml");
-
+
try {
GeneratorFactory.create(descIn, null);
}
@@ -103,16 +103,16 @@ public class GeneratorFactoryTest {
descIn.close();
}
}
-
+
@Test
public void testArtifactToSerializerMappingExtraction() throws IOException {
// TODO: Define a new one here with custom elements ...
InputStream descIn = getClass().getResourceAsStream(
"/opennlp/tools/util/featuregen/CustomClassLoadingWithSerializers.xml");
-
+
Map<String, ArtifactSerializer<?>> mapping =
GeneratorFactory.extractCustomArtifactSerializerMappings(descIn);
-
+
assertTrue(mapping.get("test.resource") instanceof
WordClusterDictionarySerializer);
}
}
\ No newline at end of file
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/PreviousMapFeatureGeneratorTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/PreviousMapFeatureGeneratorTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/PreviousMapFeatureGeneratorTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/PreviousMapFeatureGeneratorTest.java
Fri Apr 17 10:24:11 2015
@@ -31,28 +31,28 @@ public class PreviousMapFeatureGenerator
@Test
public void testFeatureGeneration() {
-
+
AdaptiveFeatureGenerator fg = new PreviousMapFeatureGenerator();
-
+
String sentence[] = new String[] {"a", "b", "c"};
-
+
List<String> features = new ArrayList<String>();
-
+
// this should generate the pd=null feature
fg.createFeatures(features, sentence, 0, null);
assertEquals(1, features.size());
assertEquals("pd=null", features.get(0));
-
+
features.clear();
-
+
// this should generate the pd=1 feature
fg.updateAdaptiveData(sentence, new String[] {"1", "2", "3"});
fg.createFeatures(features, sentence, 0, null);
assertEquals(1, features.size());
assertEquals("pd=1", features.get(0));
-
+
features.clear();
-
+
// this should generate the pd=null feature again after
// the adaptive data was cleared
fg.clearAdaptiveData();
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/StringPatternTest.java
URL:
http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/StringPatternTest.java?rev=1674263&r1=1674262&r2=1674263&view=diff
==============================================================================
---
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/StringPatternTest.java
(original)
+++
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/StringPatternTest.java
Fri Apr 17 10:24:11 2015
@@ -33,7 +33,7 @@ public class StringPatternTest {
assertTrue(StringPattern.recognize("grün").isAllLetter());
assertTrue(StringPattern.recognize("üäöæÃ").isAllLetter());
}
-
+
@Test
public void testIsInitialCapitalLetter() {
assertTrue(StringPattern.recognize("Test").isInitialCapitalLetter());
@@ -41,7 +41,7 @@ public class StringPatternTest {
assertTrue(StringPattern.recognize("TesT").isInitialCapitalLetter());
assertTrue(StringPattern.recognize("ÃäöæÃ").isInitialCapitalLetter());
}
-
+
@Test
public void testIsAllCapitalLetter() {
assertTrue(StringPattern.recognize("TEST").isAllCapitalLetter());
@@ -49,7 +49,7 @@ public class StringPatternTest {
assertFalse(StringPattern.recognize("ÃÃÃÃÃÃÃÃä").isAllCapitalLetter());
assertFalse(StringPattern.recognize("ÃÃÃÃÃdÃÃÃ").isAllCapitalLetter());
}
-
+
@Test
public void testIsAllLowerCaseLetter() {
assertTrue(StringPattern.recognize("test").isAllLowerCaseLetter());
@@ -60,42 +60,42 @@ public class StringPatternTest {
assertFalse(StringPattern.recognize("testT").isAllLowerCaseLetter());
assertFalse(StringPattern.recognize("tesÃt").isAllLowerCaseLetter());
}
-
+
@Test
public void testIsAllDigit() {
assertTrue(StringPattern.recognize("123456").isAllDigit());
assertFalse(StringPattern.recognize("123,56").isAllDigit());
assertFalse(StringPattern.recognize("12356f").isAllDigit());
}
-
+
@Test
public void testDigits() {
assertEquals(6, StringPattern.recognize("123456").digits());
assertEquals(3, StringPattern.recognize("123fff").digits());
assertEquals(0, StringPattern.recognize("test").digits());
}
-
+
@Test
public void testContainsPeriod() {
assertTrue(StringPattern.recognize("test.").containsPeriod());
assertTrue(StringPattern.recognize("23.5").containsPeriod());
assertFalse(StringPattern.recognize("test,/-1").containsPeriod());
}
-
+
@Test
public void testContainsComma() {
assertTrue(StringPattern.recognize("test,").containsComma());
assertTrue(StringPattern.recognize("23,5").containsComma());
assertFalse(StringPattern.recognize("test./-1").containsComma());
}
-
+
@Test
public void testContainsSlash() {
assertTrue(StringPattern.recognize("test/").containsSlash());
assertTrue(StringPattern.recognize("23/5").containsSlash());
assertFalse(StringPattern.recognize("test.1-,").containsSlash());
}
-
+
@Test
public void testContainsDigit() {
assertTrue(StringPattern.recognize("test1").containsDigit());
@@ -109,12 +109,12 @@ public class StringPatternTest {
assertTrue(StringPattern.recognize("23-5").containsHyphen());
assertFalse(StringPattern.recognize("test.1/,").containsHyphen());
}
-
+
@Test
public void testContainsLetters() {
assertTrue(StringPattern.recognize("test--").containsLetters());
assertTrue(StringPattern.recognize("23h5Ãm").containsLetters());
assertFalse(StringPattern.recognize("---.1/,").containsLetters());
}
-
+
}