[CWB] Text-level restricted query error

Stephanie Evert stefanML at collocations.de
Tue Sep 2 21:22:06 CEST 2025


> I am encountering an error when I run the query `[lemma="run" & text_author="Muir, John, 1838-1914"]` on our CQPweb.

I assume that text_author is an s-attribute. In this case, you need a different syntax to access its annotation

	[lemma="run" & _.text_author="Muir, John, 1838-1914"]

The "this" label _ refers to the current token and allows you to access the values of s-attributes, which are only exposed through label references.  I often find it more readable to specify metadata filters as a global constraint, e.g.

	[lemma="run"] :: match.text_author="Muir, John, 1838-1914"

> Does anyone know why this error might be occurring?

The error message is indeed a bit cryptic. The full explanation is that bare references to s-attributes are allowed, but always return an integer code that is 0 outside a region of the specified type, and nonzero inside.  This allows you to find tokens e.g. inside a <head> element with

	[lemma="run" & head] 

or even the lemma "run" at the start of a sentence:

	[lemma="run" & lbound(head)] 

where the builtin lbound() function tests appropriate bits of the integer code.  Another use is to find any tokens in the corpus that are not wrapped in an <s> element (assuming this should not happen).

	[!s]

In your query, text_author returns such an integer code, which cannot be compared with a string value.

Best,
Stephanie [educating the CWB community, one query at a time]


More information about the CWB mailing list