gpt4 book ai didi

java - 如何使用 AddValues 向实例添加新的标称值?

转载 作者:搜寻专家 更新时间:2023-11-01 00:55:20 24 4
gpt4 key购买 nike

我真的必须仔细研究 WEKA API。我想做的就是为我的属性引入新的标称值。

我有像Sentence 1这样的数据

@relation i-do-not-care

@attribute sentence_id {1090587:0}
@attribute word {here,girlfriend,bday,23rd,go,for,my,just}
@attribute relations {nmod:poss-,amod+;nsubj-,nsubj+;nmod+;advmod+,amod-,nmod-;case+;nmod:poss+,advmod-,case-}
@attribute target {0}

@data
1090587:0,go,nsubj+;nmod+;advmod+,0
1090587:0,my,nmod:poss-,0

句子2

@relation i-do-not-care

@attribute sentence_id {1090587:1}
@attribute word {be,idea,house,weehawken,offer,view,top,along,of,have,if,you,a,in,the,ever,to,river,chart}
@attribute relations {aux-,cop-,nmod-;case+,nsubj+;acl:relcl-;xcomp+,advmod-,det-,nsubj-,advcl+;nsubj+;dobj+,case-,acl:relcl+;det+;nmod+;dobj-,mark+;nsubj+;det+;nmod+;cop+;aux+;case+;advcl-;advmod+,compound+;nsubj-;det+,mark+;xcomp-,mark-,compound-,det+;nmod+;nmod-;case+}
@attribute target {0,1}

@data
1090587:1,a,det-,0
1090587:1,have,advcl+;nsubj+;dobj+,0

我试图完成的是将它们添加到一个空的实例数据集中:

@relation features

@attribute sentence_id {}
@attribute word {}
@attribute relations {}
@attribute target {0,1}

@data

这就是我尝试这样做的方式:

public Instances add(Instances instances, Instances newInstances) {

AddValues addValues = new AddValues();

try {
// This should just copy 'sentence_id' values
// but I am not sure about that.
addValues.setAttributeIndex("1");
addValues.setInputFormat(newInstances);

instances = Filter.useFilter(instances, addValues);

return instances;
} catch (Exception e) {
e.printStackTrace();
}

return null;
}

但它只是覆盖 instances 而不是添加值。

最佳答案

您两次使用相同的代码。

instances = Filter.useFilter(instances, addValues); 

return instances = Filter.useFilter(instances, addValues);

试试这个:

instances = Filter.useFilter(instances, addValues); 

return instances;

或下一级:

return Filter.useFilter(instances, addValues

关于java - 如何使用 AddValues 向实例添加新的标称值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34723049/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com