Skip to content

Filter

Filter

Bases: KIF_Object

Criterion for matching statements.

A statement matches a filter if:

  • Its subject matches the filter subject.
  • Its property matches the filter property.
  • Its value (if any) matches the filter value.
  • Its snak type matches the filter snak_mask.
  • Its subject type matches the filter subject_mask.
  • Its property type matches the filter property_mask
  • Its value type (if any) matches the filter value_mask.
  • Its rank (if any) matches the filter rank_mask.
  • Its value language (if any) matches the filter language.

Parameters:

  • subject (TFingerprint | None, default: None ) –

    Subject fingerprint.

  • property (TFingerprint | None, default: None ) –

    Property fingerprint.

  • value (TFingerprint | None, default: None ) –

    Value fingerprint.

  • snak_mask (TSnakMask | None, default: None ) –

    Snak mask.

  • subject_mask (TDatatypeMask | None, default: None ) –

    Datatype mask.

  • property_mask (TPropertyMask | None, default: None ) –

    Property mask.

  • value_mask (TDatatypeMask | None, default: None ) –

    Datatype mask.

  • rank_mask (TRankMask | None, default: None ) –

    Rank mask.

  • best_ranked (bool | None, default: None ) –

    Best-ranked flag.

  • language (TTextLanguage | None, default: None ) –

    Language.

  • annotated (bool | None, default: None ) –

    Annotated flag.

DatatypeMask

Bases: Flags

Mask for concrete datatype classes.

match(datatype)

Tests whether datatype mask matches datatype.

Parameters:

  • datatype (TDatatype) –

    Datatype.

Returns:

  • bool

    True if successful; False otherwise.

PropertyMask

Bases: Flags

Mask for concrete property classes.

match(property)

Tests whether property mask matches property.

Parameters:

  • property (TProperty) –

    Property.

Returns:

  • bool

    True if successful; False otherwise.

RankMask

Bases: Flags

Mask for concrete rank classes.

match(rank)

Tests whether rank mask matches rank.

Parameters:

  • rank (TRank) –

    Rank.

Returns:

  • bool

    True if successful; False otherwise.

SnakMask

Bases: Flags

Mask for concrete snak classes.

match(snak)

Tests whether snak mask matches snak.

Parameters:

  • snak (TSnak) –

    Snak.

Returns:

  • bool

    True if successful; False otherwise.

annotated()

The annotated flag of filter.

best_ranked()

The best-ranked flag of filter.

combine(*others, operator='and')

Combines filter with others.

The operator ("and" or "or") determines the logical operator to be used to combine the filters.

Parameters:

  • others (Filter, default: () ) –

    Filters.

  • operator (Literal['and', 'or'], default: 'and' ) –

    Logical operator.

Returns:

from_snak(subject=None, snak=None) classmethod

Creates filter from snak.

Parameters:

  • subject (TFingerprint | None, default: None ) –

    Entity fingerprint.

  • snak (Snak | None, default: None ) –

    Snak.

Returns:

from_statement(stmt) classmethod

Creates filter from statement.

Parameters:

Returns:

get_annotated()

Gets the annotated flag of filter.

Whether to fetch statement annotations.

Returns:

  • bool

    Annotated flag.

get_best_ranked()

Gets the best-ranked flag of filter.

Whether to match best-ranked statements.

Returns:

  • bool

    Annotated flag.

get_language()

Gets the language criterion of filter.

Returns:

  • str | None

    Language.

get_property()

Gets the property criterion of filter.

Returns:

get_property_mask()

Gets the property mask of filter.

Returns:

get_rank_mask()

Gets the rank mask of filter.

Returns:

get_snak_mask()

Gets the snak mask of filter.

Returns:

get_subject()

Gets the subject criterion of filter.

Returns:

get_subject_mask()

Gets the subject mask of filter.

Returns:

get_value()

Gets the value criterion of filter.

Returns:

get_value_mask()

Gets the value mask of filter.

Returns:

is_empty()

Tests whether filter is empty.

An empty filter matches nothing.

Returns:

  • bool

    True if successful; False otherwise.

is_full()

Tests whether filter is full.

A full filter matches anything.

Returns:

  • bool

    True if successful; False otherwise.

is_nonempty()

Tests whether filter is non-empty.

Returns:

  • bool

    True if successful; False otherwise.

is_nonfull()

Tests whether filter is non-full.

Returns:

  • bool

    True if successful; False otherwise.

language()

The language criterion of filter.

match(stmt)

Tests whether filter shallow-matches statement.

Parameters:

  • stmt (TStatement) –

    Statement.

Returns:

  • bool

    True if successful; False otherwise.

normalize()

Reduces filter to a normal form.

Normalizes the fingerprint expressions in filter.

Returns:

property()

The property criterion of filter.

property_mask()

The property mask of filter.

rank_mask()

The rank mask of filter.

snak_mask()

The snak mask of filter.

subject()

The subject criterion of filter.

subject_mask()

The subject mask of filter.

value()

The value criterion of filter.

value_mask()

The value mask of filter.

Fingerprint

Bases: KIF_Object

Abstract base class for fingerprint expressions.

datatype_mask property

The datatypes shallow-matched by fingerprint.

range_datatype_mask property

The datatypes shallow-matched by the range of fingerprint.

get_datatype_mask()

Gets the datatypes shallow-matched by fingerprint.

Returns:

get_range_datatype_mask()

Gets the datatypes shallow-matched by the range of fingerprint.

Returns:

is_empty()

Tests whether fingerprint is empty (matches nothing).

Returns:

  • bool

    True if successful; False otherwise.

is_full()

Tests whether fingerprint is full (matches anything).

Returns:

  • bool

    True if successful; False otherwise.

match(value)

Tests whether fingerprint shallow-matches value.

Parameters:

  • value (TValue) –

    Value.

Returns:

  • bool

    True if successful; False otherwise.

normalize(datatype_mask=None)

Reduces fingerprint to a normal form.

If datatype_mask is given, ensures that the resulting fingerprint matches only values with a datatype in datatype_mask.

Returns:

And = AndFingerprint module-attribute

Or = OrFingerprint module-attribute