decomp.semantics.predpatt.filters

Filters for refining predicate and argument extractions based on linguistic criteria.

Filtering functions for refining PredPatt extractions.

This module provides predicate and argument filters that can be applied to refine the output of PredPatt extraction based on linguistic criteria such as verb type, syntactic role, and semantic properties.

Functions

Predicate Filters

is_pred_verb

Check if predicate root is a verb.

is_not_copula

Exclude copular predicates.

is_not_have

Exclude “have” predicates.

is_not_interrogative

Exclude interrogative predicates.

has_subj

Check if predicate has a subject.

is_good_ancestor

Check if predicate has good dependency ancestors.

is_good_descendants

Check if predicate has good dependency descendants.

filter_events_nucl

Filter predicates for NUCL event extraction.

filter_events_sprl

Filter predicates for SituatedPRL event extraction.

Argument Filters

is_sbj_or_obj

Check if argument is subject or object.

is_not_pronoun

Exclude pronominal arguments.

has_direct_arc

Check for direct dependency arc.

Filter Application

apply_filters

Apply multiple filters to extractions.

activate

Activate specific filter configurations.

Notes

Filters can be combined using PredPattOpts to customize extraction behavior. Backward compatibility aliases use camelCase naming.

activate(pred)[source]

Apply all predicate and argument filters to a predicate.

Demonstrates how to apply all available filters to a predicate and its arguments. Initializes empty rules lists before applying.

Parameters:

pred (Predicate) – The predicate to apply all filters to.

Return type:

None

apply_filters(_filter, pred, **options)[source]

Apply a filter function with proper parameter handling.

Handles different filter function signatures and parameter requirements. Supports both predicate filters and argument filters.

Parameters:
  • _filter (callable) – The filter function to apply.

  • pred (Predicate) – The predicate to filter.

  • **options (bool) – Additional options for the filter (e.g., passive for hasSubj).

Returns:

True if filter accepts the predicate/arguments, False otherwise.

Return type:

bool

filter_events_NUCL(event, parse)

Apply filters for running Keisuke’s NUCLE HIT.

Combines multiple predicate filters for the NUCL evaluation. Only applies if the event is not interrogative.

Parameters:
  • event (Predicate) – The predicate event to filter.

  • parse (UDParse) – The dependency parse (included for compatibility).

Returns:

True if event passes all NUCL filters (accept), False otherwise (reject).

Return type:

bool

filter_events_SPRL(event, parse)

Apply filters for running UD SPRL HIT.

Combines multiple predicate filters for the SPRL evaluation. Only applies if the parse is not interrogative.

Parameters:
  • event (Predicate) – The predicate event to filter.

  • parse (UDParse) – The dependency parse (used for interrogative check).

Returns:

True if event passes all SPRL filters (accept), False otherwise (reject).

Return type:

bool

filter_events_nucl(event, parse)[source]

Apply filters for running Keisuke’s NUCLE HIT.

Combines multiple predicate filters for the NUCL evaluation. Only applies if the event is not interrogative.

Parameters:
  • event (Predicate) – The predicate event to filter.

  • parse (UDParse) – The dependency parse (included for compatibility).

Returns:

True if event passes all NUCL filters (accept), False otherwise (reject).

Return type:

bool

filter_events_sprl(event, parse)[source]

Apply filters for running UD SPRL HIT.

Combines multiple predicate filters for the SPRL evaluation. Only applies if the parse is not interrogative.

Parameters:
  • event (Predicate) – The predicate event to filter.

  • parse (UDParse) – The dependency parse (used for interrogative check).

Returns:

True if event passes all SPRL filters (accept), False otherwise (reject).

Return type:

bool

hasSubj(pred, passive=False)

Filter predicates that have subjects.

Checks if the predicate has a subject dependent. Optionally includes passive subjects (nsubjpass) when passive=True.

Parameters:
  • pred (Predicate) – The predicate to check.

  • passive (bool, optional) – Whether to include passive subjects (nsubjpass). Default: False.

Returns:

True if predicate has a subject (accept), False otherwise (reject).

Return type:

bool

has_direct_arc(pred, arg)[source]

Check if the argument and predicate has a direct arc.

Verifies that the argument root token is directly governed by the predicate root token.

Parameters:
Returns:

True if there is a direct dependency arc (accept), False otherwise (reject).

Return type:

bool

has_subj(pred, passive=False)[source]

Filter predicates that have subjects.

Checks if the predicate has a subject dependent. Optionally includes passive subjects (nsubjpass) when passive=True.

Parameters:
  • pred (Predicate) – The predicate to check.

  • passive (bool, optional) – Whether to include passive subjects (nsubjpass). Default: False.

Returns:

True if predicate has a subject (accept), False otherwise (reject).

Return type:

bool

isGoodAncestor(pred)

Filter predicates with good ancestry.

Returns true if verb is not dominated by a relation that might alter its veridicality. This filter is very conservative; many veridical verbs will be excluded.

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate has good ancestry (accept), False otherwise (reject).

Return type:

bool

isGoodDescendants(pred)

Filter predicates with good descendants.

Returns true if verb immediately dominates a relation that might alter its veridicality. This filter is very conservative; many veridical verbs will be excluded.

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate has good descendants (accept), False otherwise (reject).

Return type:

bool

isNotCopula(pred)

Filter out copula constructions.

Checks if any of the dependents of pred are copula verbs. UD annotates copula verbs only when the nonverbal predicate is the head of the clause.

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate is not a copula construction (accept), False otherwise (reject).

Return type:

bool

isNotHave(pred)

Filter out ‘have’ verbs.

Excludes predicates with ‘have’, ‘had’, or ‘has’ as the root text.

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate is not a ‘have’ verb (accept), False otherwise (reject).

Return type:

bool

isNotInterrogative(pred)

Filter out interrogative predicates.

Checks if the predicate contains a question mark. This is a simple heuristic filter to exclude interrogative sentences.

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate does not contain ‘?’ (accept), False otherwise (reject).

Return type:

bool

isNotPronoun(arg)

Filter out pronoun arguments.

Excludes arguments that are pronouns (PRP tag) or specific pronoun-like words: that, this, which, what.

Parameters:

arg (Argument) – The argument to check.

Returns:

True if argument is not a pronoun (accept), False otherwise (reject).

Return type:

bool

isPredVerb(pred)

Filter to accept only verbal predicates.

Checks if the predicate root has a verbal part-of-speech tag (starts with ‘V’).

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate root tag starts with ‘V’ (accept), False otherwise (reject).

Return type:

bool

isSbjOrObj(arg)

Filter to accept core arguments (subjects and objects).

Accepts arguments with core grammatical relations: nsubj, dobj, iobj.

Parameters:

arg (Argument) – The argument to check.

Returns:

True if argument is a core argument (accept), False otherwise (reject).

Return type:

bool

is_good_ancestor(pred)[source]

Filter predicates with good ancestry.

Returns true if verb is not dominated by a relation that might alter its veridicality. This filter is very conservative; many veridical verbs will be excluded.

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate has good ancestry (accept), False otherwise (reject).

Return type:

bool

is_good_descendants(pred)[source]

Filter predicates with good descendants.

Returns true if verb immediately dominates a relation that might alter its veridicality. This filter is very conservative; many veridical verbs will be excluded.

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate has good descendants (accept), False otherwise (reject).

Return type:

bool

is_not_copula(pred)[source]

Filter out copula constructions.

Checks if any of the dependents of pred are copula verbs. UD annotates copula verbs only when the nonverbal predicate is the head of the clause.

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate is not a copula construction (accept), False otherwise (reject).

Return type:

bool

is_not_have(pred)[source]

Filter out ‘have’ verbs.

Excludes predicates with ‘have’, ‘had’, or ‘has’ as the root text.

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate is not a ‘have’ verb (accept), False otherwise (reject).

Return type:

bool

is_not_interrogative(pred)[source]

Filter out interrogative predicates.

Checks if the predicate contains a question mark. This is a simple heuristic filter to exclude interrogative sentences.

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate does not contain ‘?’ (accept), False otherwise (reject).

Return type:

bool

is_not_pronoun(arg)[source]

Filter out pronoun arguments.

Excludes arguments that are pronouns (PRP tag) or specific pronoun-like words: that, this, which, what.

Parameters:

arg (Argument) – The argument to check.

Returns:

True if argument is not a pronoun (accept), False otherwise (reject).

Return type:

bool

is_pred_verb(pred)[source]

Filter to accept only verbal predicates.

Checks if the predicate root has a verbal part-of-speech tag (starts with ‘V’).

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate root tag starts with ‘V’ (accept), False otherwise (reject).

Return type:

bool

is_sbj_or_obj(arg)[source]

Filter to accept core arguments (subjects and objects).

Accepts arguments with core grammatical relations: nsubj, dobj, iobj.

Parameters:

arg (Argument) – The argument to check.

Returns:

True if argument is a core argument (accept), False otherwise (reject).

Return type:

bool

Submodules

decomp.semantics.predpatt.filters.predicate_filters

Predicate filtering functions for PredPatt.

This module contains filter functions that determine whether predicates should be included in the final extraction results based on various linguistic and structural criteria.

is_not_interrogative(pred)[source]

