【发布时间】:2016-04-15 20:25:58
【问题描述】:
我真的需要细细琢磨 WEKA API。我要做的就是为我的属性引入新的标称值。
我有类似句子 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
和第二句
@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 而不是添加值。
【问题讨论】: