Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lacombe #1154

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Lacombe #1154

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions frontend/js/orthography.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const AVAILABLE_ORTHOGRAPHIES = new Set([
"Latn",
"Latn-x-macron",
"CMRO",
"Standardized",
"Original",
]);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
{% if show_ic != "no" %}
{{ lemma.inflectional_category }}
{% endif %}
{% if lemma.show_emoji %}
<span class="wordclass" data-cy="word-class">
<span class="wordclass__emoji">{{ emoji }} &nbsp;</span>
</span>
{% endif %}
{% if display_options.mode == 'linguistic' %}
{% if lemma.show_emoji %}
<span class="wordclass" data-cy="word-class">
<span class="wordclass__emoji">{{ emoji }} &nbsp;</span>
</span>
{% endif %}
{% if lemma.inflectional_category_linguistic %}
<span class="wordclass__inflectional-class wordclass--described" data-has-tooltip tabindex="0"
aria-describedby="tooltip:{{ id }}"> {{ lemma.inflectional_category_linguistic }} ({{ lemma.inflectional_category }})</span>
Expand All @@ -58,11 +58,6 @@
{% endif %}

{% if display_options.mode == 'english' %}
{% if lemma.show_emoji %}
<span class="wordclass" data-cy="word-class">
<span class="wordclass__emoji">{{ emoji }} &nbsp;</span>
</span>
{% endif %}
{% if lemma.inflectional_category_linguistic %}
<span class="wordclass__inflectional-class wordclass--described" data-has-tooltip tabindex="0"
aria-describedby="tooltip:{{ id }}"> {% relabel_plain_english lemma.inflectional_category %} </span>
Expand All @@ -77,11 +72,6 @@
{% endif %}

{% if display_options.mode == 'source_language' %}
{% if lemma.show_emoji %}
<span class="wordclass" data-cy="word-class">
<span class="wordclass__emoji">{{ emoji }} &nbsp;</span>
</span>
{% endif %}
{% if lemma.inflectional_category_linguistic %}
<span class="wordclass__inflectional-class wordclass--described" data-has-tooltip tabindex="0"
aria-describedby="tooltip:{{ id }}"> {% relabel_source lemma.inflectional_category %} </span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
{# These are the definitions for the inflection (non-lemma), could be empty #}
<ol class="meanings meanings--search-result">
{% for def in result.definitions %}
<li class="meanings__meaning" data-cy="lemma-meaning">{{ def.text }}
<li class="meanings__meaning" data-cy="lemma-meaning">{% convert def.text %}
{% include "CreeDictionary/components/citations.html" with dictionary_sources=def.source_ids %}
</li>
{% endfor %}
Expand Down
23 changes: 23 additions & 0 deletions src/CreeDictionary/morphodict/templatetags/morphodict_orth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.conf import settings
from django.utils.html import format_html

from morphodict.lexicon.models import Definition
from ..orthography import ORTHOGRAPHY

register = template.Library()
Expand Down Expand Up @@ -74,3 +75,25 @@ def current_orthography_name(context):
# Determine the currently requested orthography:
request_orth = ORTHOGRAPHY.from_request(context.request)
return ORTHOGRAPHY.name_of(request_orth)


@register.simple_tag(name="convert", takes_context=True)
def convert_to_standardized(context, definition: str):
if settings.MORPHODICT_DICTIONARY_NAME == "Lacombe":
orth = context.request.COOKIES.get("orth")
if orth == "Original":
return definition
d = Definition.objects.filter(text=definition).first()
if not d:
return definition
wf = d.wordform
if not wf:
return definition

if wf.linguist_info:
if "standardized" in wf.linguist_info:
return wf.linguist_info["standardized"]["senses"][0]["definition"]
else:
return definition

return definition
Empty file removed src/crkLacombeeng/app/__init__.py
Empty file.
5 changes: 3 additions & 2 deletions src/crkLacombeeng/site/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@
MORPHODICT_PREVIEW_WARNING = False

MORPHODICT_ORTHOGRAPHY = {
"default": "Latn",
"default": "Original",
"available": {
"Latn": {"name": "Latin"},
"Original": {"name": "Original", "converter": "crkLacombeeng.app.orthography.to_original"},
"Standardized": {"name": "Standardized", "converter": "crkLacombeeng.app.orthography.to_standardized"}
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def run(self):
slug=entry["slug"],
rw_domains=rw_domains,
rw_indices=rw_indices,
wn_synsets=wn_synsets,
wn_synsets_string=wn_synsets,
is_lemma=True,
linguist_info=entry.get("linguistInfo", {}),
import_hash=freshness_check.importjson_hash_for_slug(entry["slug"]),
Expand Down
2 changes: 1 addition & 1 deletion src/morphodict/lexicon/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class Wordform(models.Model):
"""
)

wn_synsets = models.CharField(
wn_synsets_string = models.CharField(
max_length=2048,
blank=True,
null=True,
Expand Down