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 && Action’ - Find any strings with Event and Action, including descendant tags.

‘Event || 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 && Action]’ - Find a group that contains both Event and Action(at any level).

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

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

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

Practical Complex Example:

{(Onset || Offset), (Def || {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)