Plug in API Token Detail - czcorpus/kontext GitHub Wiki
Plug-ins / [token_detail]
interface: plugins.abstract.token_detail.AbstractTokenDetail
type: optional
Token detail plug-in is used for attaching (an external) information to any token in a concordance. Typically, this can be used to attach dictionaries, encyclopediae to individual tokens, named entities etc.
The plug-in is composed of three main general components:
- backend represents an adapter communicating with an (external) service
- client frontend visually interprets the data provided by the backend,
- server frontend exports backend data to be readable by the client frontend.
In general it is expected to be possible to mix these (especially backend vs. frontend) in different ways - e.g. RawHtmlFrontend is probably usable along with any backend producing raw HTML output.
Please note that in case of this plug-in the key to customization lies in frontends and backends. It means that in case you need a special functionality, it will be probably enough to extend this plug-in by an empty class and add your frontend or backend (depending on what needs to be customized).
<kontext>
...
<plugins>
...
<corparch>
<module>default_corparch</module>
<js_module>ucnkCorparch</js_module>
<file>/path/to/kontext/conf/corplist.xml</file>
</corparch>
<token_detail>
<module>default_token_detail</module>
<js_module>defaultTokenDetail</js_module>
<backends>/path/to/kontext/conf/token-detail-providers.json</backends>
</token_detail>
</plugins>
</kontext>
[
{
"ident": "wiktionary_for_ic_9_en",
"heading": {
"en_US": "Wiktionary",
"cs_CZ": "Wiktionary"
},
"backend": "plugins.default_token_detail.backends.HTTPBackend",
"frontend": "plugins.default_token_detail.frontends.RawHtmlFrontend",
"conf": {
"server": "en.wiktionary.org",
"path": "/w/index.php?title={lemma}&action=render",
"ssl": true,
"port": 443
}
},
{
"ident": "other_provider",
"...": "..... etc ..."
}
]
In a corpora configuration file (corplist.xml), a corpus we want to be used along with this service must define a token detail provider:
<kontext>
<corplist>
<corpus ident="intercorp_v9_en">
<token_detail>
<provider>wiktionary_for_ic_9_en</provider>
<provider>other_provider</provider>
</token_detail>
</corpus>
...
</corplist>
</kontext>