QueryParser

class QueryParser(expression_string)[source]

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

Methods

hed.models.expression_parser.QueryParser.__init__(...)

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

hed.models.expression_parser.QueryParser.current_token()

hed.models.expression_parser.QueryParser.search(...)

Attributes

QueryParser.__init__(expression_string)[source]

Compiles a QueryParser 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

QueryParser.current_token()[source]
QueryParser.search(hed_string_obj)[source]