2013-03-06 73 views
1

我正在使用WEKA的Java API開發應用程序。當運行StringToWordVector過濾器(轉換成字符串類型的屬性),以我的input.arff文件看起來像這樣:在WEKA中運行StringToWordVector過濾器

@relation Instantzien_Bektorea 

    @attribute 5_Ainf_Lema string 
    @attribute 6_Arg_PosKat {IZE,ADJ,ADI,ADB,DET,IOR,LOT,PRT,ITJ,BST,ADL,ADT,SIG,SNB,LAB,POST} 
    @attribute 7_Arg_Pos_AzpiKat {ARR,IZB,LIB,ZKI,GAL,SIN,ADK,ADP,FAK,ERKARR,ERKIND,NOLARR,NOLGAL,DZH,BAN,ORD,DZG,ORO,PERARR,PERIND,IZGMGB,IZGGAL,BIH,ELK,JOK,JNT,HUTSA} 
    @attribute 8_Arg_Kasua {abl,abu,abz,ala,soz,dat,des,erg,gel,gen,ine,ins,mot,abs,par,pro,bnk,desk,aurk,bald,emen,erlt,espl,haut,helb,kaus,konpl,kont,denb,mod,mos,ondo,zhg,neg,gen_post_ine,gen_post,gen_post_abs,ala_des,soz_post_ala,zero_post_abl,-} 
    @attribute 9_Argumentuaren_FSint {-,subj,obj} 
    @attribute 10_Arg_Posizioa {Aurretik,Atzetik} 
    @attribute 11_Dist_HKop numeric 
    @attribute 12_Dist_ArgKop numeric 
    @attribute 13_Framea string 
    @attribute 15_Frame_Unekoa string 
    @attribute Klasea {arg0,arg1,arg2,argM*LOC,argM*TMP,argM*MNR,argM*Cause,argM*ADV,argM*PRP,argM*-,argM*NEG,argM*DIS} 

    @data 
    eta_gero,LOT,ARR,denb,-,Aurretik,999,1,argM_PRED_arg1,ARGM_PRED_arg1,argM*TMP 
    Ainf_Lema,ADI,SIN,mod,-,Aurretik,1,1,argM_arg0_arg1_PRED,argM_arg0_ARG1_PRED,arg1 
    Ainf_Lema,IZE,ARR,abs,subj,Aurretik,999,2,arg0_argM_arg1_PRED,ARG0_argM_arg1_PRED,arg0 
... 

我再弄一堆實例是寫了output.arrf是這樣的:

@relation 'Train_Instantzien_Bektorea-weka.filters.unsupervised.attribute.StringToWordVector-R1,9,10-W1000-prune-rate-1.0-N0-stemmerweka.core.stemmers.NullStemmer-M1-tokenizerweka.core.tokenizers.WordTokenizer -delimiters \" \\r\\n\\t.,;:\\\'\\\"()?!\"' 

@attribute 6_Arg_PosKat {IZE,ADJ,ADI,ADB,DET,IOR,LOT,PRT,ITJ,BST,ADL,ADT,SIG,SNB,LAB,POST} 
@attribute 7_Arg_Pos_AzpiKat {ARR,IZB,LIB,ZKI,GAL,SIN,ADK,ADP,FAK,ERKARR,ERKIND,NOLARR,NOLGAL,DZH,BAN,ORD,DZG,ORO,PERARR,PERIND,IZGMGB,IZGGAL,BIH,ELK,JOK,JNT,HUTSA} 
@attribute 8_Arg_Kasua {abl,abu,abz,ala,soz,dat,des,erg,gel,gen,ine,ins,mot,abs,par,pro,bnk,desk,aurk,bald,emen,erlt,espl,haut,helb,kaus,konpl,kont,denb,mod,mos,ondo,zhg,neg,gen_post_ine,gen_post,gen_post_abs,ala_des,soz_post_ala,zero_post_abl,-} 
@attribute 9_Argumentuaren_FSint {-,subj,obj} 
@attribute 10_Arg_Posizioa {Aurretik,Atzetik} 
@attribute 11_Dist_HKop numeric 
@attribute 12_Dist_ArgKop numeric 
@attribute Klasea {arg0,arg1,arg2,argM*LOC,argM*TMP,argM*MNR,argM*Cause,argM*ADV,argM*PRP,argM*-,argM*NEG,argM*DIS} 
@attribute ARG0_PRED_arg1 numeric 
@attribute ARG0_arg1_PRED numeric 
@attribute ARG0_arg1_PRED_arg1_argM numeric 
@attribute ARG0_arg1_PRED_argM numeric 
@attribute ARG0_arg1_PRED_argM_argM numeric 
@attribute ARG0_argM_PRED numeric 

... 

@attribute argM_PRED_ARG1_argM_argM numeric 
@attribute argM_PRED numeric 
@attribute argM_PRED_arg1_ARGM numeric 

... 

@attribute ARGM_argM_PRED_arg1_argM numeric 
@attribute arg0_ARGM_arg1_PRED numeric 
@attribute arg0_ARGM_arg1_PRED_argM numeric 
@attribute arg0_arg1_PRED_ARGM_argM numeric 
@attribute eta_gero numeric 
@attribute gaur numeric 


@data 
{0 LOT,2 denb,5 999,6 1,7 argM*TMP,90 1,162 1,197 1} 
{0 ADI,1 SIN,2 mod,5 1,6 1,7 arg1,19 1,42 1,93 1} 
{2 abs,3 subj,5 999,6 2,16 1,19 1,29 1} 

正如你將在output.arff文件中看到的一些屬性從實例中消失(第一個實例 - >沒有第一個屬性,沒有第三個屬性等)爲什麼這樣?

運行過濾器中的Java代碼看起來是這樣的:

 // StringToWordVector filter 
     String[] options = new String[1]; 
     options[0] = "-R <1,9,10>";          
     StringToWordVector filter = new StringToWordVector(); 
     filter.setOptions(options);       
     filter.setInputFormat(input.arff);       
     Instances output_inst = Filter.useFilter(input_inst, filter); 

任何想法,問題出在哪裏,可以嗎?非常感謝你。

回答

2

首先,輸入文件是在正常的ARFF格式,而輸出文件是稀疏 ARFF,因爲他們開始與{}結束。 (請參閱上Attribute-Relation File Format信息)

{0 LOT,2 denb,5 999,6 1,7 argM*TMP,90 1,162 1,197 1} 

在這種稀疏格式,屬性具有值0將被省略。所有目前的屬性都需要通過它們的索引和值來指定。在上面的例子(第一個實例):

  • 屬性0 => LOT
  • 屬性1省略=> 0
  • 屬性2 => DeNB的
  • 屬性3中省略=> 0
  • ...

如果你看一下屬性1的定義,你會發現它不是數值而是名義值,所以0是它的值的索引,在這個例子中是ARR

所以沒有缺失的屬性,它們在輸出中被忽略,因爲它是稀疏格式。

如果你想知道爲什麼你有不同的屬性:這是StringToWordVector過濾器的結果。

相關問題