Mahesh
Mahesh

Reputation: 29

How to convert a text file into ARFF format?

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 ..

Upvotes: 0

Views: 15899

Answers (1)

Renklauf
Renklauf

Reputation: 981

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.

Upvotes: 2

Related Questions