Filter out interrogative predicates.

Checks if the predicate contains a question mark. This is a simple heuristic filter to exclude interrogative sentences.

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate does not contain ‘?’ (accept), False otherwise (reject).

Return type:

bool

is_pred_verb(pred)[source]

Filter to accept only verbal predicates.

Checks if the predicate root has a verbal part-of-speech tag (starts with ‘V’).

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate root tag starts with ‘V’ (accept), False otherwise (reject).

Return type:

bool

is_not_copula(pred)[source]

Filter out copula constructions.

Checks if any of the dependents of pred are copula verbs. UD annotates copula verbs only when the nonverbal predicate is the head of the clause.

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate is not a copula construction (accept), False otherwise (reject).

Return type:

bool

is_good_ancestor(pred)[source]

Filter predicates with good ancestry.

Returns true if verb is not dominated by a relation that might alter its veridicality. This filter is very conservative; many veridical verbs will be excluded.

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate has good ancestry (accept), False otherwise (reject).

Return type:

bool

is_good_descendants(pred)[source]

Filter predicates with good descendants.

Returns true if verb immediately dominates a relation that might alter its veridicality. This filter is very conservative; many veridical verbs will be excluded.

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate has good descendants (accept), False otherwise (reject).

Return type:

bool

has_subj(pred, passive=False)[source]

Filter predicates that have subjects.

Checks if the predicate has a subject dependent. Optionally includes passive subjects (nsubjpass) when passive=True.

Parameters:
  • pred (Predicate) – The predicate to check.

  • passive (bool, optional) – Whether to include passive subjects (nsubjpass). Default: False.

Returns:

True if predicate has a subject (accept), False otherwise (reject).

Return type:

bool

is_not_have(pred)[source]

Filter out ‘have’ verbs.

Excludes predicates with ‘have’, ‘had’, or ‘has’ as the root text.

Parameters:

pred (Predicate) – The predicate to check.

Returns:

True if predicate is not a ‘have’ verb (accept), False otherwise (reject).

Return type:

bool

filter_events_nucl(event, parse)[source]

Apply filters for running Keisuke’s NUCLE HIT.

Combines multiple predicate filters for the NUCL evaluation. Only applies if the event is not interrogative.

Parameters:
  • event (Predicate) – The predicate event to filter.

  • parse (UDParse) – The dependency parse (included for compatibility).

Returns:

True if event passes all NUCL filters (accept), False otherwise (reject).

Return type:

bool

filter_events_sprl(event, parse)[source]

Apply filters for running UD SPRL HIT.

Combines multiple predicate filters for the SPRL evaluation. Only applies if the parse is not interrogative.

Parameters:
  • event (Predicate) – The predicate event to filter.

  • parse (UDParse) – The dependency parse (used for interrogative check).

Returns:

True if event passes all SPRL filters (accept), False otherwise (reject).

Return type:

bool

activate(pred)[source]

Apply all predicate and argument filters to a predicate.

Demonstrates how to apply all available filters to a predicate and its arguments. Initializes empty rules lists before applying.

Parameters:

pred (Predicate) – The predicate to apply all filters to.

Return type:

None

apply_filters(_filter, pred, **options)[source]

Apply a filter function with proper parameter handling.

Handles different filter function signatures and parameter requirements. Supports both predicate filters and argument filters.

Parameters:
  • _filter (callable) – The filter function to apply.

  • pred (Predicate) – The predicate to filter.

  • **options (bool) – Additional options for the filter (e.g., passive for hasSubj).

Returns:

True if filter accepts the predicate/arguments, False otherwise.

Return type:

bool

decomp.semantics.predpatt.filters.argument_filters

Argument filtering functions for PredPatt.

This module contains filter functions that determine whether arguments should be included in the final extraction results based on various linguistic and structural criteria.

is_sbj_or_obj(arg)[source]

Filter to accept core arguments (subjects and objects).

Accepts arguments with core grammatical relations: nsubj, dobj, iobj.

Parameters:

arg (Argument) – The argument to check.

Returns:

True if argument is a core argument (accept), False otherwise (reject).

Return type:

bool

is_not_pronoun(arg)[source]

Filter out pronoun arguments.

Excludes arguments that are pronouns (PRP tag) or specific pronoun-like words: that, this, which, what.

Parameters:

arg (Argument) – The argument to check.

Returns:

True if argument is not a pronoun (accept), False otherwise (reject).

Return type:

bool

has_direct_arc(pred, arg)[source]

Check if the argument and predicate has a direct arc.

Verifies that the argument root token is directly governed by the predicate root token.

Parameters:
Returns:

True if there is a direct dependency arc (accept), False otherwise (reject).

Return type:

bool