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

Handling multiple entries for same headword DSL -> Yomichan #574

Closed
chickendude opened this issue Jul 22, 2024 · 9 comments
Closed

Handling multiple entries for same headword DSL -> Yomichan #574

chickendude opened this issue Jul 22, 2024 · 9 comments

Comments

@chickendude
Copy link

I have a DSL dictionary that has multiple entries for a single headword:

test
    [i]type[/i] (example)
    definition
test
    [i]another type[/i] (example)
    another [b]definition[/b]

.. but when converting to a Yomichan dictionary, a suffix (2) is added to the second entry:

["test", "", "", "",    0, ["type (example)\ndefinition"], 2785, ""],
["test (2)", "", "", "", 0, ["    another type (example)\nanother definition"], 2786, ""]

When using the dictionary in Yomitan, the second entry never shows up unless i specifically search for mos (2) in the dictionary search screen.

In GoldenDict, the DSL dictionary returns both results:
image

If Yomichan/Yomitan is unable to have duplicate headwords, would it not make more sense to merge them into one entry? Otherwise, the second result will never actually show up when using the dictionary.

@ilius
Copy link
Owner

ilius commented Jul 29, 2024

I don't know what others do, but the json format can not have duplicate keys.

We can merge entries with same headword by just adding a horizontal line (like ---------- for plaintext, and <hr> for html entries) between them.
Does that solve the problem?

@chickendude
Copy link
Author

I think that would solve the problem perfectly, yeah.

@ilius
Copy link
Owner

ilius commented Aug 1, 2024

I pushed to branch yomichan-merge.
Please test.

@chickendude
Copy link
Author

I tested this and they are combined, but something seems to have changed in the formatting, it looks like there are HTML tags but they're sanitized, whereas before all formatting had been stripped out:
image

&lt;i&gt;headword&lt;/i&gt;&lt;br/&gt;&amp;nbsp;<br>&lt;hr&gt;<br>&lt;i&gt;headword2&lt;/i&gt;&lt;br/&gt;&amp;nbsp;

@ilius
Copy link
Owner

ilius commented Aug 1, 2024

Does it not support rich text at all?

@chickendude
Copy link
Author

chickendude commented Aug 1, 2024

It looks like it is possible, but the format is a bit unintuitive. I took a look at the Jitendex Yomichan dictionary, and it looks like the tags are defined separately in the json, using "tag", "style" and "content" keys. Previously it would just convert it to plain text (just missing the second definition). Having html support would be great, but i think that's a separate issue. I'd be happy for now to just have the plain text as before but with both headwords combined into one.

This is an example entry from the Jitendex dictionary with formatting:

[
        "CDプレーヤー",
        "シーディープレーヤー",
        "★ priority form",
        "",
        200,
        [
            {
                "type": "structured-content",
                "content": [
                    {
                        "tag": "div",
                        "content": [
                            {
                                "tag": "span",
                                "title": "noun (common) (futsuumeishi)",
                                "style": {
                                    "fontSize": "0.8em",
                                    "fontWeight": "bold",
                                    "padding": "0.2em 0.3em",
                                    "wordBreak": "keep-all",
                                    "borderRadius": "0.3em",
                                    "verticalAlign": "text-bottom",
                                    "backgroundColor": "#565656",
                                    "color": "white",
                                    "cursor": "help",
                                    "marginRight": "0.25em"
                                },
                                "data": {
                                    "code": "n"
                                },
                                "content": "noun"
                            },
                            {
                                "tag": "div",
                                "content": [
                                    {
                                        "tag": "ul",
                                        "style": {
                                            "listStyleType": "none",
                                            "paddingLeft": "0"
                                        },
                                        "data": {
                                            "content": "glossary"
                                        },
                                        "content": {
                                            "tag": "li",
                                            "content": "CD player"
                                        }
                                    },
                                    {
                                        "tag": "div",
                                        "style": {
                                            "marginLeft": "0.5em"
                                        },
                                        "data": {
                                            "content": "extra-info"
                                        },
                                        "content": {
                                            "tag": "div",
                                            "content": {
                                                "tag": "div",
                                                "style": {
                                                    "borderStyle": "none none none solid",
                                                    "padding": "0.5rem",
                                                    "borderRadius": "0.4rem",
                                                    "borderWidth": "calc(3em / var(--font-size-no-units))",
                                                    "marginTop": "0.5rem",
                                                    "marginBottom": "0.5rem",
                                                    "borderColor": "var(--text-color)",
                                                    "backgroundColor": "color-mix(in srgb, var(--text-color) 5%, transparent)"
                                                },
                                                "data": {
                                                    "content": "example-sentence",
                                                    "sentence-key": "CDプレイヤー",
                                                    "source": "162365",
                                                    "source-type": "tat"
                                                },
                                                "content": [
                                                    {
                                                        "tag": "div",
                                                        "style": {
                                                            "fontSize": "1.3em"
                                                        },
                                                        "data": {
                                                            "content": "example-sentence-a"
                                                        },
                                                        "content": [
                                                            {
                                                                "tag": "ruby",
                                                                "content": [
                                                                    "私",
                                                                    {
                                                                        "tag": "rt",
                                                                        "content": "わたし"
                                                                    }
                                                                ]
                                                            },
                                                            "は、この",
                                                            {
                                                                "tag": "span",
                                                                "style": {
                                                                    "textEmphasis": "dot red"
                                                                },
                                                                "data": {
                                                                    "content": "example-keyword"
                                                                },
                                                                "content": "CDプレイヤー"
                                                            },
                                                            "をただで",
                                                            {
                                                                "tag": "ruby",
                                                                "content": [
                                                                    "得",
                                                                    {
                                                                        "tag": "rt",
                                                                        "content": "え"
                                                                    }
                                                                ]
                                                            },
                                                            "ました。"
                                                        ]
                                                    },
                                                    {
                                                        "tag": "div",
                                                        "style": {
                                                            "fontSize": "0.8em"
                                                        },
                                                        "data": {
                                                            "content": "example-sentence-b"
                                                        },
                                                        "content": "I got this CD player for free."
                                                    }
                                                ]
                                            }
                                        }
                                    }
                                ]
                            }
                        ]
                    },
                    {
                        "tag": "div",
                        "style": {
                            "marginTop": "0.5rem"
                        },
                        "data": {
                            "content": "forms"
                        },
                        "content": [
                            {
                                "tag": "span",
                                "title": "spelling and reading variants",
                                "style": {
                                    "fontSize": "0.8em",
                                    "fontWeight": "bold",
                                    "padding": "0.2em 0.3em",
                                    "wordBreak": "keep-all",
                                    "borderRadius": "0.3em",
                                    "verticalAlign": "text-bottom",
                                    "backgroundColor": "#565656",
                                    "color": "white",
                                    "cursor": "help",
                                    "marginRight": "0.25em"
                                },
                                "content": "forms"
                            },
                            {
                                "tag": "div",
                                "style": {
                                    "marginTop": "0.2em"
                                },
                                "content": {
                                    "tag": "table",
                                    "content": [
                                        {
                                            "tag": "tr",
                                            "content": [
                                                {
                                                    "tag": "th",
                                                    "style": {
                                                        "fontSize": "1.2em",
                                                        "textAlign": "center",
                                                        "fontWeight": "normal"
                                                    }
                                                },
                                                {
                                                    "tag": "th",
                                                    "style": {
                                                        "fontSize": "1.2em",
                                                        "textAlign": "center",
                                                        "fontWeight": "normal"
                                                    },
                                                    "content": "CDプレーヤー"
                                                },
                                                {
                                                    "tag": "th",
                                                    "style": {
                                                        "fontSize": "1.2em",
                                                        "textAlign": "center",
                                                        "fontWeight": "normal"
                                                    },
                                                    "content": "CDプレイヤー"
                                                }
                                            ]
                                        },
                                        {
                                            "tag": "tr",
                                            "content": [
                                                {
                                                    "tag": "th",
                                                    "style": {
                                                        "fontWeight": "normal"
                                                    },
                                                    "content": "シーディープレーヤー"
                                                },
                                                {
                                                    "tag": "td",
                                                    "style": {
                                                        "textAlign": "center"
                                                    },
                                                    "content": {
                                                        "tag": "div",
                                                        "title": "high priority form",
                                                        "style": {
                                                            "cursor": "help",
                                                            "padding": "0 0.25em",
                                                            "color": "white",
                                                            "background": "radial-gradient(green 50%, white 100%)",
                                                            "clipPath": "circle()"
                                                        },
                                                        "content": "優"
                                                    }
                                                },
                                                {
                                                    "tag": "td",
                                                    "style": {
                                                        "textAlign": "center"
                                                    }
                                                }
                                            ]
                                        },
                                        {
                                            "tag": "tr",
                                            "content": [
                                                {
                                                    "tag": "th",
                                                    "style": {
                                                        "fontWeight": "normal"
                                                    },
                                                    "content": "シーディープレイヤー"
                                                },
                                                {
                                                    "tag": "td",
                                                    "style": {
                                                        "textAlign": "center"
                                                    }
                                                },
                                                {
                                                    "tag": "td",
                                                    "style": {
                                                        "textAlign": "center"
                                                    },
                                                    "content": {
                                                        "tag": "div",
                                                        "title": "valid form/reading combination",
                                                        "style": {
                                                            "cursor": "help",
                                                            "padding": "0 0.25em",
                                                            "color": "var(--background-color)",
                                                            "background": "radial-gradient(var(--text-color) 50%, white 100%)",
                                                            "clipPath": "circle()"
                                                        },
                                                        // ** There's more after this **
                                                    }
                                                }
                                            ]
                                        }
                                    ]
                                }
                            }
                        ]
                    }
                ]
            }
        ]
    ]
]

@ilius
Copy link
Owner

ilius commented Aug 1, 2024

I force-pushed to yomichan-merge branch.
Please try again.

@chickendude
Copy link
Author

That is perfect, thank you!

@ilius
Copy link
Owner

ilius commented Aug 2, 2024

I also pushed to master branch.

@ilius ilius closed this as completed Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants