-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
80 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { convertHeadwordsToSC } from './convertHeadwordsToSC.js'; | ||
import { convertGlossToSC } from './convertGlossToSC.js'; | ||
|
||
/** | ||
* Converts a dictionary entry to a detailed definition. | ||
* @param {DictionaryEntry} entry | ||
* @returns {import('yomichan-dict-builder/dist/types/yomitan/termbank').DetailedDefinition} | ||
*/ | ||
function convertEntryToDetailedDefinition(entry) { | ||
/** | ||
* @type {import('yomichan-dict-builder/dist/types/yomitan/termbank').DetailedDefinition} | ||
*/ | ||
const detailedDefinition = { | ||
type: 'structured-content', | ||
content: [ | ||
// Headword | ||
convertHeadwordsToSC(entry.headwords), | ||
{ | ||
tag: 'div', | ||
data: { | ||
wordshk: 'definition', | ||
}, | ||
lang: 'yue', | ||
content: entry.glosses.map((gloss) => { | ||
return convertGlossToSC(gloss); | ||
}), | ||
}, | ||
], | ||
}; | ||
return detailedDefinition; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,18 @@ | ||
import { TermEntry } from 'yomichan-dict-builder'; | ||
import { convertReadingToRubySC } from './parseTextToSC'; | ||
|
||
/** | ||
* | ||
* @param {DictionaryEntry} entry | ||
* @returns {import('yomichan-dict-builder/dist/types/yomitan/termbank').TermInformation[]} | ||
*/ | ||
function convertEntryToYomitanTerm(entry) { | ||
/** | ||
* @type {import('yomichan-dict-builder/dist/types/yomitan/termbank').TermInformation[]} | ||
*/ | ||
const terms = []; | ||
return terms; | ||
} | ||
function convertEntryToYomitanTerms(entry) { | ||
|
||
/** | ||
* Converts headword(s) to structured content. | ||
* @param {TextReadingPair[]} headwords | ||
*/ | ||
function convertHeadwordsToSC(headwords) { | ||
const headwordsSCList = headwords.map(headwordToSC); | ||
const separator = '・'; | ||
/** | ||
* @type {import('yomichan-dict-builder/dist/types/yomitan/termbank').StructuredContent[]} | ||
*/ | ||
const headwordsSCListWithSeparator = []; | ||
for (let i = 0; i < headwordsSCList.length; i++) { | ||
headwordsSCListWithSeparator.push(headwordsSCList[i]); | ||
if (i !== headwordsSCList.length - 1) { | ||
headwordsSCListWithSeparator.push(separator); | ||
} | ||
} | ||
|
||
// Create terms for each headword | ||
/** | ||
* @type {import('yomichan-dict-builder/dist/types/yomitan/termbank').StructuredContent} | ||
* @type {import('yomichan-dict-builder/dist/types/yomitan/termbank').TermInformation[]} | ||
*/ | ||
const sc = { | ||
tag: 'div', | ||
data: { | ||
wordshk: 'headword', | ||
}, | ||
lang: 'yue', | ||
content: ['【', ...headwordsSCListWithSeparator, '】'], | ||
}; | ||
return sc; | ||
const yomitanTerms = []; | ||
return yomitanTerms; | ||
} | ||
|
||
/** | ||
* Converts a headword to structured content. | ||
* @param {TextReadingPair} headword | ||
* @returns {import('yomichan-dict-builder/dist/types/yomitan/termbank').StructuredContent} | ||
*/ | ||
function headwordToSC(headword) { | ||
return convertReadingToRubySC(headword); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { convertReadingToRubySC } from './parseTextToSC.js'; | ||
|
||
/** | ||
* Converts headword(s) to structured content. | ||
* @param {TextReadingPair[]} headwords | ||
*/ | ||
function convertHeadwordsToSC(headwords) { | ||
const headwordsSCList = headwords.map(headwordToSC); | ||
const separator = '・'; | ||
/** | ||
* @type {import('yomichan-dict-builder/dist/types/yomitan/termbank').StructuredContent[]} | ||
*/ | ||
const headwordsSCListWithSeparator = []; | ||
for (let i = 0; i < headwordsSCList.length; i++) { | ||
headwordsSCListWithSeparator.push(headwordsSCList[i]); | ||
if (i !== headwordsSCList.length - 1) { | ||
headwordsSCListWithSeparator.push(separator); | ||
} | ||
} | ||
/** | ||
* @type {import('yomichan-dict-builder/dist/types/yomitan/termbank').StructuredContent} | ||
*/ | ||
const sc = { | ||
tag: 'div', | ||
data: { | ||
wordshk: 'headword', | ||
}, | ||
lang: 'yue', | ||
content: ['【', ...headwordsSCListWithSeparator, '】'], | ||
}; | ||
return sc; | ||
} | ||
|
||
/** | ||
* Converts a headword to structured content. | ||
* @param {TextReadingPair} headword | ||
* @returns {import('yomichan-dict-builder/dist/types/yomitan/termbank').StructuredContent} | ||
*/ | ||
function headwordToSC(headword) { | ||
return convertReadingToRubySC(headword); | ||
} | ||
|
||
export { convertHeadwordsToSC }; |