Class Pattern

  • All Implemented Interfaces:
    java.lang.Comparable<Pattern>

    public class Pattern
    extends java.lang.Object
    implements java.lang.Comparable<Pattern>
    Implementation of pattern structure. We define it as a list of pairs . Besides, a bitSet appearingIn denotes the sequences where the pattern appears. Copyright Antonio Gomariz PeƱalver 2013 This file is part of the SPMF DATA MINING SOFTWARE (http://www.philippe-fournier-viger.com/spmf). SPMF is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SPMF is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SPMF. If not, see .
    Author:
    agomariz
    • Constructor Detail

      • Pattern

        public Pattern()
        Standard constructor
      • Pattern

        public Pattern​(java.util.List<ItemAbstractionPair> elements)
        New pattern from a list of pairs
        Parameters:
        elements -
      • Pattern

        public Pattern​(ItemAbstractionPair pair)
        New pattern from a single pair
        Parameters:
        pair -
    • Method Detail

      • toString

        public java.lang.String toString()
        Get the string representation of this pattern
        Overrides:
        toString in class java.lang.Object
        Returns:
        the string representation
      • toStringToFile

        public java.lang.String toStringToFile​(boolean outputSequenceIdentifiers)
        Get the string representation of this pattern. Adjusted to SPMF format.
        Parameters:
        outputSequenceIdentifiers - show the sequence identifiers where the pattern appears if true
        Returns:
        the string representation
      • getSupport

        public int getSupport()
      • clonePatron

        public Pattern clonePatron()
        It clones a pattern
        Returns:
        the clone
      • getElements

        public java.util.List<ItemAbstractionPair> getElements()
        It obtains the elements of the pattern
        Returns:
        the list of elements
      • getIthElement

        public ItemAbstractionPair getIthElement​(int i)
        It obtains the Ith element of the pattern
        Parameters:
        i - the position
        Returns:
        the ith element
      • getLastButOneElement

        public ItemAbstractionPair getLastButOneElement()
        It obtains the last but one element of the pattern
        Returns:
        the last but one element
      • setElements

        public void setElements​(java.util.List<ItemAbstractionPair> elements)
        Setter method to set the elements of the pattern
        Parameters:
        elements - a list of elements
      • add

        public void add​(ItemAbstractionPair pair)
        It adds an item with its abstraction in the pattern. The new pair is added in the last position of the pattern.
        Parameters:
        pair -
      • size

        public int size()
        It returns the number of items contained in the pattern
        Returns:
        the number of items
      • compareTo

        public int compareTo​(Pattern o)
        Compare this pattern with another. Since we always compare elements which belong to the same equivalence class we only make the comparison of the last items of both patterns.
        Specified by:
        compareTo in interface java.lang.Comparable<Pattern>
        Parameters:
        o - the other pattern
        Returns:
        0 if equal, -1 if smaller, otherwise 1
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • isPrefix

        public boolean isPrefix​(Pattern p)
        It informs us if this pattern is a prefix of the argument given pattern.
        Parameters:
        p - the pattern
        Returns:
        true if yes, otherwise false
      • getAppearingIn

        public java.util.BitSet getAppearingIn()
        It returns the list of sequence IDs where the pattern appears.
        Returns:
        the list of sequence IDs
      • setAppearingIn

        public void setAppearingIn​(java.util.BitSet appearingIn)
        it set the list of sequence IDs where the pattern appears.
        Parameters:
        appearingIn -
      • clear

        public void clear()
      • concatenate

        public Pattern concatenate​(ItemAbstractionPair pair)
        It concatenates the given pair as a last element of the pattern
        Parameters:
        pair - the pair
        Returns:
        the resulting pattern
      • concatenar

        public Pattern concatenar​(Pattern pattern)
        It concatenates the given pattern to the current pattern
        Parameters:
        pattern -
        Returns:
        the resulting pattern
      • isSubpattern

        public boolean isSubpattern​(AbstractionCreator abstractionCreator,
                                    Pattern p)
        It answers if the current Pattern is a subpattern of another one given as parameter.
        Parameters:
        abstractionCreator - an abstraction creator
        p - pattern to check if it is a superpattern of the current one
        Returns:
        true if it is a subpattern otherwise, false