edu.columbia.cs.cg.prdualrank.graph
Class PRDualRankGraph<T extends Matchable,D extends Document>

java.lang.Object
  extended by edu.columbia.cs.cg.prdualrank.graph.PRDualRankGraph<T,D>

public class PRDualRankGraph<T extends Matchable,D extends Document>
extends java.lang.Object

This class is used for our implementation of: "Searching Patterns for Relation Extraction over the Web: Rediscovering the Pattern-Relation Duality" . Y. Fang and K. C.-C. Chang. In WSDM, pages 825-834, 2011. For further information, WSDM 2011 Conference Website .

Description

The graph connecting patterns and tuples as defined in PRDualRank paper.
This graph associates a Matchable Object with a Document object storing the frequencies with which they occur in the data.
For more information about Graphs, see Section 4 of the mentioned paper.

Since:
2011-10-07
Version:
0.1
Author:
Pablo Barrio, Goncalo Simoes
See Also:
WSDM 2011 Conference Website

Constructor Summary
PRDualRankGraph()
          Instantiates a new PRDualRank graph.
 
Method Summary
 void addContext(Pattern<T,D> pattern, Relationship tuple, int frequency)
          Adds a new connection between a pattern and a tuple.
 double getFreqency(Pattern<T,D> pattern)
          Gets the total frequency of a pattern in the graph.
 int getFrequency(Relationship tuple)
          Gets the total frequency of a tuple.
 int getMatchingFrequency(Pattern<T,D> pattern, Relationship tuple)
          Gets the matching frequency between a pattern and a tuple.
 int getMatchingFrequency(Relationship tuple, Pattern<T,D> pattern)
          Gets the matching frequency between a tuple and a pattern.
 java.util.Set<Pattern<T,D>> getMatchingPatterns(Relationship tuple)
          Gets the matching patterns of a given tuple.
 java.util.Set<Relationship> getMatchingTuples(Pattern<T,D> pattern)
          Gets the matching tuples given a pattern
 java.util.Set<Pattern<T,D>> getPatterns()
          Gets the patterns from the graph.
 java.util.Set<Relationship> getTuples()
          Gets the tuples from the graph.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PRDualRankGraph

public PRDualRankGraph()
Instantiates a new PRDualRank graph.

Method Detail

addContext

public void addContext(Pattern<T,D> pattern,
                       Relationship tuple,
                       int frequency)
Adds a new connection between a pattern and a tuple. Also includes the frequency with which this connection (called 'context' in the paper) appears in the collection being processed.

Parameters:
pattern - the pattern to be added in the graph.
tuple - the tuple to be connected to the pattern.
frequency - the frequency with which this context appears in the 'snippets'

getPatterns

public java.util.Set<Pattern<T,D>> getPatterns()
Gets the patterns from the graph.

Returns:
the patterns

getTuples

public java.util.Set<Relationship> getTuples()
Gets the tuples from the graph.

Returns:
the tuples

getMatchingFrequency

public int getMatchingFrequency(Pattern<T,D> pattern,
                                Relationship tuple)
Gets the matching frequency between a pattern and a tuple.

Parameters:
pattern - the pattern
tuple - the tuple
Returns:
the frequency which which this pair appears in the graph.

getMatchingTuples

public java.util.Set<Relationship> getMatchingTuples(Pattern<T,D> pattern)
Gets the matching tuples given a pattern

Parameters:
pattern - the pattern
Returns:
the matching tuples

getFreqency

public double getFreqency(Pattern<T,D> pattern)
Gets the total frequency of a pattern in the graph. It is the sum of all the individual frequencies with all the matching tuples.

Parameters:
pattern - the pattern
Returns:
the freqency with which the pattern appears in the collection.

getFrequency

public int getFrequency(Relationship tuple)
Gets the total frequency of a tuple. It includes all the patterns that match this tuple.

Parameters:
tuple - the tuple
Returns:
the frequency in the graph.

getMatchingFrequency

public int getMatchingFrequency(Relationship tuple,
                                Pattern<T,D> pattern)
Gets the matching frequency between a tuple and a pattern. Should return the same value than getMatchingFrequency(pattern,tuple) if the graph is consistent.

Parameters:
tuple - the tuple
pattern - the pattern
Returns:
the matching frequency with which the tuple and the pattern appear in the collection (represented in the graph)

getMatchingPatterns

public java.util.Set<Pattern<T,D>> getMatchingPatterns(Relationship tuple)
Gets the matching patterns of a given tuple. The meaning of 'Match' depends on the patterns. For instance, for search patterns, 'to match' means to hit the document containing the tuple. However for extraction patterns, it means to match the context of the tuple in some document.

Parameters:
tuple - the tuple
Returns:
the patterns that 'match' the tuple.