Skip to content

Commit

Permalink
Merge pull request #951 from IanCa/develop
Browse files Browse the repository at this point in the history
Replace and/or with &&/|| for searching
  • Loading branch information
VisLab authored Jun 12, 2024
2 parents 4a6af0c + 673770e commit ee75b02
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 57 deletions.
16 changes: 8 additions & 8 deletions hed/models/query_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,27 @@ def __init__(self, expression_string):
'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 && Action' - Find any strings with Event and Action, including descendant tags.
'Event or Action' - Same as above, but it has either.
'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 and Action]' - Find a group that contains both Event and Action(at any level).
'[Event && 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 && 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 && 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.
'{Event && 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,
{(Onset || Offset), (Def || {Def-expand}): ???} - A group with an onset tag,
a def tag or def-expand group, and an optional wildcard group
Parameters:
Expand Down Expand Up @@ -96,7 +96,7 @@ def _tokenize(expression_string):
"""Tokenize the expression string into a list"""
grouping_re = r"\[\[|\[|\]\]|\]|}|{|:"
paren_re = r"\)|\(|~"
word_re = r"\?+|\band\b|\bor\b|,|[\"_\-a-zA-Z0-9/.^#\*@]+"
word_re = r"\?+|\&\&|\|\||,|[\"_\-a-zA-Z0-9/.^#\*@]+"
re_string = fr"({grouping_re}|{paren_re}|{word_re})"
token_re = re.compile(re_string)

Expand Down
4 changes: 2 additions & 2 deletions hed/models/query_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ class Token:
def __init__(self, text):
tokens = {
",": Token.And,
"and": Token.And,
"or": Token.Or,
"&&": Token.And,
"||": Token.Or,
"[": Token.DescendantGroup,
"]": Token.DescendantGroupEnd,
"(": Token.LogicalGroup,
Expand Down
Loading

0 comments on commit ee75b02

Please sign in to comment.