com.googlecode.whatswrong
Class EdgeLabelFilter

java.lang.Object
  extended by com.googlecode.whatswrong.EdgeFilter
      extended by com.googlecode.whatswrong.EdgeLabelFilter
All Implemented Interfaces:
NLPInstanceFilter

public class EdgeLabelFilter
extends EdgeFilter

An EdgeLabelFilter filters out edges with a label that contains one of a set of allowed label substrings.

Note that if the set of allowed label substrings is empty the filter allows all edges.

Author:
Sebastian Riedel

Constructor Summary
EdgeLabelFilter(java.util.Set<java.lang.String> allowedLabels)
          Creates a new EdgeLabelFilter that allows the given label substrings.
EdgeLabelFilter(java.lang.String... allowedLabels)
          Creates a new EdgeLabelFilter that allows the given label substrings.
 
Method Summary
 void addAllowedLabel(java.lang.String label)
          Adds an allowed label substring.
 boolean allows(java.lang.String label)
          Checks whether the filter allows the given label substring.
 void clear()
          Removes all allowed label substrings.
 java.util.Collection<Edge> filterEdges(java.util.Collection<Edge> original)
          Filters out all edges that don't have a label that contains one of the allowed label substrings.
 void removeAllowedLabel(java.lang.String label)
          Removes an allowed label substring.
 
Methods inherited from class com.googlecode.whatswrong.EdgeFilter
filter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EdgeLabelFilter

public EdgeLabelFilter(java.lang.String... allowedLabels)
Creates a new EdgeLabelFilter that allows the given label substrings.

Parameters:
allowedLabels - var array label substrings that are allowed.

EdgeLabelFilter

public EdgeLabelFilter(java.util.Set<java.lang.String> allowedLabels)
Creates a new EdgeLabelFilter that allows the given label substrings.

Parameters:
allowedLabels - a set of label substrings that are allowed.
Method Detail

addAllowedLabel

public void addAllowedLabel(java.lang.String label)
Adds an allowed label substring.

Parameters:
label - the label that should be allowed.

removeAllowedLabel

public void removeAllowedLabel(java.lang.String label)
Removes an allowed label substring.

Parameters:
label - the label substring to disallow.

clear

public void clear()
Removes all allowed label substrings. In this state the filter allows all labels.


filterEdges

public java.util.Collection<Edge> filterEdges(java.util.Collection<Edge> original)
Filters out all edges that don't have a label that contains one of the allowed label substrings. If the set of allowed substrings is empty then the original set of edges is returned as is.

Specified by:
filterEdges in class EdgeFilter
Parameters:
original - the original set of edges.
Returns:
a filtered version of the original edge collection.
See Also:
EdgeFilter#filterEdges(Collection)

allows

public boolean allows(java.lang.String label)
Checks whether the filter allows the given label substring.

Parameters:
label - the label substring we want to check whether the filter allows it.
Returns:
true iff the filter allows the given label substring.


Copyright © 2009. All Rights Reserved.