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

add etymology entries to definitions #183

Closed
wants to merge 2 commits into from

Conversation

seth-js
Copy link
Contributor

@seth-js seth-js commented Dec 26, 2024

Adds hidden-by-default etymology entries to each relevant definition.

3-tidy-up.js

The keys etymology_text and breakdown_text are written to each lemmaDict entry where etymology is provided in the parsedLine.

The breakdown_text is a shortened version of the etymology_text where only the break down part is saved:

Borrowed from Old Church Slavonic въплътити (vŭplŭtiti). By surface analysis, во- (vo-) +‎ плоть (plotʹ) +‎ -и́ть (-ítʹ). becomes во- (vo-) +‎ плоть (plotʹ) +‎ -и́ть (-ítʹ). This extra key is handled later in 4-make-yomitan.js.

I should also mention that I added this during the lemma and form JSON creation part:

for (const file of readdirSync(writeFolder)) {
    if (file.includes(`${sourceIso}-${targetIso}`)) {
        unlinkSync(`${writeFolder}/${file}`);
    }
}

I noticed while testing with a small pool of words that some leftover data was still in the writeFolder from a previous run, and that data was being added to my smaller dictionary. That loop should prevent that.

4-make-yomitan.js

The function getStructuredEtym creates an extra-info element similar to how example sentences are structured. In order for me to only see breakdown_text in the etymology entry, I create multiple span elements for the element's content rather than just a text node, and I add CSS in Yomitan settings to filter out only the spans I want to see.

The content is handled like this:

Borrowed from Old Church Slavonic въплътити (vŭplŭtiti). By surface analysis, во- (vo-) +‎ плоть (plotʹ) +‎ -и́ть (-ítʹ). 
<span class="gloss-sc-span" data-sc-content="target-text">📝 </span>
<span class="gloss-sc-span" data-sc-content="normal-text">Borrowed from Old Church Slavonic въплътити (vŭplŭtiti). By surface analysis, </span>
<span class="gloss-sc-span" data-sc-content="target-text">во- (vo-) + плоть (plotʹ) + -и́ть (-ítʹ)</span>
<span class="gloss-sc-span" data-sc-content="normal-text">.</span>

If the entry has no breakdown_text, the etymology is added as a text node like usual.

data\styles.css

The CSS for etymology entries are very similar to example sentence entries. The etymology entries are hidden by default.

A user can show these entries by adding this to Yomitan's custom CSS setting:

div[data-sc-content="etymology-entry"] {
  display: block;
}

If the user wants to only see break down text like myself, they can instead add:

div[data-sc-content="etymology-entry"]:has(span[data-sc-content="target-text"]) {
  display: block;
}

span[data-sc-content="normal-text"] {
  display: none;
}

Added `etymology_text` and `breakdown_text` to lemma entries. Made it so old files are deleted before generating new lemma and form JSONs.
@seth-js seth-js closed this Jan 3, 2025
@seth-js seth-js deleted the etym-entry branch January 3, 2025 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant