@Test public void testDictionaryArtifactToSerializerMappingExtraction() throws IOException { InputStream descIn = getClass().getResourceAsStream( "/opennlp/tools/util/featuregen/TestDictionarySerializerMappingExtraction.xml"); Map<String, ArtifactSerializer<?>> mapping = GeneratorFactory.extractArtifactSerializerMappings(descIn); Assert.assertTrue(mapping.get("test.dictionary") instanceof DictionarySerializer); }
public static Map<String, ArtifactSerializer<?>> extractArtifactSerializerMappings( InputStream xmlDescriptorIn) throws IOException { org.w3c.dom.Document xmlDescriptorDOM = createDOM(xmlDescriptorIn); Element element = xmlDescriptorDOM.getDocumentElement(); String elementName = element.getTagName(); if (elementName.equals("featureGenerators")) { Map<String, ArtifactSerializer<?>> mapping = new HashMap<>(); NodeList nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { if (nodes.item(i) instanceof Element) { Element childElem = (Element)nodes.item(i); if (childElem.getTagName().equals("generator")) { extractArtifactSerializerMappings(mapping, childElem); } } } return mapping; } else { return extractArtifactSerializerMappingsClassicFormat(element); } }
GeneratorFactory { public static Map<String, ArtifactSerializer<?>> extractArtifactSerializerMappings( InputStream xmlDescriptorIn) throws IOException { org.w3c.dom.Document xmlDescriptorDOM = createDOM(xmlDescriptorIn); Element element = xmlDescriptorDOM.getDocumentElement(); String elementName = element.getTagName(); if (elementName.equals("featureGenerators")) { Map<String, ArtifactSerializer<?>> mapping = new HashMap<>(); NodeList nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { if (nodes.item(i) instanceof Element) { Element childElem = (Element)nodes.item(i); if (childElem.getTagName().equals("generator")) { extractArtifactSerializerMappings(mapping, childElem); } } } return mapping; } else { return extractArtifactSerializerMappingsClassicFormat(element); } } }
GeneratorFactory { public static Map<String, ArtifactSerializer<?>> extractArtifactSerializerMappings( InputStream xmlDescriptorIn) throws IOException { org.w3c.dom.Document xmlDescriptorDOM = createDOM(xmlDescriptorIn); Element element = xmlDescriptorDOM.getDocumentElement(); String elementName = element.getTagName(); if (elementName.equals("featureGenerators")) { Map<String, ArtifactSerializer<?>> mapping = new HashMap<>(); NodeList nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { if (nodes.item(i) instanceof Element) { Element childElem = (Element)nodes.item(i); if (childElem.getTagName().equals("generator")) { extractArtifactSerializerMappings(mapping, childElem); } } } return mapping; } else { return extractArtifactSerializerMappingsClassicFormat(element); } }  }
GeneratorFactory { public static Map<String, ArtifactSerializer<?>> extractArtifactSerializerMappings( InputStream xmlDescriptorIn) throws IOException { org.w3c.dom.Document xmlDescriptorDOM = createDOM(xmlDescriptorIn); Element element = xmlDescriptorDOM.getDocumentElement(); String elementName = element.getTagName(); if (elementName.equals("featureGenerators")) { Map<String, ArtifactSerializer<?>> mapping = new HashMap<>(); NodeList nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { if (nodes.item(i) instanceof Element) { Element childElem = (Element)nodes.item(i); if (childElem.getTagName().equals("generator")) { extractArtifactSerializerMappings(mapping, childElem); } } } return mapping; } else { return extractArtifactSerializerMappingsClassicFormat(element); } }  static AdaptiveFeatureGenerator create(InputStream xmlDescriptorIn,
      FeatureGeneratorResourceProvider resourceManager); static Map<String, ArtifactSerializer<?>> extractArtifactSerializerMappings(
      InputStream xmlDescriptorIn); static List<Element> getDescriptorElements(InputStream xmlDescriptorIn); }
GeneratorFactory { public static Map<String, ArtifactSerializer<?>> extractArtifactSerializerMappings( InputStream xmlDescriptorIn) throws IOException { org.w3c.dom.Document xmlDescriptorDOM = createDOM(xmlDescriptorIn); Element element = xmlDescriptorDOM.getDocumentElement(); String elementName = element.getTagName(); if (elementName.equals("featureGenerators")) { Map<String, ArtifactSerializer<?>> mapping = new HashMap<>(); NodeList nodes = element.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { if (nodes.item(i) instanceof Element) { Element childElem = (Element)nodes.item(i); if (childElem.getTagName().equals("generator")) { extractArtifactSerializerMappings(mapping, childElem); } } } return mapping; } else { return extractArtifactSerializerMappingsClassicFormat(element); } }  static AdaptiveFeatureGenerator create(InputStream xmlDescriptorIn,
      FeatureGeneratorResourceProvider resourceManager); static Map<String, ArtifactSerializer<?>> extractArtifactSerializerMappings(
      InputStream xmlDescriptorIn); static List<Element> getDescriptorElements(InputStream xmlDescriptorIn);  }