July 2017
Beginner to intermediate
715 pages
17h 3m
English
Now we are ready to build our model. We loop through the labels array, which contains pos and neg, and for each label we create a new Classification object. We then create a new file using this label and use the listFiles method to create an array of filenames. Next, we will traverse these filenames using a for loop:
public void buildSentimentAnalysisModel() { out.println("Building Sentiment Model"); File trainingDir = new File("\\path to file\\txt_sentoken"); for (int i = 0; i < labels.length; i++) { Classification classification = new Classification(labels[i]); File file = new File(trainingDir, labels[i]); File[] trainingFiles = file.listFiles(); ... } }
Within the for loop, we extract the tweet ...