有谁知道如何向 org.w3c.dom.Element 添加值以实例化 MiningSchema 和 SupportVectorMachineModel?
Does anyone know how to add a value to org.w3c.dom.Element to instantiate both MiningSchema and SupportVectorMachineModel?
我有一个 github 存储库 here,其中包含我的所有代码。给我空指针的代码片段在模型中,空指针位于 Model:32。我仍然不完全确定在这里做什么。
我已经准备好其他一切工作,这是给我一个问题的一件事。代码片段如下:
private SupportVectorMachine svm = new SupportVectorMachine();
private SupportVectors supportVectors = new SupportVectors();
private SupportVectorMachineModel svmModel;
private MiningSchema schema;
private ClassLoader loader = new ClassLoader();
private Element element;
public void create(Instances instances) throws IOException, SAXException
{
assert instances!=null;
DocumentBuilder builder = null;
element = (Element) builder.parse(instances.toString());
try
{
schema = new MiningSchema(element, instances, schema.getTransformationDictionary());
svmModel = new SupportVectorMachineModel(element, instances, schema);
} catch (Exception e)
{
e.printStackTrace();
}
}
private Element element;
Document doc;
public void create(Instances instances) throws IOException, SAXException, ParserConfigurationException {
assert instances!=null;
DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
assert builder != null;
doc = builder.parse(instances.toString());
element = (Element) doc;
我从实例创建了一个新文档,然后将其转换为一个元素。
我有一个 github 存储库 here,其中包含我的所有代码。给我空指针的代码片段在模型中,空指针位于 Model:32。我仍然不完全确定在这里做什么。 我已经准备好其他一切工作,这是给我一个问题的一件事。代码片段如下:
private SupportVectorMachine svm = new SupportVectorMachine();
private SupportVectors supportVectors = new SupportVectors();
private SupportVectorMachineModel svmModel;
private MiningSchema schema;
private ClassLoader loader = new ClassLoader();
private Element element;
public void create(Instances instances) throws IOException, SAXException
{
assert instances!=null;
DocumentBuilder builder = null;
element = (Element) builder.parse(instances.toString());
try
{
schema = new MiningSchema(element, instances, schema.getTransformationDictionary());
svmModel = new SupportVectorMachineModel(element, instances, schema);
} catch (Exception e)
{
e.printStackTrace();
}
}
private Element element;
Document doc;
public void create(Instances instances) throws IOException, SAXException, ParserConfigurationException {
assert instances!=null;
DocumentBuilderFactory documentBuilderFactory = new DocumentBuilderFactoryImpl();
DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
assert builder != null;
doc = builder.parse(instances.toString());
element = (Element) doc;
我从实例创建了一个新文档,然后将其转换为一个元素。