{# some helper functions for rendering a korp link in a variety of places, # generally: in the analyses column. #} {% macro mix_mwe(expr) -%} {% set delim = current_pair_settings.korp_options.lemma_search_delimiter %} {% if ' ' in expr -%} {{ expr|split_string|join(lemma_search_delimiter) }} {%- else -%} {{ expr }} {%- endif -%} {%- endmacro %} {% macro link_lemma(lemma) -%} {% if not orig_from %} {% set orig_from = _from %} {% endif %} {%- set korp_opts = current_pair_settings.korp_options %} {% if korp_opts.lemma_search_path and lemma -%} {% set l_host = current_pair_settings.korp_search_host %} {% set query_path = korp_opts.lemma_search_query %} {% if korp_opts.is_korp_default_lang %} {% set search_path = korp_opts.lemma_search_path_default_lang %} {% else %} {% set search_path = korp_opts.lemma_search_path.replace('TARGET_LANG_ISO', orig_from) %} {% endif %} {% if korp_opts.korp_parallel %} {% set search_path = korp_opts.bilingual_wordform_search_path .replace('TARGET_LANG_ISO', orig_from) %} {% set query_path = korp_opts.bilingual_wordform_search_query .replace('word', 'lemma') .replace('USER_INPUT', 'INPUT_LEMMA') %} {% endif %} {# Have to only encode half of this, because korp doesn't accept quotes in the query, so we need to urlencode the query, but not the rest of the path #} {# TODO: bilingual #} {% set query = search_path.replace( 'SEARCH_QUERY', query_path.replace( 'INPUT_LEMMA', lemma )|urlencode_quote(safe="#&/")) %} {% set s_href = l_host + query %} {% trans %}Texts{% endtrans %} → {%- endif %} {%- endmacro %} {# TODO: necessary? current_pair_settings.korp_options.lemma_search_path.replace('TARGET_LANG_ISO', orig_from) #} {% macro wordform_search_url() -%} {%- if current_pair_settings.korp_options.is_korp_default_lang %} {%- set s_path = current_pair_settings.korp_search_host + current_pair_settings.korp_options.wordform_search_path_default_lang -%} {% else %} {%- set s_path = current_pair_settings.korp_search_host + current_pair_settings.korp_options.wordform_search_path -%} {% endif -%} {{ s_path.replace('//', '/') }} {%- endmacro %} {# vim: set ts=4 sw=4 tw=72 syntax=jinja : #}