ARFF用于自然语言处理

Dea*_*nes 9 nlp machine-learning weka arff

我正在尝试进行一系列评论,并将它们转换为ARFF格式,以便与WEKA一起使用.不幸的是,我完全误解了格式是如何工作的,或者我必须拥有所有可能单词的属性,然后是存在指示符.有没有人知道更好的方法,或理想情况下有一个样本ARFF文件?

Dea*_*nes 3

花了一段时间才解决,但有了这个 input.arff:

@relation text_files

@attribute review string
@attribute sentiment {0, 1}

@data
"this is some text", 1
"this is some more text", 1
"different stuff", 0
Run Code Online (Sandbox Code Playgroud)

这个命令:

java -classpath "C:\\Program Files\\Weka-3-6\\weka.jar" weka.filters.unsupervised.attribute.StringToWordVector -i input.arff -o output.arff
Run Code Online (Sandbox Code Playgroud)

产生以下内容:

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

@attribute sentiment {0,1}
@attribute different numeric
@attribute is numeric
@attribute more numeric
@attribute some numeric
@attribute stuff numeric
@attribute text numeric
@attribute this numeric

@data

{0 1,2 1,4 1,6 1,7 1}
{0 1,2 1,3 1,4 1,6 1,7 1}
{1 1,5 1}
Run Code Online (Sandbox Code Playgroud)

  • 这是一篇相当老的帖子,但据我记得元组中的第一个数字是@attribute编号,第二个数字是字符串中的出现次数。我认为在某种程度上它可以意味着你想要的,只要你明白结果意味着什么。 (2认同)