You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2017/01/20 12:18:40 UTC
opennlp git commit: OPENNLP-949: Add more eval tests for qn and others
Repository: opennlp
Updated Branches:
refs/heads/master 2ff81900c -> d141f3c34
OPENNLP-949: Add more eval tests for qn and others
Project: http://git-wip-us.apache.org/repos/asf/opennlp/repo
Commit: http://git-wip-us.apache.org/repos/asf/opennlp/commit/d141f3c3
Tree: http://git-wip-us.apache.org/repos/asf/opennlp/tree/d141f3c3
Diff: http://git-wip-us.apache.org/repos/asf/opennlp/diff/d141f3c3
Branch: refs/heads/master
Commit: d141f3c34d9251071f95188da50e4c57f9870bfc
Parents: 2ff8190
Author: J�rn Kottmann <jo...@apache.org>
Authored: Thu Jan 19 23:37:09 2017 +0100
Committer: J�rn Kottmann <jo...@apache.org>
Committed: Fri Jan 20 12:51:15 2017 +0100
----------------------------------------------------------------------
.../opennlp/tools/eval/ArvoresDeitadasEval.java | 89 +++-
.../opennlp/tools/eval/Conll00ChunkerEval.java | 27 +-
.../tools/eval/Conll02NameFinderEval.java | 421 ++++++++++++++++---
.../opennlp/tools/eval/ConllXPosTaggerEval.java | 52 ++-
.../test/java/opennlp/tools/eval/EvalUtil.java | 30 ++
5 files changed, 527 insertions(+), 92 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/opennlp/blob/d141f3c3/opennlp-tools/src/test/java/opennlp/tools/eval/ArvoresDeitadasEval.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/test/java/opennlp/tools/eval/ArvoresDeitadasEval.java b/opennlp-tools/src/test/java/opennlp/tools/eval/ArvoresDeitadasEval.java
index 7233a77..ca62c5b 100644
--- a/opennlp-tools/src/test/java/opennlp/tools/eval/ArvoresDeitadasEval.java
+++ b/opennlp-tools/src/test/java/opennlp/tools/eval/ArvoresDeitadasEval.java
@@ -30,7 +30,6 @@ import opennlp.tools.formats.ad.ADChunkSampleStream;
import opennlp.tools.formats.ad.ADNameSampleStream;
import opennlp.tools.formats.ad.ADSentenceSampleStream;
import opennlp.tools.formats.convert.NameToTokenSampleStream;
-import opennlp.tools.ml.perceptron.PerceptronTrainer;
import opennlp.tools.namefind.NameSample;
import opennlp.tools.sentdetect.SDCrossValidator;
import opennlp.tools.sentdetect.SentenceDetectorFactory;
@@ -71,15 +70,6 @@ public class ArvoresDeitadasEval {
private static final String LANG = "pt";
- private static TrainingParameters getPerceptronZeroCutoff() {
- TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
- params.put(TrainingParameters.ALGORITHM_PARAM,
- PerceptronTrainer.PERCEPTRON_VALUE);
- params.put(TrainingParameters.CUTOFF_PARAM, "0");
-
- return params;
- }
-
private static ObjectStream<String> getLineSample(String corpus)
throws IOException {
return new PlainTextByLineStream(new MarkableFileInputStreamFactory(
@@ -142,18 +132,87 @@ public class ArvoresDeitadasEval {
}
@Test
- public void evalPortugueseSentenceDetector() throws IOException {
- sentenceCrossEval(getPerceptronZeroCutoff(), 0.9892778840089301d);
+ public void evalPortugueseSentenceDetectorPerceptron() throws IOException {
+ sentenceCrossEval(EvalUtil.createPerceptronParams(), 0.9892778840089301d);
}
@Test
- public void evalPortugueseTokenizer() throws IOException {
- tokenizerCrossEval(getPerceptronZeroCutoff(), 0.9994887308380267d);
+ public void evalPortugueseSentenceDetectorGis() throws IOException {
+ sentenceCrossEval(ModelUtil.createDefaultTrainingParameters(), 0.987270070655111d);
}
@Test
- public void evalPortugueseChunker() throws IOException {
+ public void evalPortugueseSentenceDetectorMaxentQn() throws IOException {
+ sentenceCrossEval(EvalUtil.createMaxentQnParams(), 0.99261110833375d);
+ }
+
+ @Test
+ public void evalPortugueseSentenceDetectorNaiveBayes() throws IOException {
+ sentenceCrossEval(EvalUtil.createNaiveBayesParams(), 0.9672196206048099d);
+ }
+
+ @Test
+ public void evalPortugueseTokenizerPerceptron() throws IOException {
+ tokenizerCrossEval(EvalUtil.createPerceptronParams(), 0.9994887308380267d);
+ }
+
+ @Test
+ public void evalPortugueseTokenizerGis() throws IOException {
+ tokenizerCrossEval(ModelUtil.createDefaultTrainingParameters(), 0.9992539405481062d);
+ }
+
+ @Test
+ public void evalPortugueseTokenizerMaxentQn() throws IOException {
+ tokenizerCrossEval(EvalUtil.createMaxentQnParams(), 0.9996017148748251d);
+ }
+
+ @Test
+ public void evalPortugueseTokenizerNaiveBayes() throws IOException {
+ tokenizerCrossEval(EvalUtil.createNaiveBayesParams(), 0.9962358244502717d);
+ }
+ @Test
+ public void evalPortugueseTokenizerMaxentQnMultipleThreads() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+ params.put("Threads", "4");
+ tokenizerCrossEval(params, 0.9996017148748251d);
+ }
+
+ @Test
+ public void evalPortugueseChunkerPerceptron() throws IOException {
+ chunkerCrossEval(EvalUtil.createPerceptronParams(),
+ 0.9638122825015589d);
+ }
+
+ @Test
+ public void evalPortugueseChunkerGis() throws IOException {
chunkerCrossEval(ModelUtil.createDefaultTrainingParameters(),
0.9573860781121228d);
}
+
+ @Test
+ public void evalPortugueseChunkerGisMultipleThreads() throws IOException {
+ TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
+ params.put("Threads", "4");
+ chunkerCrossEval(params, 0.9573860781121228d);
+ }
+
+ @Test
+ public void evalPortugueseChunkerQn() throws IOException {
+ chunkerCrossEval(EvalUtil.createMaxentQnParams(),
+ 0.9652111035230788d);
+ }
+
+ @Test
+ public void evalPortugueseChunkerQnMultipleThreads() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+ params.put("Threads", "4");
+
+ // NOTE: Should be the same as without multiple threads!!!
+ chunkerCrossEval(params, 0.9647304571382662);
+ }
+
+ @Test
+ public void evalPortugueseChunkerNaiveBayes() throws IOException {
+ chunkerCrossEval(EvalUtil.createNaiveBayesParams(), 0.9041507736043933d);
+ }
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/d141f3c3/opennlp-tools/src/test/java/opennlp/tools/eval/Conll00ChunkerEval.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/test/java/opennlp/tools/eval/Conll00ChunkerEval.java b/opennlp-tools/src/test/java/opennlp/tools/eval/Conll00ChunkerEval.java
index 94c1ef1..7e6102e 100644
--- a/opennlp-tools/src/test/java/opennlp/tools/eval/Conll00ChunkerEval.java
+++ b/opennlp-tools/src/test/java/opennlp/tools/eval/Conll00ChunkerEval.java
@@ -67,14 +67,35 @@ public class Conll00ChunkerEval {
}
@Test
- public void evalEnglish() throws IOException {
- TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
+ public void evalEnglishPerceptron() throws IOException {
+ ChunkerModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
+ "conll00/train.txt"), EvalUtil.createPerceptronParams());
+
+ eval(maxentModel,
+ new File(EvalUtil.getOpennlpDataDir(), "conll00/test.txt"),
+ 0.9295018353434714d);
+ }
+ @Test
+ public void evalEnglishMaxentGis() throws IOException {
ChunkerModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
- "conll00/train.txt"), params);
+ "conll00/train.txt"), ModelUtil.createDefaultTrainingParameters());
eval(maxentModel,
new File(EvalUtil.getOpennlpDataDir(), "conll00/test.txt"),
0.9239687473746113d);
}
+
+ // Note: Don't try to run this on your MacBook
+ @Test
+ public void evalEnglishMaxentQn() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+ params.put("Threads", "4");
+ ChunkerModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
+ "conll00/train.txt"), params);
+
+ eval(maxentModel,
+ new File(EvalUtil.getOpennlpDataDir(), "conll00/test.txt"),
+ 0.9302599230947028d);
+ }
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/d141f3c3/opennlp-tools/src/test/java/opennlp/tools/eval/Conll02NameFinderEval.java
----------------------------------------------------------------------
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 7819546..d1a71cf 100644
--- a/opennlp-tools/src/test/java/opennlp/tools/eval/Conll02NameFinderEval.java
+++ b/opennlp-tools/src/test/java/opennlp/tools/eval/Conll02NameFinderEval.java
@@ -50,6 +50,24 @@ import opennlp.tools.util.model.ModelUtil;
*/
public class Conll02NameFinderEval {
+ private final File dutchTrainingFile;
+ private final File dutchTestAFile;
+ private final File dutchTestBFile;
+
+ private final File spanishTrainingFile;
+ private final File spanishTestAFile;
+ private final File spanishTestBFile;
+
+ public Conll02NameFinderEval() {
+ dutchTrainingFile = new File(EvalUtil.getOpennlpDataDir(), "conll02/ner/data/ned.train");
+ dutchTestAFile = new File(EvalUtil.getOpennlpDataDir(), "conll02/ner/data/ned.testa");
+ dutchTestBFile = new File(EvalUtil.getOpennlpDataDir(), "conll02/ner/data/ned.testb");
+
+ spanishTrainingFile = new File(EvalUtil.getOpennlpDataDir(), "conll02/ner/data/esp.train");
+ spanishTestAFile = new File(EvalUtil.getOpennlpDataDir(), "conll02/ner/data/esp.testa");
+ spanishTestBFile = new File(EvalUtil.getOpennlpDataDir(), "conll02/ner/data/esp.testb");
+ }
+
private static TokenNameFinderModel train(File trainFile, LANGUAGE lang,
TrainingParameters params, int types) throws IOException {
@@ -73,75 +91,192 @@ public class Conll02NameFinderEval {
}
@Test
- public void evalDutchPerson() throws IOException {
+ public void evalDutchPersonPerceptron() throws IOException {
+ TrainingParameters params = EvalUtil.createPerceptronParams();
+
+ TokenNameFinderModel maxentModel = train(dutchTrainingFile, LANGUAGE.NL, params,
+ Conll02NameSampleStream.GENERATE_PERSON_ENTITIES);
+
+ eval(maxentModel, dutchTestAFile, LANGUAGE.NL,
+ Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.6238361266294227d);
+
+ eval(maxentModel, dutchTestBFile, LANGUAGE.NL,
+ Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.744312026002167d);
+ }
+
+ @Test
+ public void evalDutchPersonMaxentGis() throws IOException {
TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
- TokenNameFinderModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/ned.train"), LANGUAGE.NL, params,
+ TokenNameFinderModel maxentModel = train(dutchTrainingFile, LANGUAGE.NL, params,
Conll02NameSampleStream.GENERATE_PERSON_ENTITIES);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/ned.testa"), LANGUAGE.NL,
+ eval(maxentModel, dutchTestAFile, LANGUAGE.NL,
Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.5696539485359361d);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/ned.testb"), LANGUAGE.NL,
+ eval(maxentModel, dutchTestBFile, LANGUAGE.NL,
Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.7127771911298839d);
}
@Test
- public void evalDutchOrganization() throws IOException {
+ public void evalDutchPersonMaxentQn() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+
+ TokenNameFinderModel maxentModel = train(dutchTrainingFile, LANGUAGE.NL, params,
+ Conll02NameSampleStream.GENERATE_PERSON_ENTITIES);
+
+ eval(maxentModel, dutchTestAFile, LANGUAGE.NL,
+ Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.6363636363636364d);
+
+ eval(maxentModel, dutchTestBFile, LANGUAGE.NL,
+ Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.7482403898213319d);
+ }
+
+ @Test
+ public void evalDutchOrganizationPerceptron() throws IOException {
+ TrainingParameters params = EvalUtil.createPerceptronParams();
+
+ TokenNameFinderModel maxentModel = train(dutchTrainingFile, LANGUAGE.NL, params,
+ Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES);
+
+ eval(maxentModel, dutchTestAFile, LANGUAGE.NL,
+ Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.6081871345029239d);
+
+ eval(maxentModel, dutchTestBFile, LANGUAGE.NL,
+ Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.6502808988764045d);
+ }
+
+ @Test
+ public void evalDutchOrganizationMaxentGis() throws IOException {
TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
- TokenNameFinderModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/ned.train"), LANGUAGE.NL, params,
+ TokenNameFinderModel maxentModel = train(dutchTrainingFile, LANGUAGE.NL, params,
Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/ned.testa"), LANGUAGE.NL,
+ eval(maxentModel, dutchTestAFile, LANGUAGE.NL,
Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.5197969543147207d);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/ned.testb"), LANGUAGE.NL,
+ eval(maxentModel, dutchTestBFile, LANGUAGE.NL,
Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.5753228120516498d);
}
@Test
- public void evalDutchLocation() throws IOException {
+ public void evalDutchOrganizationMaxentQn() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+
+ TokenNameFinderModel maxentModel = train(dutchTrainingFile, LANGUAGE.NL, params,
+ Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES);
+
+ eval(maxentModel, dutchTestAFile, LANGUAGE.NL,
+ Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.5412748171368861d);
+
+ eval(maxentModel, dutchTestBFile, LANGUAGE.NL,
+ Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.5764966740576497d);
+ }
+
+ @Test
+ public void evalDutchLocationPerceptron() throws IOException {
+ TrainingParameters params = EvalUtil.createPerceptronParams();
+
+ TokenNameFinderModel maxentModel = train(dutchTrainingFile, LANGUAGE.NL, params,
+ Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES);
+
+ eval(maxentModel, dutchTestAFile, LANGUAGE.NL,
+ Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.7978609625668449d);
+
+ eval(maxentModel, dutchTestBFile, LANGUAGE.NL,
+ Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.7880434782608695d);
+ }
+
+ @Test
+ public void evalDutchLocationMaxentGis() throws IOException {
TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
- TokenNameFinderModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/ned.train"), LANGUAGE.NL, params,
+ TokenNameFinderModel maxentModel = train(dutchTrainingFile, LANGUAGE.NL, params,
Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/ned.testa"), LANGUAGE.NL,
+ eval(maxentModel, dutchTestAFile, LANGUAGE.NL,
Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.5451977401129944d);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/ned.testb"), LANGUAGE.NL,
+ eval(maxentModel, dutchTestBFile, LANGUAGE.NL,
Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.680952380952381d);
}
@Test
- public void evalDutchMisc() throws IOException {
+ public void evalDutchLocationMaxentQn() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+
+ TokenNameFinderModel maxentModel = train(dutchTrainingFile, LANGUAGE.NL, params,
+ Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES);
+
+ eval(maxentModel, dutchTestAFile, LANGUAGE.NL,
+ Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.6737683089214381d);
+
+ eval(maxentModel, dutchTestBFile, LANGUAGE.NL,
+ Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.7433903576982893d);
+ }
+
+ @Test
+ public void evalDutchMiscPerceptron() throws IOException {
+ TrainingParameters params = EvalUtil.createPerceptronParams();
+
+ TokenNameFinderModel maxentModel = train(dutchTrainingFile, LANGUAGE.NL, params,
+ Conll02NameSampleStream.GENERATE_MISC_ENTITIES);
+
+ eval(maxentModel, dutchTestAFile, LANGUAGE.NL,
+ Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.6651198762567672d);
+
+ eval(maxentModel, dutchTestBFile, LANGUAGE.NL,
+ Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.6748166259168704d);
+ }
+
+ @Test
+ public void evalDutchMiscMaxentGis() throws IOException {
TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
- TokenNameFinderModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/ned.train"), LANGUAGE.NL, params,
+ TokenNameFinderModel maxentModel = train(dutchTrainingFile, LANGUAGE.NL, params,
Conll02NameSampleStream.GENERATE_MISC_ENTITIES);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/ned.testa"), LANGUAGE.NL,
+ eval(maxentModel, dutchTestAFile, LANGUAGE.NL,
Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.5831157528285466d);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/ned.testb"), LANGUAGE.NL,
+ eval(maxentModel, dutchTestBFile, LANGUAGE.NL,
Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.5762897914379803d);
}
@Test
- public void evalDutchCombined() throws IOException {
+ public void evalDutchMiscMaxentQn() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+
+ TokenNameFinderModel maxentModel = train(dutchTrainingFile, LANGUAGE.NL, params,
+ Conll02NameSampleStream.GENERATE_MISC_ENTITIES);
+
+ eval(maxentModel, dutchTestAFile, LANGUAGE.NL,
+ Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.4227642276422764d);
+
+ eval(maxentModel, dutchTestBFile, LANGUAGE.NL,
+ Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.455294863665187d);
+ }
+
+ @Test
+ public void evalDutchCombinedPerceptron() throws IOException {
+ TrainingParameters params = EvalUtil.createPerceptronParams();
+
+ int combinedType = Conll02NameSampleStream.GENERATE_PERSON_ENTITIES
+ | Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES
+ | Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES
+ | Conll02NameSampleStream.GENERATE_MISC_ENTITIES;
+
+ TokenNameFinderModel maxentModel = train(dutchTrainingFile, LANGUAGE.NL, params,
+ combinedType);
+
+ eval(maxentModel, dutchTestAFile, LANGUAGE.NL, combinedType, 0.727808326787117d);
+
+ eval(maxentModel, dutchTestBFile, LANGUAGE.NL, combinedType, 0.7388253638253639d);
+ }
+
+ @Test
+ public void evalDutchCombinedMaxentGis() throws IOException {
TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
int combinedType = Conll02NameSampleStream.GENERATE_PERSON_ENTITIES
@@ -149,87 +284,219 @@ public class Conll02NameFinderEval {
| Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES
| Conll02NameSampleStream.GENERATE_MISC_ENTITIES;
- TokenNameFinderModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/ned.train"), LANGUAGE.NL, params,
+ TokenNameFinderModel maxentModel = train(dutchTrainingFile, LANGUAGE.NL, params,
+ combinedType);
+
+ eval(maxentModel, dutchTestAFile, LANGUAGE.NL, combinedType, 0.6728164867517175d);
+
+ eval(maxentModel, dutchTestBFile, LANGUAGE.NL, combinedType, 0.6985893619774816d);
+ }
+
+ @Test
+ public void evalDutchCombinedMaxentQn() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+
+ int combinedType = Conll02NameSampleStream.GENERATE_PERSON_ENTITIES
+ | Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES
+ | Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES
+ | Conll02NameSampleStream.GENERATE_MISC_ENTITIES;
+
+ TokenNameFinderModel maxentModel = train(dutchTrainingFile, LANGUAGE.NL, params,
combinedType);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/ned.testa"), LANGUAGE.NL, combinedType, 0.6728164867517175d);
+ eval(maxentModel, dutchTestAFile, LANGUAGE.NL, combinedType, 0.6999800915787379d);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/ned.testb"), LANGUAGE.NL, combinedType, 0.6985893619774816d);
+ eval(maxentModel, dutchTestBFile, LANGUAGE.NL, combinedType, 0.7101430258496261d);
}
@Test
- public void evalSpanishPerson() throws IOException {
+ public void evalSpanishPersonPerceptron() throws IOException {
+ TrainingParameters params = EvalUtil.createPerceptronParams();
+
+ TokenNameFinderModel maxentModel = train(spanishTrainingFile, LANGUAGE.ES, params,
+ Conll02NameSampleStream.GENERATE_PERSON_ENTITIES);
+
+ eval(maxentModel, spanishTestAFile, LANGUAGE.ES,
+ Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.8331210191082803d);
+
+ eval(maxentModel, spanishTestBFile, LANGUAGE.ES,
+ Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.8419705694177864d);
+ }
+
+ @Test
+ public void evalSpanishPersonMaxentGis() throws IOException {
TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
- TokenNameFinderModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/esp.train"), LANGUAGE.ES, params,
+ TokenNameFinderModel maxentModel = train(spanishTrainingFile, LANGUAGE.ES, params,
Conll02NameSampleStream.GENERATE_PERSON_ENTITIES);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/esp.testa"), LANGUAGE.ES,
+ eval(maxentModel, spanishTestAFile, LANGUAGE.ES,
Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.686960933536276d);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/esp.testb"), LANGUAGE.ES,
+ eval(maxentModel, spanishTestBFile, LANGUAGE.ES,
Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.8132033008252063d);
}
+
@Test
- public void evalSpanishOrganization() throws IOException {
+ public void evalSpanishPersonMaxentQn() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+
+ TokenNameFinderModel maxentModel = train(spanishTrainingFile, LANGUAGE.ES, params,
+ Conll02NameSampleStream.GENERATE_PERSON_ENTITIES);
+
+ eval(maxentModel, spanishTestAFile, LANGUAGE.ES,
+ Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.7432498772704957d);
+
+ eval(maxentModel, spanishTestBFile, LANGUAGE.ES,
+ Conll02NameSampleStream.GENERATE_PERSON_ENTITIES, 0.8218773096821878d);
+ }
+
+ @Test
+ public void evalSpanishOrganizationPerceptron() throws IOException {
+ TrainingParameters params = EvalUtil.createPerceptronParams();
+
+ TokenNameFinderModel maxentModel = train(spanishTrainingFile, LANGUAGE.ES, params,
+ Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES);
+
+ eval(maxentModel, spanishTestAFile, LANGUAGE.ES,
+ Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.7478819748758399d);
+
+ eval(maxentModel, spanishTestBFile, LANGUAGE.ES,
+ Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.7715330894579315d);
+ }
+
+ @Test
+ public void evalSpanishOrganizationMaxentGis() throws IOException {
TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
- TokenNameFinderModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/esp.train"), LANGUAGE.ES, params,
+ TokenNameFinderModel maxentModel = train(spanishTrainingFile, LANGUAGE.ES, params,
Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/esp.testa"), LANGUAGE.ES,
+ eval(maxentModel, spanishTestAFile, LANGUAGE.ES,
Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.6982288828337874d);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/esp.testb"), LANGUAGE.ES,
+ eval(maxentModel, spanishTestBFile, LANGUAGE.ES,
Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.7640449438202247d);
}
@Test
- public void evalSpanishLocation() throws IOException {
+ public void evalSpanishOrganizationMaxentQn() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+
+ TokenNameFinderModel maxentModel = train(spanishTrainingFile, LANGUAGE.ES, params,
+ Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES);
+
+ eval(maxentModel, spanishTestAFile, LANGUAGE.ES,
+ Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.6827859978347167d);
+
+ eval(maxentModel, spanishTestBFile, LANGUAGE.ES,
+ Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES, 0.7766212970376302d);
+ }
+
+ @Test
+ public void evalSpanishLocationPerceptron() throws IOException {
+ TrainingParameters params = EvalUtil.createPerceptronParams();
+
+ TokenNameFinderModel maxentModel = train(spanishTrainingFile, LANGUAGE.ES, params,
+ Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES);
+
+ eval(maxentModel, spanishTestAFile, LANGUAGE.ES,
+ Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.7018867924528303d);
+
+ eval(maxentModel, spanishTestBFile, LANGUAGE.ES,
+ Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.6315158777711205d);
+ }
+
+ @Test
+ public void evalSpanishLocationMaxentGis() throws IOException {
TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
- TokenNameFinderModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/esp.train"), LANGUAGE.ES, params,
+ TokenNameFinderModel maxentModel = train(spanishTrainingFile, LANGUAGE.ES, params,
Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/esp.testa"), LANGUAGE.ES,
+ eval(maxentModel, spanishTestAFile, LANGUAGE.ES,
Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.7386907929749867d);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/esp.testb"), LANGUAGE.ES,
+ eval(maxentModel, spanishTestBFile, LANGUAGE.ES,
Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.6772777167947311d);
}
@Test
- public void evalSpanishMisc() throws IOException {
+ public void evalSpanishLocationMaxentQn() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+
+ TokenNameFinderModel maxentModel = train(spanishTrainingFile, LANGUAGE.ES, params,
+ Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES);
+
+ eval(maxentModel, spanishTestAFile, LANGUAGE.ES,
+ Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.7544565842438182d);
+
+ eval(maxentModel, spanishTestBFile, LANGUAGE.ES,
+ Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES, 0.7005019520356944d);
+ }
+
+ @Test
+ public void evalSpanishMiscPerceptron() throws IOException {
+ TrainingParameters params = EvalUtil.createPerceptronParams();
+
+ TokenNameFinderModel maxentModel = train(spanishTrainingFile, LANGUAGE.ES, params,
+ Conll02NameSampleStream.GENERATE_MISC_ENTITIES);
+
+ eval(maxentModel, spanishTestAFile, LANGUAGE.ES,
+ Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.5102880658436214d);
+
+ eval(maxentModel, spanishTestBFile, LANGUAGE.ES,
+ Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.5842696629213483d);
+ }
+
+ @Test
+ public void evalSpanishMiscMaxentGis() throws IOException {
TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
- TokenNameFinderModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/esp.train"), LANGUAGE.ES, params,
+ TokenNameFinderModel maxentModel = train(spanishTrainingFile, LANGUAGE.ES, params,
Conll02NameSampleStream.GENERATE_MISC_ENTITIES);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/esp.testa"), LANGUAGE.ES,
+ eval(maxentModel, spanishTestAFile, LANGUAGE.ES,
Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.40971168437025796d);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/esp.testb"), LANGUAGE.ES,
+ eval(maxentModel, spanishTestBFile, LANGUAGE.ES,
Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.45703124999999994d);
}
@Test
- public void evalSpanishCombined() throws IOException {
+ public void evalSpanishMiscMaxentQn() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+
+ TokenNameFinderModel maxentModel = train(spanishTrainingFile, LANGUAGE.ES, params,
+ Conll02NameSampleStream.GENERATE_MISC_ENTITIES);
+
+ eval(maxentModel, spanishTestAFile, LANGUAGE.ES,
+ Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.47095761381475676d);
+
+ eval(maxentModel, spanishTestBFile, LANGUAGE.ES,
+ Conll02NameSampleStream.GENERATE_MISC_ENTITIES, 0.4926931106471817d);
+ }
+
+ @Test
+ public void evalSpanishCombinedPerceptron() throws IOException {
+ TrainingParameters params = EvalUtil.createPerceptronParams();
+
+ int combinedType = Conll02NameSampleStream.GENERATE_PERSON_ENTITIES
+ | Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES
+ | Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES
+ | Conll02NameSampleStream.GENERATE_MISC_ENTITIES;
+
+ TokenNameFinderModel maxentModel = train(spanishTrainingFile, LANGUAGE.ES, params,
+ combinedType);
+
+ eval(maxentModel, spanishTestAFile, LANGUAGE.ES, combinedType, 0.7476700838769804d);
+
+ eval(maxentModel, spanishTestBFile, LANGUAGE.ES, combinedType, 0.7692307692307693d);
+ }
+
+ @Test
+ public void evalSpanishCombinedMaxentGis() throws IOException {
TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
int combinedType = Conll02NameSampleStream.GENERATE_PERSON_ENTITIES
@@ -237,14 +504,28 @@ public class Conll02NameFinderEval {
| Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES
| Conll02NameSampleStream.GENERATE_MISC_ENTITIES;
- TokenNameFinderModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/esp.train"), LANGUAGE.ES, params,
+ TokenNameFinderModel maxentModel = train(spanishTrainingFile, LANGUAGE.ES, params,
+ combinedType);
+
+ eval(maxentModel, spanishTestAFile, LANGUAGE.ES, combinedType, 0.706765154179857d);
+
+ eval(maxentModel, spanishTestBFile, LANGUAGE.ES, combinedType, 0.7583580194667795d);
+ }
+
+ @Test
+ public void evalSpanishCombinedMaxentQn() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+
+ int combinedType = Conll02NameSampleStream.GENERATE_PERSON_ENTITIES
+ | Conll02NameSampleStream.GENERATE_ORGANIZATION_ENTITIES
+ | Conll02NameSampleStream.GENERATE_LOCATION_ENTITIES
+ | Conll02NameSampleStream.GENERATE_MISC_ENTITIES;
+
+ TokenNameFinderModel maxentModel = train(spanishTrainingFile, LANGUAGE.ES, params,
combinedType);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/esp.testa"), LANGUAGE.ES, combinedType, 0.706765154179857d);
+ eval(maxentModel, spanishTestAFile, LANGUAGE.ES, combinedType, 0.7455564833591795d);
- eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
- "conll02/ner/data/esp.testb"), LANGUAGE.ES, combinedType, 0.7583580194667795d);
+ eval(maxentModel, spanishTestBFile, LANGUAGE.ES, combinedType, 0.7856735159817352d);
}
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/d141f3c3/opennlp-tools/src/test/java/opennlp/tools/eval/ConllXPosTaggerEval.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/test/java/opennlp/tools/eval/ConllXPosTaggerEval.java b/opennlp-tools/src/test/java/opennlp/tools/eval/ConllXPosTaggerEval.java
index b6c2fa1..52b012d 100644
--- a/opennlp-tools/src/test/java/opennlp/tools/eval/ConllXPosTaggerEval.java
+++ b/opennlp-tools/src/test/java/opennlp/tools/eval/ConllXPosTaggerEval.java
@@ -77,7 +77,7 @@ public class ConllXPosTaggerEval {
}
@Test
- public void evalDanish() throws IOException {
+ public void evalDanishhMaxentGis() throws IOException {
TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
POSModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
@@ -88,7 +88,18 @@ public class ConllXPosTaggerEval {
}
@Test
- public void evalDutch() throws IOException {
+ public void evalDanishhMaxentQn() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+
+ POSModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
+ "conllx/data/danish/ddt/train/danish_ddt_train.conll"), "da", params);
+
+ eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
+ "conllx/data/danish/ddt/test/danish_ddt_test.conll"), 0.9512987012987013d);
+ }
+
+ @Test
+ public void evalDutchMaxentGis() throws IOException {
TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
POSModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
@@ -99,7 +110,18 @@ public class ConllXPosTaggerEval {
}
@Test
- public void evalPortuguese() throws IOException {
+ public void evalDutchMaxentQn() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+
+ POSModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
+ "conllx/data/dutch/alpino/train/dutch_alpino_train.conll"), "nl", params);
+
+ eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
+ "conllx/data/dutch/alpino/test/dutch_alpino_test.conll"), 0.9174574753804834d);
+ }
+
+ @Test
+ public void evalPortuguesehMaxentGis() throws IOException {
TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
POSModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
@@ -110,7 +132,18 @@ public class ConllXPosTaggerEval {
}
@Test
- public void evalSwedish() throws IOException {
+ public void evalPortuguesehMaxentQn() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+
+ POSModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
+ "conllx/data/portuguese/bosque/treebank/portuguese_bosque_train.conll"), "pt", params);
+
+ eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
+ "conllx/data/portuguese/bosque/test/portuguese_bosque_test.conll"), 0.9659110277825124d);
+ }
+
+ @Test
+ public void evalSwedishMaxentGis() throws IOException {
TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
POSModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
@@ -119,4 +152,15 @@ public class ConllXPosTaggerEval {
eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
"conllx/data/swedish/talbanken05/test/swedish_talbanken05_test.conll"), 0.9275106082036775d);
}
+
+ @Test
+ public void evalSwedishMaxentQn() throws IOException {
+ TrainingParameters params = EvalUtil.createMaxentQnParams();
+
+ POSModel maxentModel = train(new File(EvalUtil.getOpennlpDataDir(),
+ "conllx/data/swedish/talbanken05/train/swedish_talbanken05_train.conll"), "se", params);
+
+ eval(maxentModel, new File(EvalUtil.getOpennlpDataDir(),
+ "conllx/data/swedish/talbanken05/test/swedish_talbanken05_test.conll"), 0.9275106082036775d);
+ }
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/d141f3c3/opennlp-tools/src/test/java/opennlp/tools/eval/EvalUtil.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/test/java/opennlp/tools/eval/EvalUtil.java b/opennlp-tools/src/test/java/opennlp/tools/eval/EvalUtil.java
index 0b0d315..608e474 100644
--- a/opennlp-tools/src/test/java/opennlp/tools/eval/EvalUtil.java
+++ b/opennlp-tools/src/test/java/opennlp/tools/eval/EvalUtil.java
@@ -19,8 +19,38 @@ package opennlp.tools.eval;
import java.io.File;
+import opennlp.tools.ml.maxent.quasinewton.QNTrainer;
+import opennlp.tools.ml.naivebayes.NaiveBayesTrainer;
+import opennlp.tools.ml.perceptron.PerceptronTrainer;
+import opennlp.tools.util.TrainingParameters;
+import opennlp.tools.util.model.ModelUtil;
+
public class EvalUtil {
+ static TrainingParameters createPerceptronParams() {
+ TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
+ params.put(TrainingParameters.ALGORITHM_PARAM,
+ PerceptronTrainer.PERCEPTRON_VALUE);
+ params.put(TrainingParameters.CUTOFF_PARAM, "0");
+ return params;
+ }
+
+ static TrainingParameters createMaxentQnParams() {
+ TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
+ params.put(TrainingParameters.ALGORITHM_PARAM,
+ QNTrainer.MAXENT_QN_VALUE);
+ params.put(TrainingParameters.CUTOFF_PARAM, "0");
+ return params;
+ }
+
+ static TrainingParameters createNaiveBayesParams() {
+ TrainingParameters params = ModelUtil.createDefaultTrainingParameters();
+ params.put(TrainingParameters.ALGORITHM_PARAM,
+ NaiveBayesTrainer.NAIVE_BAYES_VALUE);
+ params.put(TrainingParameters.CUTOFF_PARAM, "5");
+ return params;
+ }
+
public static File getOpennlpDataDir() {
return new File(System.getProperty("OPENNLP_DATA_DIR"));
}