public Set<Integer> getSequenceIDs() { Set<Integer> ensemble = new HashSet<Integer>(); for (PseudoSequence sequence : getPseudoSequences()) { ensemble.add(sequence.getId()); } return ensemble; }
/** * Method to find all frequent items in a projected sequence database * * @param sequences the set of sequences * @return A list of pairs, where a pair is an item with (1) a boolean indicating if it is in an * itemset that is "cut" and (2) the sequence IDs where it occurs. */ protected Set<Pair> findAllFrequentPairs( SequentialPattern prefix, List<PseudoSequence> sequences) { // We use a Map the store the pairs. Map<Pair, Pair> mapPairs = new HashMap<Pair, Pair>(); // for each sequence for (PseudoSequence sequence : sequences) { // for each itemset for (int i = 0; i < sequence.size(); i++) { // for each item for (int j = 0; j < sequence.getSizeOfItemsetAt(i); j++) { String item = sequence.getItemAtInItemsetAt(j, i); // create the pair corresponding to this item Pair paire = new Pair(sequence.isPostfix(i), item); // false is ok? // get the pair object store in the map if there is one already Pair oldPaire = mapPairs.get(paire); // if there is no pair object yet if (oldPaire == null) { // store the pair object that we created mapPairs.put(paire, paire); } else { // otherwise use the old one paire = oldPaire; } // record the current sequence id for that pair paire.getSequencesID().add(sequence.getId()); } } } MemoryLogger.getInstance().checkMemory(); // check the memory for statistics. // return the map of pairs return mapPairs.keySet(); }
@Override public String toString() { StringBuffer r = new StringBuffer("============ CONTEXTE =========="); for (PseudoSequence sequence : pseudoSequences) { // pour chaque objet r.append(sequence.getId()); r.append(": "); r.append(sequence.toString()); r.append('\n'); } return r.toString(); }