out = new PrintWriter(new FileWriter(vectorFile));
// get an iterator on the Corpus
// and retrieve the documents one by one
Iterator<Document> docIterator = corpus.iterator();
while (docIterator.hasNext()) {
Document doc = docIterator.next();
int label = doc.getLabel();
// get a vector from the document
// need a metric (e.g. relative frequency / binary)
// and a lexicon
// the vector is represented as a string directly
Vector vector = null;
if (attributeMapping == null)
vector = doc.getFeatureVector(lexicon);
else
vector = doc.getFeatureVector(lexicon, attributeMapping);
out.print(label + " " + Utils.getVectorString(vector) + "\n");
}
out.close();
return vectorFile;
}