public ArrayList loadTransactions(String nameOfDataFileWithinDataDirectory) { ArrayList transactions = new ArrayList(); String[] lines = loadStrings(nameOfDataFileWithinDataDirectory); for (int i = 0; i < lines.length; i++) { transactions.add(parseTransaction(lines[i])); } return transactions; } //create a new transaction obejct from a comma separated line. public Transaction parseTransaction(String line) { no.put("how", ""); no.put("our", ""); no.put("where", ""); no.put("its", ""); no.put("this", ""); no.put("whats", ""); no.put("for", ""); no.put("you", ""); no.put("new", ""); no.put("when", ""); no.put("case", ""); no.put("say", ""); no.put("like", ""); no.put("just", ""); no.put("but", ""); no.put("they", ""); no.put("see", ""); no.put("her", ""); no.put("his", ""); no.put("the", ""); no.put("all", ""); no.put("into", ""); no.put("and", ""); no.put("our", ""); no.put("from", ""); no.put("what", ""); no.put("with", ""); no.put("there", ""); no.put("that", ""); no.put("your", ""); no.put("every", ""); no.put("their", ""); no.put("book", ""); no.put("first", ""); no.put("introduction", ""); no.put("lifes", ""); no.put("version", ""); no.put("times", ""); no.put("can", ""); no.put("making", ""); no.put("108", ""); String sections[] = split(line, ","); Transaction t = new Transaction(); //store all fields // t.itemNumber = sections[0]; // t.bibNumber = sections[1]; // t.ckodate = sections[0]; // t.ckotime = sections[3]; // t.ckidate = sections[4]; // t.ckitime = sections[5]; // t.collcode = sections[6]; // t.itemtype = sections[1]; // t.barcode = sections[8]; t.title = sections[0]; // t.callNumber = sections[10]; t.deweyClass = sections[1]; //add this to the hashmap containing the titles hm.put(t.title,t.deweyClass); parseTitle(t.title, float(t.deweyClass)); return t; } void parseTitle(String title, float deweyClass){ int arraySize = 1; int count = 0; Word w; for(int k = 0; k < title.length(); k++){ if(title.charAt(k) == ' '){ arraySize++; } } String words[] = split(title, ' '); //iterate through the words boolean repeatTitle; if(hm.containsKey(title)){ repeatTitle = true; } else{ repeatTitle = false; } for(int j = 0; j < arraySize; j++){ words[j] = words[j].toLowerCase(); //if the word is greater than 2 letters and isn't a forbidden "boring" word if(words[j].length() > 2 && !(no.containsKey(words[j]))){ //if it's in a given class if((deweyClass >= 230 && deweyClass < 240) || (deweyClass >= 297 && deweyClass < 298) || (deweyClass >= 294 && deweyClass < 295)){ //check if this word exists if(!wc.containsKey(words[j])){ w = new Word(); w.word = words[j]; wc.put(words[j], w); } else{ w = (Word)wc.get(words[j]); } w.addWordInstance(); } } }//end adding all of the words, now add the connections if(words.length> 1){ addConnections(words, 0); } } //this is a recursive funciton that will public void addConnections(String[] title, int offset){ Word firstWord, secondWord; String paira, pairb; Connection c; //since we know all the words were added at this point, we need to do 4C2 operations if(title.length -1 - offset > 2){ addConnections(title, offset+1); } //make sure the current word isn't forbidden if(wc.containsKey(title[offset])){ firstWord = (Word) wc.get(title[offset]); for(int a = offset+1; a < title.length; a++){ //make sure this word isn't forbidden if(wc.containsKey(title[a])){ secondWord = (Word) wc.get(title[a]); paira = firstWord.word+","+secondWord.word; pairb = secondWord.word+","+firstWord.word; if(connections.containsKey(paira)){ c = (Connection) connections.get(paira); c.count++; } else if(connections.containsKey(pairb)){ c = (Connection)connections.get(pairb); c.count++; } else{ c = new Connection(firstWord, secondWord); connections.put(paira,c); } } } } }