{% set random_abbr = '' %} {% set _dummy = none %} {% set abbr_exp_dict = namespace(value = {}) %} {% set abbr_string=namespace(value='') %} {% set exp_string=namespace(value='')%} {% for label_idx in range(labels|length) %} {% if labels[label_idx] == 0 %}{# Long Beginning #} {% set exp_string.value = tokens[label_idx] %}{# Create new long string #} {% elif labels[label_idx] == 1 %}{# Short Beginning #} {% if abbr_string.value!='' and abbr_string.value not in abbr_exp_dict.value.keys()%}{# Some string already present #} {% set _dummy = abbr_exp_dict.value.update({abbr_string.value:''}) %}{# Discard this string as a new short string is coming #} {% endif %} {% set abbr_string.value = tokens[label_idx] %}{# Create new short string #} {% elif labels[label_idx] == 2 %}{# Long Intermediate #} {% set exp_string.value = exp_string.value+' '+tokens[label_idx] %}{# Update existing string #} {% elif labels[label_idx] == 3 %}{# Short Intermediate #} {% set abbr_string.value = abbr_string.value+tokens[label_idx] %}{# Update existing string #} {% else %}{# Other #} {# Both non-empty, and first characters match #} {% if abbr_string.value!='' and exp_string.value!='' and exp_string.value.split()[0][0]|lower in abbr_string.value|lower and exp_string.value.split()[-1][0]|lower in abbr_string.value|lower%} {# Update both the dictionaries #} {% set _dummy = abbr_exp_dict.value.update({abbr_string.value:exp_string.value}) %} {# Empty both the strings #} {% set abbr_string.value= '' %} {% set exp_string.value= '' %} {% endif %} {% endif %} {% endfor %} {# Both non-empty, and first characters match #} {% if abbr_string.value!='' and exp_string.value!='' %} {% if exp_string.value.split()[0][0]|lower in abbr_string.value|lower and exp_string.value.split()[-1][0]|lower in abbr_string.value|lower %} {# Update both the dictionaries #} {% set _dummy = abbr_exp_dict.value.update({abbr_string.value:exp_string.value}) %} {% elif abbr_exp_dict.value.items()|length==0 %} {% set _dummy = abbr_exp_dict.value.update({abbr_string.value:exp_string.value}) %} {% endif %} {% else %} {% if abbr_string.value!=''%} {% if abbr_string.value not in abbr_exp_dict.value.keys() %} {% set _dummy = abbr_exp_dict.value.update({abbr_string.value:''}) %} {% endif %} {% endif %} {% endif %} {% if abbr_exp_dict.value %} {% set random_abbr = abbr_exp_dict.value.keys()|list|choice %} Given the tokens below, find the expansion (acronym meaning) of "{{random_abbr}}". Return {{"\\"Unclear\\""}} if the expansion can't be found. Tokens: {{tokens|join(' ')}} Expansion:
Pensando...
