我真的不得不咀嚼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
我试图完成的是将它们添加到空的Instance数据集中:
@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
而不是添加值.