Esempio n. 1
0
  /**
   * Create a projected database by pseudo-projection
   *
   * @param item The item to use to make the pseudo-projection
   * @param context The current database.
   * @param inSuffix This boolean indicates if the item "item" is part of a suffix or not.
   * @return the projected database.
   */
  private List<PseudoSequenceBIDE> buildProjectedDatabase(
      Integer item, List<PseudoSequenceBIDE> database, boolean inSuffix, Set<Integer> sidset) {
    // The projected pseudo-database
    List<PseudoSequenceBIDE> sequenceDatabase = new ArrayList<PseudoSequenceBIDE>();

    // for each sequence
    loop1:
    for (PseudoSequenceBIDE sequence : database) {

      if (sidset.contains(sequence.getId()) == false) {
        continue;
      }

      // for each item of the sequence
      for (int i = 0; i < sequence.size(); i++) {

        int sizeOfItemsetAti = sequence.getSizeOfItemsetAt(i);

        // check if the itemset contains the item that we use for the projection
        int index = sequence.indexOf(sizeOfItemsetAti, i, item);
        // if it does not, and the current item is part of a suffix if inSuffix is true
        //   and vice-versa
        if (index != -1 && sequence.isPostfix(i) == inSuffix) {
          if (index != sizeOfItemsetAti - 1) { // if this is not the last item of the itemset
            // create a new pseudo sequence
            // add it to the projected database.
            sequenceDatabase.add(new PseudoSequenceBIDE(sequence, i, index + 1));
            //							continue loop1;
            //						}
          } else if ((i
              != sequence.size() - 1)) { // if this is not the last itemset of the sequence			
            // create a new pseudo sequence
            // add it to the projected database.
            sequenceDatabase.add(new PseudoSequenceBIDE(sequence, i + 1, 0));
            //						continue loop1;
          }
        }
      }
    }
    return sequenceDatabase; // return the projected database
  }
Esempio n. 2
0
  /**
   * Create a projected database by pseudo-projection
   *
   * @param item The item to use to make the pseudo-projection
   * @param context The current database.
   * @param inSuffix This boolean indicates if the item "item" is part of a suffix or not.
   * @return the projected database.
   */
  private List<PseudoSequenceBIDE> buildProjectedContextSingleItem(
      Integer item,
      Map<Integer, PseudoSequenceBIDE> initialDatabase2,
      boolean inSuffix,
      Set<Integer> sidset) {
    // The projected pseudo-database
    List<PseudoSequenceBIDE> sequenceDatabase = new ArrayList<PseudoSequenceBIDE>();

    // for each sequence
    loop1:
    for (int sid : sidset) {
      PseudoSequenceBIDE sequence = initialDatabase2.get(sid);

      // for each itemset of the sequence
      for (int i = 0; i < sequence.size(); i++) {

        int sizeOfItemsetAti = sequence.getSizeOfItemsetAt(i);

        // find the position of the item used for the projection in this itemset if it appears
        int index = sequence.indexOf(sizeOfItemsetAti, i, item);
        // if it does appear and it is in a postfix/suffix if the item is in a postfix/suffix
        if (index != -1 && sequence.isPostfix(i) == inSuffix) {
          // if this is not the last item of the itemset
          if (index != sizeOfItemsetAti - 1) {
            // create a new pseudo sequence
            sequenceDatabase.add(new PseudoSequenceBIDE(sequence, i, index + 1));
            //						continue loop1;
          } else if (i
              != sequence.size() - 1) { // if this is not the last itemset of the sequence			
            // create a new pseudo sequence
            // if the size of this pseudo sequence is greater than 0
            // add it to the projected database.
            sequenceDatabase.add(new PseudoSequenceBIDE(sequence, i + 1, 0));
            //						continue loop1;
          }
        }
      }
    }
    return sequenceDatabase; // return the projected database
  }