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/06/06 10:45:13 UTC
opennlp git commit: OPENNLP-1081: Fix Dictionary support to
GeneratorFactory::extractArtifactSerializerMappings
Repository: opennlp
Updated Branches:
refs/heads/master 15ac7bd17 -> a13691b5b
OPENNLP-1081: Fix Dictionary support to GeneratorFactory::extractArtifactSerializerMappings
closes #220
Project: http://git-wip-us.apache.org/repos/asf/opennlp/repo
Commit: http://git-wip-us.apache.org/repos/asf/opennlp/commit/a13691b5
Tree: http://git-wip-us.apache.org/repos/asf/opennlp/tree/a13691b5
Diff: http://git-wip-us.apache.org/repos/asf/opennlp/diff/a13691b5
Branch: refs/heads/master
Commit: a13691b5be40d31099d39f7c8f3ee9970ebc20fa
Parents: 15ac7bd
Author: thygesen <th...@apache.org>
Authored: Mon May 29 16:07:35 2017 +0200
Committer: Jörn Kottmann <jo...@apache.org>
Committed: Tue Jun 6 12:41:15 2017 +0200
----------------------------------------------------------------------
.../tools/util/featuregen/GeneratorFactory.java | 5 +++++
.../util/featuregen/GeneratorFactoryTest.java | 13 ++++++++++++
...TestDictionarySerializerMappingExtractionxml | 22 ++++++++++++++++++++
3 files changed, 40 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/opennlp/blob/a13691b5/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/GeneratorFactory.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/GeneratorFactory.java b/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/GeneratorFactory.java
index 11cad42..4c3e48f 100644
--- a/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/GeneratorFactory.java
+++ b/opennlp-tools/src/main/java/opennlp/tools/util/featuregen/GeneratorFactory.java
@@ -47,6 +47,7 @@ import opennlp.tools.postag.POSModel;
import opennlp.tools.util.InvalidFormatException;
import opennlp.tools.util.ext.ExtensionLoader;
import opennlp.tools.util.model.ArtifactSerializer;
+import opennlp.tools.util.model.DictionarySerializer;
import opennlp.tools.util.model.POSModelSerializer;
/**
@@ -845,6 +846,10 @@ public class GeneratorFactory {
case "brownclusterbigram": //, ;
mapping.put(dictName, new BrownCluster.BrownClusterSerializer());
break;
+
+ case "dictionary":
+ mapping.put(dictName, new DictionarySerializer());
+ break;
}
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/a13691b5/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/GeneratorFactoryTest.java
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/GeneratorFactoryTest.java b/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/GeneratorFactoryTest.java
index dd569b0..7405537 100644
--- a/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/GeneratorFactoryTest.java
+++ b/opennlp-tools/src/test/java/opennlp/tools/util/featuregen/GeneratorFactoryTest.java
@@ -29,6 +29,7 @@ import org.junit.Test;
import opennlp.tools.util.InvalidFormatException;
import opennlp.tools.util.featuregen.WordClusterDictionary.WordClusterDictionarySerializer;
import opennlp.tools.util.model.ArtifactSerializer;
+import opennlp.tools.util.model.DictionarySerializer;
public class GeneratorFactoryTest {
@@ -124,4 +125,16 @@ public class GeneratorFactoryTest {
Assert.assertTrue(mapping.get("test.resource") instanceof WordClusterDictionarySerializer);
}
+
+ @Test
+ public void testDictionaryArtifactToSerializerMappingExtraction() throws IOException {
+
+ InputStream descIn = getClass().getResourceAsStream(
+ "/opennlp/tools/util/featuregen/TestDictionarySerializerMappingExtractionxml");
+
+ Map<String, ArtifactSerializer<?>> mapping =
+ GeneratorFactory.extractArtifactSerializerMappings(descIn);
+
+ Assert.assertTrue(mapping.get("test.dictionary") instanceof DictionarySerializer);
+ }
}
http://git-wip-us.apache.org/repos/asf/opennlp/blob/a13691b5/opennlp-tools/src/test/resources/opennlp/tools/util/featuregen/TestDictionarySerializerMappingExtractionxml
----------------------------------------------------------------------
diff --git a/opennlp-tools/src/test/resources/opennlp/tools/util/featuregen/TestDictionarySerializerMappingExtractionxml b/opennlp-tools/src/test/resources/opennlp/tools/util/featuregen/TestDictionarySerializerMappingExtractionxml
new file mode 100644
index 0000000..334fd3f
--- /dev/null
+++ b/opennlp-tools/src/test/resources/opennlp/tools/util/featuregen/TestDictionarySerializerMappingExtractionxml
@@ -0,0 +1,22 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. 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
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<generators>
+ <dictionary dict="test.dictionary"/>
+</generators>
\ No newline at end of file