//iterate until we hit the end of the category list
while(!rawLIWC.get(i).equals("%")) {
String[] splitCategory = rawLIWC.get(i).split("\\s+"); //split on all whitespace
int currentID = Integer.parseInt(splitCategory[0]);
String currentTitle = splitCategory[1];
Category currentCategory = new Category(currentTitle);
currentCategory.setLIWCID(currentID);
int j = 66; //Start of word list
//iterate until we hit end of word list
while(j < rawLIWC.size()) {
String[] splitWord = rawLIWC.get(j).split("\\s+");
for(int k=1; k<splitWord.length; k++) {
if(Integer.parseInt(splitWord[k]) == currentID) {
currentCategory.addWord(splitWord[0]);
//NOTE: now, we've added the word to the category
//but here we can also try to create a new word object
//and add this category to the word to avoid having to
//iterate over it all again
if(words.containsKey(splitWord[0])) {
words.get(splitWord[0]).addCategory(currentCategory);
} else {
LIWCWord newWord = new LIWCWord(splitWord[0]);
newWord.addCategory(currentCategory);
words.put(splitWord[0], newWord);
}
break;
}
}
j++;
}
categories.add(currentCategory);
stringCategoryLookup.put(currentCategory.getTitle(), currentCategory);
i++;
}
} catch (IOException e) {
System.err.println("Couldn't read from LIWC Dictionary file at "+path);