QueryHandler

class QueryHandler(expression_string)[source]

Parse a search expression into a form than can be used to search a HED string.

Methods

QueryHandler.__init__(expression_string)

Compiles a QueryHandler for a particular expression, so it can be used to search hed strings.

QueryHandler.search(hed_string_obj)

Returns if a match is found in the given string

Attributes

QueryHandler.__init__(expression_string)[source]

Compiles a QueryHandler for a particular expression, so it can be used to search hed strings.

Basic Input Examples:

‘Event’ - Finds any strings with Event, or a descendent tag of Event such as Sensory-event.

‘Event and Action’ - Find any strings with Event and Action, including descendant tags.

‘Event or Action’ - Same as above, but it has either.

‘“Event”’ - Finds the Event tag, but not any descendent tags.

Def/DefName/* - Find Def/DefName instances with placeholders, regardless of the value of the placeholder.

‘Eve*’ - Find any short tags that begin with Eve*, such as Event, but not Sensory-event.

‘[Event and Action]’ - Find a group that contains both Event and Action(at any level).

‘{Event and Action}’ - Find a group with Event And Action at the same level.

‘{Event and Action:}’ - Find a group with Event And Action at the same level, and nothing else.

‘{Event and Action:Agent}’ - Find a group with Event And Action at the same level, and optionally an Agent tag.

Practical Complex Example:

{(Onset or Offset), (Def or {Def-expand}): ???} - A group with an onset tag,

a def tag or def-expand group, and an optional wildcard group

Parameters:

expression_string (str) – The query string.

QueryHandler.search(hed_string_obj)[source]

Returns if a match is found in the given string

Parameters:

hed_string_obj (HedString) – String to search

Returns:

Generally you should just treat this as a bool

True if a match was found.

Return type:

list(SearchResult)