/** * Get the number of items in this pattern. Note that if an item appear twice, it will be counted * twice. * * @return the number of items */ public int getItemOccurencesTotalCount() { int count = 0; // for each itemset for (Itemset itemset : itemsets) { // add the size of this itemset count += itemset.size(); } return count; // return the total size. }
/** * Make a copy of this sequential pattern * * @return the copy. */ public SequentialPattern cloneSequence() { // create a new empty sequential pattenr SequentialPattern sequence = new SequentialPattern(); // for each itemset for (Itemset itemset : itemsets) { // make a copy and add it sequence.addItemset(itemset.cloneItemSet()); } return sequence; // return the copy }
/** Get a string representation of this sequential pattern. */ public String itemsetsToString() { StringBuffer r = new StringBuffer(""); for (Itemset itemset : itemsets) { r.append('{'); for (Integer item : itemset.getItems()) { String string = item.toString(); r.append(string); r.append(' '); } r.append('}'); } return r.append(" ").toString(); }
/** * Get a string representation of this sequential pattern, containing the sequence IDs of sequence * containing this pattern. */ public String toString() { StringBuffer r = new StringBuffer(""); // For each itemset in this sequential pattern for (Itemset itemset : itemsets) { r.append('('); // begining of an itemset // For each item in the current itemset for (Integer item : itemset.getItems()) { String string = item.toString(); r.append(string); // append the item r.append(' '); } r.append(')'); // end of an itemset } // add the list of sequence IDs that contains this pattern. if (getSequencesID() != null) { r.append(" Sequence ID: "); for (Integer id : getSequencesID()) { r.append(id); r.append(' '); } } return r.append(" ").toString(); }