ufal / lindat-kontext

An alternative web front-end for the Manatee corpus search engine
GNU General Public License v2.0
5 stars 1 forks source link

highlighting multiple nodes with common characteristics, e.g. a discontinuous multi-word expression #167

Open Ansa211 opened 6 years ago

Ansa211 commented 6 years ago

This issue is to discuss the ways in which we could highlight all tokens of a multi-word expression (or some other possibly discontinuous group of words). Normally, only the tokens that match the user query are highlighted, and they form a single continuous string of tokens (except in some cases with the meet operator, see #162 for more details).

Alexandr Rosen has suggested that we could enclose the tokens that we want to highlight in a dedicated structural tag and set the attribute DISPLAYCLASS for that tag; the desired highlighting then needs to be set up in the cascading stylesheet view.css. From the documentation:

DISPLAYCLASS a class of included text; can be used to change style of text in a structure, but to do that also requires adding the given class in the cascading style sheet view.css on the server, for example

STRUCTURE g {
    DISPLAYCLASS "bold"
}

could be used to display heading in bold. Default classes available: concred (red text), concgreen (green text).

What I do not know: Would it be possible to trigger the highlighting not only by the position of the token in a given class (which does not depend on the actual search performed by the user) but also by its presence in the search output? For example, the most obvious application would be: user searches for a token with MWE annotation. All other tokens belonging to the same mwe (as identified by an id set on the relevant structural tags around the MWE) are also highlighted; but tokens belonging to other MWEs in the context are not highlighted. Could we do this with a mix of complex css and possibly a bit of javascript? And if so, how should we set it up so that the chosen solution is NOT corpus specific?

Originally, the idea comes from Vojtěch Kovář from Lexical Computing. In an e-mail to Alexandr Rosen, he explains how to use this feature for hiding the whole content of selected structural elements:

Bonito umožňuje nastavit, jak se zobrazí daná značka v konkordanci (nastavení DISPLAYBEGIN, DISPLAYEND) a také přiřadit nějakou CSS třídu tokenům mezi těmi značkami (nastavení DISPLAYCLASS). Když dáte "DISPLAYCLASS concred", zobrazí se tokeny červeně, když dáte "DISPLAYCLASS concgreen", zobrazí se zeleně. Žádné jiné třídy teď momentálně nebudou mít žádný efekt. Ale pokud dáte do souboru view.css (nebo do jiného CSSka, které se používá u zobrazení konkordance) např, takovouto definici stylu:

i.nodisplay {
       display: none;
}

a pak přidáte strukturu např. "dont_display_errors", které nastavíte DISPLAYTAG 0 a DISPLAYCLASS "nodisplay", pak zapnutím zobrazení takové struktury zmizí tokeny uzavřené v té struktuře.