diff --git a/docs/source/HedSearchGuide.md b/docs/source/HedSearchGuide.md index ff394cf..d040a3a 100644 --- a/docs/source/HedSearchGuide.md +++ b/docs/source/HedSearchGuide.md @@ -138,13 +138,13 @@ comma-separated tags and parenthesized groups. The expressions for `A` and `B` are each evaluated and then combined using standard logic. -| Query form | Example query | Matches | Does not match | -|--------------------------------------------------------------------------------------------------|-----------------------------|----------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------| -| **`A`, `B`**
Match if both `A` and `B`
are matched. | *Event*, *Sensory-event* | *Event*, *Sensory-event*
*Sensory-event*, *Event*
(*Event*, *Sensory-event*) | *Event* | -| **`A` and `B`**
Match if both `A` and `B`
are matched.
Same as the comma notation. | *Event* and *Sensory-event* | *Event*, *Sensory-event*
*Sensory-event*, *Event*
(*Event*, *Sensory-event*) | | *Event* | -| **`A` or `B`**
Match if either `A` or `B`. | *Event* or *Sensory-event* | *Event*, *Sensory-event*
*Sensory-event*, *Event*
(*Event*, *Sensory-event*)
*Event*
*Sensory-event* | *Agent-trait* | -| **~`A`**
Match groups that do
not contain `A`
`A` can be an arbitrary expression. | { *Event*, ~*Action* } | (*Event*)
(*Event*, *Animal-agent*)
(*Sensory-event*, (*Action*)) | *Event*
*Event*, *Action*
(*Event*, *Action*)
| -| **@`A`**
Match a line that
does not contain `A`. | @*Event* | *Action*
*Agent-trait*
*Action, Agent-Trait*
(*Action*, *Agent*) | *Event*
(*Action*, *Event*)
(*Action*, *Sensory-event*)
(*Agent*, (*Sensory-event*, *Blue*)) | +| Query form | Example query | Matches | Does not match | +|-------------------------------------------------------------------------------------------------|-----------------------------|----------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------| +| **`A`, `B`**
Match if both `A` and `B`
are matched. | *Event*, *Sensory-event* | *Event*, *Sensory-event*
*Sensory-event*, *Event*
(*Event*, *Sensory-event*) | *Event* | +| **`A` && `B`**
Match if both `A` and `B`
are matched.
Same as the comma notation. | *Event* and *Sensory-event* | *Event*, *Sensory-event*
*Sensory-event*, *Event*
(*Event*, *Sensory-event*) | | *Event* | +| **`A` \|\| `B`**
Match if either `A` or `B`. | *Event* or *Sensory-event* | *Event*, *Sensory-event*
*Sensory-event*, *Event*
(*Event*, *Sensory-event*)
*Event*
*Sensory-event* | *Agent-trait* | +| **~`A`**
Match groups that do
not contain `A`
`A` can be an arbitrary expression. | { *Event*, ~*Action* } | (*Event*)
(*Event*, *Animal-agent*)
(*Sensory-event*, (*Action*)) | *Event*
*Event*, *Action*
(*Event*, *Action*)
| +| **@`A`**
Match a line that
does not contain `A`. | @*Event* | *Action*
*Agent-trait*
*Action, Agent-Trait*
(*Action*, *Agent*) | *Event*
(*Action*, *Event*)
(*Action*, *Sensory-event*)
(*Agent*, (*Sensory-event*, *Blue*)) | ### Group queries @@ -177,7 +177,7 @@ comma-separated tags and parenthesized groups. These operations can be arbitrarily nested and combined, as for example in the query: -> *[`A` or {`B` and `C`} ]* +> *[`A` || {`B` && `C`} ]* In this query Ordering on either the search terms or strings to be searched doesn't matter, @@ -188,15 +188,15 @@ You can replace any term with a wildcard: | Query form | Example query | Matches | Does not match | |--------------------------------------|-----------------|-----------------------|-------------------------------| -| **`?`**
Matches any tag or group | {`A` and `?`} | *(A, B}
(A, (B))* | *(A)
(B, C)* | -| **`??`**
Matches any tag | {`A` and `??`} | *(A, B}* | *(A)
(B, C)
(A, (B))* | -| **`???`**
Matches any group | {`A` and `???`} | *(A, (B))* | *(A)
(B, C)
(A, B)* | +| **`?`**
Matches any tag or group | {`A` && `?`} | *(A, B}
(A, (B))* | *(A)
(B, C)* | +| **`??`**
Matches any tag | {`A` && `??`} | *(A, B}* | *(A)
(B, C)
(A, (B))* | +| **`???`**
Matches any group | {`A` && `???`} | *(A, (B))* | *(A)
(B, C)
(A, B)* | **Notes**: You cannot use negation inside exact matching groups `{X:}` or `{X:Y}` notation.
You cannot use negation in combination with wildcards ( `?`, `??`, or `???` )
-In exact group matching, `or` matches one or the other, not both: -`{A or B:}` matches `(A)` or `(B)`, but not `(A, B)` +In exact group matching, `||` matches one or the other, not both: +`{A || B:}` matches `(A)` or `(B)`, but not `(A, B)` ## Where can HED search be used? @@ -217,3 +217,31 @@ Work is underway to integrate HED-based search into other tools including [**MNE-python**](https://mne.tools/stable/index.html) as well into the analysis platforms [**NEMAR**](https://nemar.org/) and [**EEGNET**](http://eegnet.org/) + +### Basic search [In development - no web API yet] + +A simpler text search also exists, this is notably faster and still has the key features of searching parent tags and grouping. + +The simplest type of query is to search for the presence or absence of a single tag. These can be combined in a few ways, but all searches are trying to match all terms. + +| Query type | Example query | Matches | Does not match | +|-------------------------------------------------------------------------------------------------------------------|----------------|----------------------------------------------------------------------|-----------------------------------------------| +| **Anywhere-term**
Prefix the term with `@` to match anywhere within a line. | *@A* | Lines with the term A anywhere in them | Lines without the term A anywhere within them | +| **Negation-term**
Prefix the term with `~` to match lines that do NOT contain the term. | *~A* | Lines that do not contain the term A | Lines containing the term A | +| **Nested-term**
Elements within parentheses must appear at the same level of nesting. | *"(A), (B)"* | (A), (B, C)
((A), (B, C)) | (A, B)
(A, C, B)
(A, (C, B)) | +| **Wildcard-term**
Use `*` to match any remaining word (anything but a comma or parenthesis). | *LongFormTag** | LongFormTag
Parent/LongFormTagExample
Parent/LongFormTagSample | Parent/OtherWordLongFormTag | + +### Notes + +- Specific words only care about their level relative to other specific words, not overall. +- If there are no grouping or anywhere words in the search, it assumes all terms are anywhere words. +- The format of the series should match the format of the search string, whether it's in short or long form. +- To enable support for matching parent tags, ensure that both the series and search string are in long form. + +#### Example search queries + +| Query type | Example query | Matches | Does not match | +|---------------------------------------------|-----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------| +| **Tag sharing a group with another tag** | `(Face, Item-interval/1)`
Face in a group with the exact tag Item-interval/1 | (Face, Item-interval/1)
Face, Item-interval/1 | (Face, Item-interval/12)
Face, Item-interval/1A
(Face, Item-interval)
(Item-interval/1) | +| **Tag sharing a group with a wildcard tag** | `(Face, Item-interval/1*)`
Face in a group with a tag starting with Item-interval/1 | (Face, Item-interval/1)
Face, Item-interval/12
(Face, Item-interval/1A) | (Face, Item-interval)
(Item-interval/1) | +| **Tag sharing a group with a subgroup** | `(Face, (Item-interval/1))`
Face in a group, with subgroup containing Item-interval/1 | (Face, (Item-interval/1))
Face, (Item-interval/1)
(Item-interval/1), Event, Face | (Face, Item-interval/1)
(Item-interval/1) |