org.put.semintec.mining.association
Class Pattern

java.lang.Object
  extended by org.put.semintec.mining.association.Pattern

public class Pattern
extends java.lang.Object

Represents a pattern.

Author:
Agnieszka Lawrynowicz

Constructor Summary
Pattern(org.semanticweb.kaon2.api.logic.QueryDefinition qd)
           
 
Method Summary
 java.util.ArrayList computeUndistinguishedVariables()
           
 java.util.ArrayList computeUndistinguishedVariablesSharedWith(Atom a)
           
 java.util.ArrayList determineVariablesConnectedToLastAtom(Atom lastAtom)
          Determines, according to principles of SMARTCALL transformation, bindings of what variables will be affected by adding new atom (except the reference variable)
 boolean equivalentTo(Pattern p, KnowledgeBase kb)
           
 void evaluate(int refClassFrequency, KnowledgeBase kb)
          Evaluates pattern, that is calculates its support
 int getFrequency()
          Getter of the property frequency
 org.semanticweb.kaon2.api.logic.QueryDefinition getQueryDefinition()
          Getter of the property queryDefinition
 double getSupport()
          Getter of the property support
 java.util.ArrayList getUndistinguishedVariables()
          Getter of the property undistinguishedVariables
 boolean isFrequent(double minSupp)
           
 boolean isSatisfiable(KnowledgeBase kb)
           
 boolean isSFree(KnowledgeBase kb)
          Checks if the pattern is semantically free w.r.t. given knowledge base, that is if it is not possible to delete any of its atoms without affecting the semantics.
 Pattern refine(Atom a)
          Refines pattern by adding an atom to it
 Pattern rewriteVariablesToDistinguishedOnes()
          Rewrites query Q1 associated with the given pattern into new query Q2 where all variables of Q1 (distinguished and undistinguished ones) are distinguished in Q2
 void setFrequency(int frequency)
          Setter of the property frequency
 void setQueryDefinition(org.semanticweb.kaon2.api.logic.QueryDefinition queryDefinition)
          Setter of the property queryDefinition
 void setSupport(double support)
          Setter of the property support
 void setUndistinguishedVariables(java.util.ArrayList undistinguishedVariables)
          Setter of the property undistinguishedVariables
 java.util.List skolemize(KnowledgeBase kb)
          Skolemizes a query associated with the given pattern -- replaces all variables with new constants thus creating new ABox
 boolean subsumedBy(Pattern p, KnowledgeBase kb)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pattern

public Pattern(org.semanticweb.kaon2.api.logic.QueryDefinition qd)
Parameters:
QueryDefinition - associated with the pattern
Method Detail

getQueryDefinition

public org.semanticweb.kaon2.api.logic.QueryDefinition getQueryDefinition()
Getter of the property queryDefinition

Returns:
Returns the queryDefinition.

setQueryDefinition

public void setQueryDefinition(org.semanticweb.kaon2.api.logic.QueryDefinition queryDefinition)
Setter of the property queryDefinition

Parameters:
queryDefinition - The queryDefinition to set.

getUndistinguishedVariables

public java.util.ArrayList getUndistinguishedVariables()
Getter of the property undistinguishedVariables

Returns:
Returns the undistinguishedVariables.

setUndistinguishedVariables

public void setUndistinguishedVariables(java.util.ArrayList undistinguishedVariables)
Setter of the property undistinguishedVariables

Parameters:
undistinguishedVariables - The undistinguishedVariables to set.

getFrequency

public int getFrequency()
Getter of the property frequency

Returns:
Returns the frequency.

setFrequency

public void setFrequency(int frequency)
Setter of the property frequency

Parameters:
frequency - The frequency to set.

getSupport

public double getSupport()
Getter of the property support

Returns:
Returns the support.

setSupport

public void setSupport(double support)
Setter of the property support

Parameters:
support - The support to set.

refine

public Pattern refine(Atom a)
               throws org.semanticweb.kaon2.api.KAON2Exception
Refines pattern by adding an atom to it

Parameters:
a - Atom by which current pattern is extended
Returns:
New refined pattern
Throws:
org.semanticweb.kaon2.api.KAON2Exception

equivalentTo

public boolean equivalentTo(Pattern p,
                            KnowledgeBase kb)
                     throws org.semanticweb.kaon2.api.KAON2Exception,
                            java.lang.InterruptedException
Parameters:
p - A pattern that is tested whether it is semantically equivalent to the given pattern.
kb - A knowledge base w.r.t. pattern equivalence is tested.
Returns:
True if the given pattern is equivalent to pattern p w.r.t. a knowledge base kb.
Throws:
java.lang.InterruptedException
org.semanticweb.kaon2.api.KAON2Exception

