diff --git a/src/morphodict/frontend/templates/morphodict/wordnet-results.html b/src/morphodict/frontend/templates/morphodict/wordnet-results.html index 2090c5e37..9f82cf278 100644 --- a/src/morphodict/frontend/templates/morphodict/wordnet-results.html +++ b/src/morphodict/frontend/templates/morphodict/wordnet-results.html @@ -1,5 +1,6 @@ {% spaceless %} {% load morphodict_extras %} +{% load relabelling %} {% if verbose_messages %}
  • Messages from search run

    @@ -12,7 +13,7 @@

    Messages from search run

    -

    {{result.wn_entry.original_str}} ({{result.wn_entry.pos}})

    +

    {{result.wn_entry.numbering}}. {{result.wn_entry.original_str}} ({% relabel_one result.wn_entry.paren_pos %})

    {{result.wn_entry.definition}}

    diff --git a/src/morphodict/resources/crk.altlabel.tsv b/src/morphodict/resources/crk.altlabel.tsv index 516ffb67f..f88e4a3da 100644 --- a/src/morphodict/resources/crk.altlabel.tsv +++ b/src/morphodict/resources/crk.altlabel.tsv @@ -557,3 +557,9 @@ A+Sg+Title A+Sg Singular, Animate One (awa word) pêyak (awa) A+Pl+Title A+Pl Plural, Animate Many (awa word) mihcêt (awa) I+Sg+Title I+Sg Singular, Inanimate One (ôma word) pêyak (ôma) I+Pl+Title I+Pl Plural, Inanimate Many (ôma word) mihcêt (ôma) + +(v) Verb Verb Action word ispayin-itwêwin https://en.wikipedia.org/wiki/Verb +(n) Noun Noun Naming word wîhowin-itwêwin https://en.wikipedia.org/wiki/Noun +(a) Adj Adjective Description word wîhtam-itwêwin https://en.wikipedia.org/wiki/Adjective +(s) AdjSat Adjective Satellite Description word wîhtam-itwêwin https://en.wikipedia.org/wiki/Adjective +(r) Adv Adverb Word that changes another word âhtawêw-itwêwin https://en.wikipedia.org/wiki/Adverb diff --git a/src/morphodict/search/runner.py b/src/morphodict/search/runner.py index 29409f405..87f52eb2a 100644 --- a/src/morphodict/search/runner.py +++ b/src/morphodict/search/runner.py @@ -145,6 +145,7 @@ def wordnet_search(query: Query) -> list[tuple[WordnetEntry, SearchResults]] | N # Wordnet search was successful _at the wordnet level_ # Now we must collect the results results = [] + synsets: dict[str, list[WordnetEntry]]= dict() for synset in wordnet_search.synsets: wn_results = SearchResults() wn_results.sort_function = lambda x: 0 - x.lemma_freq if x.lemma_freq else 0 @@ -155,6 +156,8 @@ def wordnet_search(query: Query) -> list[tuple[WordnetEntry, SearchResults]] | N wn_results.add_result(r) wn_entry = WordnetEntry(synset.name) wn_entry.original_str = " ".join(query.query_terms) + synsets.setdefault(wn_entry.pos(),[]).append(wn_entry) + wn_entry.numbering=len(synsets[wn_entry.pos()]) get_lemma_freq(wn_results) for result in wn_results.unsorted_results(): result.relevance_score = result.lemma_freq diff --git a/src/morphodict/search/types.py b/src/morphodict/search/types.py index 60530a400..00b6a8639 100644 --- a/src/morphodict/search/types.py +++ b/src/morphodict/search/types.py @@ -307,6 +307,7 @@ class WordnetEntry: synset: Synset original_str: str + numbering: Optional[int] def __init__(self, entry: str | Synset): if isinstance(entry, str): @@ -338,6 +339,9 @@ def heading(self) -> str: def pos(self) -> str: return self.synset.pos() + + def paren_pos(self) -> str: + return f"({self.synset.pos()})" def synonyms(self) -> list[str]: return [" ".join(l.name().split("_")) for l in self.synset.lemmas()]