How to convert a text file into ARFF format?

大城市里の小女人 提交于 2019-12-02 16:45:03

问题


I'm using WEKA tool for text classification, and I have to convert plain text files into ARFF format. However, I don't know how to do that. Can anyone please help me to convert a text file into ARFF format?


Thank you Renklauf for ur response,

I didn't understood these points "Since text editors like Notepad only allow a limited number of columns, you'll need to get something like Notepad++ to fit everything on one line." .. can u plz explain in brief ..

Suppose the text data is like a simple sport article like

" Basketball is a team sport, the objective being to shoot a ball through a basket horizontally positioned to score points while following a set of rules. Usually, two teams of five players play on a marked rectangular court with a basket at each width end. Basketball is one of the world's most popular and widely viewed sports" ...

This is my text document and I want to convert this to arff format .. and after that I need to use that arff format file for SVM text classification ..


回答1:


For a document classification task, each document is considered an attribute and must be enclosed in quotes. Suppose you have a corpus of 10 sports articles tagged as either pro-Yankees or pro-Red Sox for a classifier that automatically classifies sports articles as either pro-Yankees or pro-Red Sox. You need to take each document, enclose it in quotes,place it on a single line, and then place your {yankees, red_sox} attribute value after the quotes-enclosed string.

 @relation yankeesOrRedSox
 @attribute article string
 @attribute yankeesOrSox { yankees, red_sox }
 @data

 "text of article 1 here", yankees
 .
 .
 .
 "text of article 10 here", red_sox

It's key that the article is placed on a single line. When I began using Weka for text classification, this is a point that caused me a lot of frustration at first. Since text editors like Notepad only allow a limited number of columns, you'll need to get something like Notepad++ to fit everything on one line. Notepad++ has a Join Lines function that allows you to place a lot of text on a single line.

Hope this helps.



来源:https://stackoverflow.com/questions/9192318/how-to-convert-a-text-file-into-arff-format

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!