isSFree

public boolean isSFree(KnowledgeBase kb)
                throws org.semanticweb.kaon2.api.KAON2Exception,
                       java.lang.InterruptedException
Checks if the pattern is semantically free w.r.t. given knowledge base, that is if it is not possible to delete any of its atoms without affecting the semantics. The exception to this procedure is the atom with the reference concept which is not included in s-freeness tests.

Parameters:
kb - A knowledge base
Returns:
True if the pattern is semantically free
Throws:
java.lang.InterruptedException
org.semanticweb.kaon2.api.KAON2Exception
org.semanticweb.kaon2.api.KAON2Exception
java.lang.InterruptedException

skolemize

public java.util.List skolemize(KnowledgeBase kb)
                         throws org.semanticweb.kaon2.api.KAON2Exception,
                                java.lang.InterruptedException
Skolemizes a query associated with the given pattern -- replaces all variables with new constants thus creating new ABox

Parameters:
kb - A knowledge base to store result of the skolemization
Returns:
A list of ontology change events (of type ) to rollback the skolemization from the knowledge base
Throws:
java.lang.InterruptedException
org.semanticweb.kaon2.api.KAON2Exception

isSatisfiable

public boolean isSatisfiable(KnowledgeBase kb)
                      throws org.semanticweb.kaon2.api.KAON2Exception,
                             java.lang.InterruptedException
Parameters:
kb - A knowledge base
Returns:
True if a pattern is satisfiable w.r.t. a given knowledge base.
Throws:
org.semanticweb.kaon2.api.KAON2Exception
java.lang.InterruptedException

subsumedBy

public boolean subsumedBy(Pattern p,
                          KnowledgeBase kb)
                   throws org.semanticweb.kaon2.api.KAON2Exception,
                          java.lang.InterruptedException
Parameters:
p - A pattern that is tested whether it subsumes the given pattern.
kb - A knowledge base w.r.t. pattern subsumption is tested.
Returns:
True if the given pattern is subsumed by pattern p w.r.t. a knowledge base kb.
Throws:
org.semanticweb.kaon2.api.KAON2Exception
java.lang.InterruptedException

evaluate

public void evaluate(int refClassFrequency,
                     KnowledgeBase kb)
              throws org.semanticweb.kaon2.api.KAON2Exception,
                     java.lang.InterruptedException
Evaluates pattern, that is calculates its support

Parameters:
refClassFrequency - Frequency of the reference class wrt which the support of the pattern is calculated
kb - Knowledge base wrt which pattern should be evaluated
Throws:
java.lang.InterruptedException
org.semanticweb.kaon2.api.KAON2Exception

isFrequent

public boolean isFrequent(double minSupp)
                   throws org.semanticweb.kaon2.api.KAON2Exception,
                          java.lang.InterruptedException
Parameters:
minSupp - Minimum support threshold
Returns:
True if the support of the pattern is above minimum support threshold false otherwise
Throws:
java.lang.InterruptedException
org.semanticweb.kaon2.api.KAON2Exception

computeUndistinguishedVariables

public java.util.ArrayList computeUndistinguishedVariables()
Returns:
Undistinguished variables of the query associated with the pattern.

computeUndistinguishedVariablesSharedWith

public java.util.ArrayList computeUndistinguishedVariablesSharedWith(Atom a)
Parameters:
a - Atom with the variables from which the resulting list should be generated
Returns:
Undistinguished variables of the query associated with the pattern that appear in both: the query and in atom a

rewriteVariablesToDistinguishedOnes

public Pattern rewriteVariablesToDistinguishedOnes()
                                            throws org.semanticweb.kaon2.api.KAON2Exception
Rewrites query Q1 associated with the given pattern into new query Q2 where all variables of Q1 (distinguished and undistinguished ones) are distinguished in Q2

Returns:
New pattern, based on query Q2, where all variables from the initial pattern (query Q1) are distinguished ones
Throws:
org.semanticweb.kaon2.api.KAON2Exception

determineVariablesConnectedToLastAtom

public java.util.ArrayList determineVariablesConnectedToLastAtom(Atom lastAtom)
                                                          throws org.semanticweb.kaon2.api.KAON2Exception
Determines, according to principles of SMARTCALL transformation, bindings of what variables will be affected by adding new atom (except the reference variable)

Parameters:
lastAtom - Last atom of the pattern
Returns:
List of variables whose bindings will be affected by adding new atom
Throws:
org.semanticweb.kaon2.api.KAON2Exception