0
votes

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
What's the format of your txt file? Did you try CSVLoader? - chl
@Mahesh: Each article must be on a single line and enclosed in quotes. Your quoted article is 4 lines long. All 4 lines need to be placed on a SINGLE line and enclosed in quotes. Depending on the length of the article you may run out of columns if you use a text editor like Notepad. This is why I recommend you use Notepad++ which allows you to have lines of unlimited length (using the Join Lines function). - Renklauf

1 Answers

2
votes

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.