From e161c24879c261d57ef092c19ee904e3c194581d Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Fri, 22 Dec 2023 23:26:40 +0100 Subject: [PATCH 01/19] move dictionary files to dictionary folder --- .eslintrc.json | 10 +++++----- dev/jsconfig.json | 4 ++-- ext/js/background/backend.js | 2 +- ext/js/background/offscreen.js | 2 +- ext/js/data/sandbox/anki-note-data-creator.js | 2 +- .../sandbox => dictionary}/dictionary-data-util.js | 0 ext/js/{language => dictionary}/dictionary-database.js | 0 .../dictionary-importer-media-loader.js | 0 ext/js/{language => dictionary}/dictionary-importer.js | 0 .../dictionary-worker-handler.js | 0 .../{language => dictionary}/dictionary-worker-main.js | 0 .../dictionary-worker-media-loader.js | 0 ext/js/{language => dictionary}/dictionary-worker.js | 2 +- ext/js/display/display-generator.js | 2 +- ext/js/language/translator.js | 2 +- ext/js/pages/settings/dictionary-controller.js | 2 +- ext/js/pages/settings/dictionary-import-controller.js | 2 +- ext/js/templates/sandbox/anki-template-renderer.js | 2 +- test/database.test.js | 4 ++-- test/fixtures/translator-test.js | 4 ++-- types/ext/translator.d.ts | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) rename ext/js/{language/sandbox => dictionary}/dictionary-data-util.js (100%) rename ext/js/{language => dictionary}/dictionary-database.js (100%) rename ext/js/{language => dictionary}/dictionary-importer-media-loader.js (100%) rename ext/js/{language => dictionary}/dictionary-importer.js (100%) rename ext/js/{language => dictionary}/dictionary-worker-handler.js (100%) rename ext/js/{language => dictionary}/dictionary-worker-main.js (100%) rename ext/js/{language => dictionary}/dictionary-worker-media-loader.js (100%) rename ext/js/{language => dictionary}/dictionary-worker.js (98%) diff --git a/.eslintrc.json b/.eslintrc.json index eb0eecdb57..6c8b34818f 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -713,7 +713,7 @@ "ext/js/general/regex-util.js", "ext/js/general/text-source-map.js", "ext/js/language/deinflector.js", - "ext/js/language/dictionary-database.js", + "ext/js/dictionary/dictionary-database.js", "ext/js/language/sandbox/dictionary-data-util.js", "ext/js/language/sandbox/japanese-util.js", "ext/js/language/translator.js", @@ -741,10 +741,10 @@ "ext/js/data/database.js", "ext/js/data/json-schema.js", "ext/js/general/cache-map.js", - "ext/js/language/dictionary-database.js", - "ext/js/language/dictionary-importer.js", - "ext/js/language/dictionary-worker-handler.js", - "ext/js/language/dictionary-worker-media-loader.js", + "ext/js/dictionary/dictionary-database.js", + "ext/js/dictionary/dictionary-importer.js", + "ext/js/dictionary/dictionary-worker-handler.js", + "ext/js/dictionary/dictionary-worker-media-loader.js", "ext/js/media/media-util.js" ], "env": { diff --git a/dev/jsconfig.json b/dev/jsconfig.json index d613e88d4c..a754006890 100644 --- a/dev/jsconfig.json +++ b/dev/jsconfig.json @@ -64,8 +64,8 @@ "../ext/js/general/regex-util.js", "../ext/js/general/text-source-map.js", "../ext/js/language/deinflector.js", - "../ext/js/language/dictionary-importer.js", - "../ext/js/language/dictionary-database.js", + "../ext/js/dictionary/dictionary-importer.js", + "../ext/js/dictionary/dictionary-database.js", "../ext/js/language/sandbox/dictionary-data-util.js", "../ext/js/language/sandbox/japanese-util.js", "../ext/js/language/translator.js", diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index c62685b20e..63ed023ace 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -29,9 +29,9 @@ import {AnkiUtil} from '../data/anki-util.js'; import {OptionsUtil} from '../data/options-util.js'; import {PermissionsUtil} from '../data/permissions-util.js'; import {ArrayBufferUtil} from '../data/sandbox/array-buffer-util.js'; +import {DictionaryDatabase} from '../dictionary/dictionary-database.js'; import {Environment} from '../extension/environment.js'; import {ObjectPropertyAccessor} from '../general/object-property-accessor.js'; -import {DictionaryDatabase} from '../language/dictionary-database.js'; import {JapaneseUtil} from '../language/sandbox/japanese-util.js'; import {Translator} from '../language/translator.js'; import {AudioDownloader} from '../media/audio-downloader.js'; diff --git a/ext/js/background/offscreen.js b/ext/js/background/offscreen.js index 1cab592923..962a16fad4 100644 --- a/ext/js/background/offscreen.js +++ b/ext/js/background/offscreen.js @@ -21,7 +21,7 @@ import {ClipboardReader} from '../comm/clipboard-reader.js'; import {invokeMessageHandler} from '../core.js'; import {createApiMap, getApiMapHandler} from '../core/api-map.js'; import {ArrayBufferUtil} from '../data/sandbox/array-buffer-util.js'; -import {DictionaryDatabase} from '../language/dictionary-database.js'; +import {DictionaryDatabase} from '../dictionary/dictionary-database.js'; import {JapaneseUtil} from '../language/sandbox/japanese-util.js'; import {Translator} from '../language/translator.js'; diff --git a/ext/js/data/sandbox/anki-note-data-creator.js b/ext/js/data/sandbox/anki-note-data-creator.js index dce719381b..9d93b49789 100644 --- a/ext/js/data/sandbox/anki-note-data-creator.js +++ b/ext/js/data/sandbox/anki-note-data-creator.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import {DictionaryDataUtil} from '../../language/sandbox/dictionary-data-util.js'; +import {DictionaryDataUtil} from '../../dictionary/dictionary-data-util.js'; /** * This class is used to convert the internal dictionary entry format to the diff --git a/ext/js/language/sandbox/dictionary-data-util.js b/ext/js/dictionary/dictionary-data-util.js similarity index 100% rename from ext/js/language/sandbox/dictionary-data-util.js rename to ext/js/dictionary/dictionary-data-util.js diff --git a/ext/js/language/dictionary-database.js b/ext/js/dictionary/dictionary-database.js similarity index 100% rename from ext/js/language/dictionary-database.js rename to ext/js/dictionary/dictionary-database.js diff --git a/ext/js/language/dictionary-importer-media-loader.js b/ext/js/dictionary/dictionary-importer-media-loader.js similarity index 100% rename from ext/js/language/dictionary-importer-media-loader.js rename to ext/js/dictionary/dictionary-importer-media-loader.js diff --git a/ext/js/language/dictionary-importer.js b/ext/js/dictionary/dictionary-importer.js similarity index 100% rename from ext/js/language/dictionary-importer.js rename to ext/js/dictionary/dictionary-importer.js diff --git a/ext/js/language/dictionary-worker-handler.js b/ext/js/dictionary/dictionary-worker-handler.js similarity index 100% rename from ext/js/language/dictionary-worker-handler.js rename to ext/js/dictionary/dictionary-worker-handler.js diff --git a/ext/js/language/dictionary-worker-main.js b/ext/js/dictionary/dictionary-worker-main.js similarity index 100% rename from ext/js/language/dictionary-worker-main.js rename to ext/js/dictionary/dictionary-worker-main.js diff --git a/ext/js/language/dictionary-worker-media-loader.js b/ext/js/dictionary/dictionary-worker-media-loader.js similarity index 100% rename from ext/js/language/dictionary-worker-media-loader.js rename to ext/js/dictionary/dictionary-worker-media-loader.js diff --git a/ext/js/language/dictionary-worker.js b/ext/js/dictionary/dictionary-worker.js similarity index 98% rename from ext/js/language/dictionary-worker.js rename to ext/js/dictionary/dictionary-worker.js index 3119dd7b22..669c65accc 100644 --- a/ext/js/language/dictionary-worker.js +++ b/ext/js/dictionary/dictionary-worker.js @@ -73,7 +73,7 @@ export class DictionaryWorker { */ _invoke(action, params, transfer, onProgress, formatResult) { return new Promise((resolve, reject) => { - const worker = new Worker('/js/language/dictionary-worker-main.js', {type: 'module'}); + const worker = new Worker('/js/dictionary/dictionary-worker-main.js', {type: 'module'}); /** @type {import('dictionary-worker').InvokeDetails} */ const details = { complete: false, diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 87b02f8a73..920d2c94c1 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -18,8 +18,8 @@ import {isObject} from '../core.js'; import {ExtensionError} from '../core/extension-error.js'; +import {DictionaryDataUtil} from '../dictionary/dictionary-data-util.js'; import {HtmlTemplateCollection} from '../dom/html-template-collection.js'; -import {DictionaryDataUtil} from '../language/sandbox/dictionary-data-util.js'; import {yomitan} from '../yomitan.js'; import {PronunciationGenerator} from './sandbox/pronunciation-generator.js'; import {StructuredContentGenerator} from './sandbox/structured-content-generator.js'; diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index ddbd857855..4590994039 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -31,7 +31,7 @@ export class Translator { constructor({japaneseUtil, database}) { /** @type {import('./sandbox/japanese-util.js').JapaneseUtil} */ this._japaneseUtil = japaneseUtil; - /** @type {import('./dictionary-database.js').DictionaryDatabase} */ + /** @type {import('../dictionary/dictionary-database.js').DictionaryDatabase} */ this._database = database; /** @type {?Deinflector} */ this._deinflector = null; diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js index 6e9522db01..db6a73d43f 100644 --- a/ext/js/pages/settings/dictionary-controller.js +++ b/ext/js/pages/settings/dictionary-controller.js @@ -17,8 +17,8 @@ */ import {EventListenerCollection, log} from '../../core.js'; +import {DictionaryWorker} from '../../dictionary/dictionary-worker.js'; import {querySelectorNotNull} from '../../dom/query-selector.js'; -import {DictionaryWorker} from '../../language/dictionary-worker.js'; import {yomitan} from '../../yomitan.js'; class DictionaryEntry { diff --git a/ext/js/pages/settings/dictionary-import-controller.js b/ext/js/pages/settings/dictionary-import-controller.js index 35b7c461fc..c478b26549 100644 --- a/ext/js/pages/settings/dictionary-import-controller.js +++ b/ext/js/pages/settings/dictionary-import-controller.js @@ -18,8 +18,8 @@ import {log} from '../../core.js'; import {ExtensionError} from '../../core/extension-error.js'; +import {DictionaryWorker} from '../../dictionary/dictionary-worker.js'; import {querySelectorNotNull} from '../../dom/query-selector.js'; -import {DictionaryWorker} from '../../language/dictionary-worker.js'; import {yomitan} from '../../yomitan.js'; import {DictionaryController} from './dictionary-controller.js'; diff --git a/ext/js/templates/sandbox/anki-template-renderer.js b/ext/js/templates/sandbox/anki-template-renderer.js index 515e85daa2..d69c7b476b 100644 --- a/ext/js/templates/sandbox/anki-template-renderer.js +++ b/ext/js/templates/sandbox/anki-template-renderer.js @@ -18,10 +18,10 @@ import {Handlebars} from '../../../lib/handlebars.js'; import {AnkiNoteDataCreator} from '../../data/sandbox/anki-note-data-creator.js'; +import {DictionaryDataUtil} from '../../dictionary/dictionary-data-util.js'; import {PronunciationGenerator} from '../../display/sandbox/pronunciation-generator.js'; import {StructuredContentGenerator} from '../../display/sandbox/structured-content-generator.js'; import {CssStyleApplier} from '../../dom/sandbox/css-style-applier.js'; -import {DictionaryDataUtil} from '../../language/sandbox/dictionary-data-util.js'; import {JapaneseUtil} from '../../language/sandbox/japanese-util.js'; import {AnkiTemplateRendererContentManager} from './anki-template-renderer-content-manager.js'; import {TemplateRendererMediaProvider} from './template-renderer-media-provider.js'; diff --git a/test/database.test.js b/test/database.test.js index 702de9f862..fd092b8677 100644 --- a/test/database.test.js +++ b/test/database.test.js @@ -22,8 +22,8 @@ import path from 'path'; import {beforeEach, describe, expect, test, vi} from 'vitest'; import {parseJson} from '../dev/json.js'; import {createDictionaryArchive} from '../dev/util.js'; -import {DictionaryDatabase} from '../ext/js/language/dictionary-database.js'; -import {DictionaryImporter} from '../ext/js/language/dictionary-importer.js'; +import {DictionaryDatabase} from '../ext/js/dictionary/dictionary-database.js'; +import {DictionaryImporter} from '../ext/js/dictionary/dictionary-importer.js'; import {DictionaryImporterMediaLoader} from './mocks/dictionary-importer-media-loader.js'; const dirname = path.dirname(fileURLToPath(import.meta.url)); diff --git a/test/fixtures/translator-test.js b/test/fixtures/translator-test.js index 0afbe1f0b1..83644513aa 100644 --- a/test/fixtures/translator-test.js +++ b/test/fixtures/translator-test.js @@ -24,8 +24,8 @@ import {expect, vi} from 'vitest'; import {parseJson} from '../../dev/json.js'; import {createDictionaryArchive} from '../../dev/util.js'; import {AnkiNoteDataCreator} from '../../ext/js/data/sandbox/anki-note-data-creator.js'; -import {DictionaryDatabase} from '../../ext/js/language/dictionary-database.js'; -import {DictionaryImporter} from '../../ext/js/language/dictionary-importer.js'; +import {DictionaryDatabase} from '../../ext/js/dictionary/dictionary-database.js'; +import {DictionaryImporter} from '../../ext/js/dictionary/dictionary-importer.js'; import {JapaneseUtil} from '../../ext/js/language/sandbox/japanese-util.js'; import {Translator} from '../../ext/js/language/translator.js'; import {chrome, fetch} from '../mocks/common.js'; diff --git a/types/ext/translator.d.ts b/types/ext/translator.d.ts index 39d4be81b7..f1eb6bccf4 100644 --- a/types/ext/translator.d.ts +++ b/types/ext/translator.d.ts @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -import type {DictionaryDatabase} from '../../ext/js/language/dictionary-database'; +import type {DictionaryDatabase} from '../../ext/js/dictionary/dictionary-database'; import type {JapaneseUtil} from '../../ext/js/language/sandbox/japanese-util'; import type * as Dictionary from './dictionary'; import type * as DictionaryDatabaseTypes from './dictionary-database'; From b264c9bf36d71af10019dc2a63db4b60c5846730 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sat, 23 Dec 2023 11:16:47 +0100 Subject: [PATCH 02/19] wip --- .../dictionary-term-meta-bank-v3-schema.json | 55 ++++++++++++++-- ext/js/dictionary/dictionary-data-util.js | 17 ++++- ext/js/dictionary/dictionary-database.js | 2 + ext/js/display/display-generator.js | 64 +++++++++++++------ ext/js/language/translator.js | 30 ++++++++- types/ext/dictionary-data-util.d.ts | 31 ++++++++- types/ext/dictionary-data.d.ts | 8 +++ types/ext/dictionary-database.d.ts | 20 +++++- types/ext/dictionary.d.ts | 15 +++++ 9 files changed, 208 insertions(+), 34 deletions(-) diff --git a/ext/data/schemas/dictionary-term-meta-bank-v3-schema.json b/ext/data/schemas/dictionary-term-meta-bank-v3-schema.json index 995c456aff..1a8ac3b840 100644 --- a/ext/data/schemas/dictionary-term-meta-bank-v3-schema.json +++ b/ext/data/schemas/dictionary-term-meta-bank-v3-schema.json @@ -31,7 +31,6 @@ "type": "array", "description": "Metadata about a single term.", "minItems": 3, - "maxItems": 3, "additionalItems": false, "items": [ { @@ -40,8 +39,8 @@ }, { "type": "string", - "enum": ["freq", "pitch"], - "description": "Type of data. \"freq\" corresponds to frequency information; \"pitch\" corresponds to pitch information." + "enum": ["freq", "pitch", "ipa"], + "description": "Type of data. \"freq\" corresponds to frequency information; \"pitch\" corresponds to pitch information. \"ipa\" corresponds to IPA transcription." }, { "description": "Data for the term." @@ -49,8 +48,6 @@ ], "oneOf": [ { - "minItems": 3, - "maxItems": 3, "items": [ {}, {"const": "freq"}, @@ -83,8 +80,6 @@ ] }, { - "minItems": 3, - "maxItems": 3, "items": [ {}, {"const": "pitch"}, @@ -164,6 +159,52 @@ } } ] + }, + { + "items": [ + {}, + {"const": "ipa"}, + { + "type": ["object"], + "description": "IPA transcription information for the term.", + "required": [ + "reading", + "transcriptions" + ], + "additionalProperties": false, + "properties": { + "reading": { + "type": "string", + "description": "Reading for the term." + }, + "transcriptions": { + "type": "array", + "description": "List of different IPA transcription information for the term and reading combination.", + "items": { + "type": "object", + "required": [ + "ipa" + ], + "additionalProperties": false, + "properties": { + "ipa": { + "type": "string", + "description": "IPA transcription for the term." + }, + "tags": { + "type": "array", + "description": "List of tags for this IPA transcription.", + "items": { + "type": "string", + "description": "Tag for this IPA transcription." + } + } + } + } + } + } + } + ] } ] } diff --git a/ext/js/dictionary/dictionary-data-util.js b/ext/js/dictionary/dictionary-data-util.js index a54b043bbf..c3393804f7 100644 --- a/ext/js/dictionary/dictionary-data-util.js +++ b/ext/js/dictionary/dictionary-data-util.js @@ -146,7 +146,7 @@ export class DictionaryDataUtil { /** @type {Map} */ const groupedPronunciationsMap = new Map(); - for (const {headwordIndex, dictionary, pitches} of pronunciations) { + for (const {headwordIndex, dictionary, pitches, transcriptions} of pronunciations) { const {term, reading} = headwords[headwordIndex]; let dictionaryGroupedPronunciationList = groupedPronunciationsMap.get(dictionary); if (typeof dictionaryGroupedPronunciationList === 'undefined') { @@ -157,6 +157,7 @@ export class DictionaryDataUtil { let groupedPronunciation = this._findExistingGroupedPronunciation(reading, position, nasalPositions, devoicePositions, tags, dictionaryGroupedPronunciationList); if (groupedPronunciation === null) { groupedPronunciation = { + type: 'pitch-accent', terms: new Set(), reading, position, @@ -168,6 +169,20 @@ export class DictionaryDataUtil { } groupedPronunciation.terms.add(term); } + for (const {ipa, tags = []} of transcriptions) { + let groupedPronunciation = this._findExistingGroupedPronunciation(reading, ipa, null, null, null, tags, dictionaryGroupedPronunciationList); + if (groupedPronunciation === null) { + groupedPronunciation = { + type: 'phonetic-transcription', + terms: new Set(), + reading, + ipa, + tags + }; + dictionaryGroupedPronunciationList.push(groupedPronunciation); + } + groupedPronunciation.terms.add(term); + } } /** @type {import('dictionary-data-util').DictionaryGroupedPronunciations[]} */ diff --git a/ext/js/dictionary/dictionary-database.js b/ext/js/dictionary/dictionary-database.js index 45c5c6fdb9..02db6322a0 100644 --- a/ext/js/dictionary/dictionary-database.js +++ b/ext/js/dictionary/dictionary-database.js @@ -627,6 +627,8 @@ export class DictionaryDatabase { return {index, term, mode, data, dictionary}; case 'pitch': return {index, term, mode, data, dictionary}; + case 'ipa': + return {index, term, mode, data, dictionary}; default: throw new Error(`Unknown mode: ${mode}`); } diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 920d2c94c1..ec62236583 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -641,35 +641,61 @@ export class DisplayGenerator { */ _createPronunciation(details) { const jp = this._japaneseUtil; - const {reading, position, nasalPositions, devoicePositions, tags, exclusiveTerms, exclusiveReadings} = details; - const morae = jp.getKanaMorae(reading); - const node = this._instantiate('pronunciation'); + switch (details.type) { + case 'pitch-accent': { + const {reading, position, nasalPositions, devoicePositions, tags, exclusiveTerms, exclusiveReadings} = details; + const morae = jp.getKanaMorae(reading); - node.dataset.pitchAccentDownstepPosition = `${position}`; - if (nasalPositions.length > 0) { node.dataset.nasalMoraPosition = nasalPositions.join(' '); } - if (devoicePositions.length > 0) { node.dataset.devoiceMoraPosition = devoicePositions.join(' '); } - node.dataset.tagCount = `${tags.length}`; + const node = this._instantiate('pronunciation'); - let n = this._querySelector(node, '.pronunciation-tag-list'); - this._appendMultiple(n, this._createTag.bind(this), tags); + node.dataset.pitchAccentDownstepPosition = `${position}`; + if (nasalPositions.length > 0) { node.dataset.nasalMoraPosition = nasalPositions.join(' '); } + if (devoicePositions.length > 0) { node.dataset.devoiceMoraPosition = devoicePositions.join(' '); } + node.dataset.tagCount = `${tags.length}`; - n = this._querySelector(node, '.pronunciation-disambiguation-list'); - this._createPronunciationDisambiguations(n, exclusiveTerms, exclusiveReadings); + let n = this._querySelector(node, '.pronunciation-tag-list'); + this._appendMultiple(n, this._createTag.bind(this), tags); - n = this._querySelector(node, '.pronunciation-downstep-notation-container'); - n.appendChild(this._pronunciationGenerator.createPronunciationDownstepPosition(position)); + n = this._querySelector(node, '.pronunciation-disambiguation-list'); + this._createPronunciationDisambiguations(n, exclusiveTerms, exclusiveReadings); - n = this._querySelector(node, '.pronunciation-text-container'); - n.lang = 'ja'; - n.appendChild(this._pronunciationGenerator.createPronunciationText(morae, position, nasalPositions, devoicePositions)); + n = this._querySelector(node, '.pronunciation-downstep-notation-container'); + n.appendChild(this._pronunciationGenerator.createPronunciationDownstepPosition(position)); - n = this._querySelector(node, '.pronunciation-graph-container'); - n.appendChild(this._pronunciationGenerator.createPronunciationGraph(morae, position)); + n = this._querySelector(node, '.pronunciation-text-container'); - return node; + n.lang = 'ja'; + n.appendChild(this._pronunciationGenerator.createPronunciationText(morae, position, nasalPositions, devoicePositions)); + + n = this._querySelector(node, '.pronunciation-graph-container'); + n.appendChild(this._pronunciationGenerator.createPronunciationGraph(morae, position)); + + return node; + } + case 'phonetic-transcription': { + const {ipa, tags, exclusiveTerms, exclusiveReadings} = details; + + const node = this._instantiate('pronunciation'); + + node.dataset.tagCount = `${tags.length}`; + + let n = this._querySelector(node, '.pronunciation-tag-list'); + this._appendMultiple(n, this._createTag.bind(this), tags); + + n = this._querySelector(node, '.pronunciation-disambiguation-list'); + this._createPronunciationDisambiguations(n, exclusiveTerms, exclusiveReadings); + + n = this._querySelector(node, '.pronunciation-text-container'); + + this._setTextContent(n, ipa); + + return node; + } + } } + /** * @param {HTMLElement} container * @param {string[]} exclusiveTerms diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 4590994039..9316352349 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -988,6 +988,31 @@ export class Translator { } } break; + case 'ipa': + { + if (data.reading !== reading) { continue; } + /** @type {import('dictionary').TermIPA[]} */ + const phoneticTranscriptions = []; + for (const {ipa, tags} of data.transcriptions) { + /** @type {import('dictionary').Tag[]} */ + const tags2 = []; + if (Array.isArray(tags)) { + tagAggregator.addTags(tags2, dictionary, tags); + } + phoneticTranscriptions.push({ipa, tags: tags2}); + } + for (const {pronunciations, headwordIndex} of targets) { + pronunciations.push(this._createTermPronunciation( + pronunciations.length, + headwordIndex, + dictionary, + dictionaryIndex, + dictionaryPriority, + [], + phoneticTranscriptions + )); + } + } } } } @@ -1342,10 +1367,11 @@ export class Translator { * @param {number} dictionaryIndex * @param {number} dictionaryPriority * @param {import('dictionary').TermPitch[]} pitches + * @param {import('dictionary').TermIPA[]} transcriptions * @returns {import('dictionary').TermPronunciation} */ - _createTermPronunciation(index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pitches) { - return {index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pitches}; + _createTermPronunciation(index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pitches, transcriptions) { + return {index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pitches, transcriptions}; } /** diff --git a/types/ext/dictionary-data-util.d.ts b/types/ext/dictionary-data-util.d.ts index b78e643956..21a4a6e8e9 100644 --- a/types/ext/dictionary-data-util.d.ts +++ b/types/ext/dictionary-data-util.d.ts @@ -63,7 +63,8 @@ export type KanjiFrequency = { export type TermFrequencyType = 'popular' | 'rare' | 'normal'; -export type GroupedPronunciationInternal = { +export type GroupedPitchAccentInternal = { + type: 'pitch-accent'; terms: Set; reading: string; position: number; @@ -72,8 +73,19 @@ export type GroupedPronunciationInternal = { tags: Dictionary.Tag[]; }; -export type GroupedPronunciation = { - terms: string[]; +export type GroupedIpaInternal = { + type: 'phonetic-transcription'; + terms: Set; + reading: string; + tags: Dictionary.Tag[]; + ipa: string; +}; + +export type GroupedPronunciationInternal = GroupedPitchAccentInternal | GroupedIpaInternal; + +export type GroupedPitchAccent = { + type: 'pitch-accent'; + terms: Set; reading: string; position: number; nasalPositions: number[]; @@ -83,6 +95,19 @@ export type GroupedPronunciation = { exclusiveReadings: string[]; }; +export type GroupedIpa = { + type: 'phonetic-transcription'; + terms: Set; + reading: string; + tags: Dictionary.Tag[]; + ipa: string; + exclusiveTerms: string[]; + exclusiveReadings: string[]; +}; + + +export type GroupedPronunciation = GroupedPitchAccent | GroupedIpa; + export type DictionaryGroupedPronunciations = { dictionary: string; pronunciations: GroupedPronunciation[]; diff --git a/types/ext/dictionary-data.d.ts b/types/ext/dictionary-data.d.ts index b194c190cd..3c610d2587 100644 --- a/types/ext/dictionary-data.d.ts +++ b/types/ext/dictionary-data.d.ts @@ -154,6 +154,14 @@ export type TermMetaPitch = [ data: TermMetaPitchData, ]; +export type TermMetaIpaData = { + reading: string; + transcriptions: { + ipa: string; + tags?: string[]; + }[]; +}; + export type KanjiMetaArray = KanjiMeta[]; export type KanjiMeta = KanjiMetaFrequency; diff --git a/types/ext/dictionary-database.d.ts b/types/ext/dictionary-database.d.ts index 3202ef6017..d9238b05a9 100644 --- a/types/ext/dictionary-database.d.ts +++ b/types/ext/dictionary-database.d.ts @@ -102,7 +102,7 @@ export type Tag = { dictionary: string; }; -export type DatabaseTermMeta = DatabaseTermMetaFrequency | DatabaseTermMetaPitch; +export type DatabaseTermMeta = DatabaseTermMetaFrequency | DatabaseTermMetaPitch | DatabaseTermMetaIpa; export type DatabaseTermMetaFrequency = { expression: string; @@ -118,12 +118,19 @@ export type DatabaseTermMetaPitch = { dictionary: string; }; +export type DatabaseTermMetaIpa = { + expression: string; + mode: 'ipa'; + data: DictionaryData.TermMetaIpaData; + dictionary: string; +}; + export type TermMetaFrequencyDataWithReading = { reading: string; frequency: DictionaryData.GenericFrequencyData; }; -export type TermMeta = TermMetaFrequency | TermMetaPitch; +export type TermMeta = TermMetaFrequency | TermMetaPitch | TermMetaIPA; export type TermMetaType = TermMeta['mode']; @@ -143,6 +150,15 @@ export type TermMetaPitch = { dictionary: string; }; +export type TermMetaIPA = { + index: number; + term: string; + mode: 'ipa'; + data: DictionaryData.TermMetaIpaData; + dictionary: string; +}; + + export type DatabaseKanjiMeta = DatabaseKanjiMetaFrequency; export type DatabaseKanjiMetaFrequency = { diff --git a/types/ext/dictionary.d.ts b/types/ext/dictionary.d.ts index 3e90dec0e1..35730c1cb5 100644 --- a/types/ext/dictionary.d.ts +++ b/types/ext/dictionary.d.ts @@ -368,6 +368,10 @@ export type TermPronunciation = { * The pitch accent representations for the term. */ pitches: TermPitch[]; + /** + * The phonetic transcriptions for the term. + */ + transcriptions: TermIPA[]; }; /** @@ -392,6 +396,17 @@ export type TermPitch = { tags: Tag[]; }; +export type TermIPA = { + /** + * An IPA transcription. + */ + ipa: string; + /** + * Tags for the IPA transcription. + */ + tags: Tag[]; +}; + /** * Frequency information corresponds to how frequently a term appears in a corpus, * which can be a number of occurrences or an overall rank. From 4c5ead34e4bc0ed48ec3f96830491d37c0fe6f39 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Fri, 22 Dec 2023 23:26:40 +0100 Subject: [PATCH 03/19] move dictionary files to dictionary folder --- .eslintrc.json | 10 +++++----- dev/jsconfig.json | 4 ++-- ext/js/background/backend.js | 2 +- ext/js/background/offscreen.js | 2 +- ext/js/data/sandbox/anki-note-data-creator.js | 2 +- .../sandbox => dictionary}/dictionary-data-util.js | 0 ext/js/{language => dictionary}/dictionary-database.js | 0 .../dictionary-importer-media-loader.js | 0 ext/js/{language => dictionary}/dictionary-importer.js | 0 .../dictionary-worker-handler.js | 0 .../{language => dictionary}/dictionary-worker-main.js | 0 .../dictionary-worker-media-loader.js | 0 ext/js/{language => dictionary}/dictionary-worker.js | 2 +- ext/js/display/display-generator.js | 2 +- ext/js/language/translator.js | 2 +- ext/js/pages/settings/dictionary-controller.js | 2 +- ext/js/pages/settings/dictionary-import-controller.js | 2 +- ext/js/templates/sandbox/anki-template-renderer.js | 2 +- test/database.test.js | 4 ++-- test/fixtures/translator-test.js | 4 ++-- types/ext/translator.d.ts | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) rename ext/js/{language/sandbox => dictionary}/dictionary-data-util.js (100%) rename ext/js/{language => dictionary}/dictionary-database.js (100%) rename ext/js/{language => dictionary}/dictionary-importer-media-loader.js (100%) rename ext/js/{language => dictionary}/dictionary-importer.js (100%) rename ext/js/{language => dictionary}/dictionary-worker-handler.js (100%) rename ext/js/{language => dictionary}/dictionary-worker-main.js (100%) rename ext/js/{language => dictionary}/dictionary-worker-media-loader.js (100%) rename ext/js/{language => dictionary}/dictionary-worker.js (98%) diff --git a/.eslintrc.json b/.eslintrc.json index 873092967c..bd90f4fc12 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -651,7 +651,7 @@ "ext/js/general/regex-util.js", "ext/js/general/text-source-map.js", "ext/js/language/deinflector.js", - "ext/js/language/dictionary-database.js", + "ext/js/dictionary/dictionary-database.js", "ext/js/language/sandbox/dictionary-data-util.js", "ext/js/language/sandbox/japanese-util.js", "ext/js/language/translator.js", @@ -679,10 +679,10 @@ "ext/js/data/database.js", "ext/js/data/json-schema.js", "ext/js/general/cache-map.js", - "ext/js/language/dictionary-database.js", - "ext/js/language/dictionary-importer.js", - "ext/js/language/dictionary-worker-handler.js", - "ext/js/language/dictionary-worker-media-loader.js", + "ext/js/dictionary/dictionary-database.js", + "ext/js/dictionary/dictionary-importer.js", + "ext/js/dictionary/dictionary-worker-handler.js", + "ext/js/dictionary/dictionary-worker-media-loader.js", "ext/js/media/media-util.js" ], "env": { diff --git a/dev/jsconfig.json b/dev/jsconfig.json index d613e88d4c..a754006890 100644 --- a/dev/jsconfig.json +++ b/dev/jsconfig.json @@ -64,8 +64,8 @@ "../ext/js/general/regex-util.js", "../ext/js/general/text-source-map.js", "../ext/js/language/deinflector.js", - "../ext/js/language/dictionary-importer.js", - "../ext/js/language/dictionary-database.js", + "../ext/js/dictionary/dictionary-importer.js", + "../ext/js/dictionary/dictionary-database.js", "../ext/js/language/sandbox/dictionary-data-util.js", "../ext/js/language/sandbox/japanese-util.js", "../ext/js/language/translator.js", diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index f7cad1e6f6..df4b977751 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -30,9 +30,9 @@ import {AnkiUtil} from '../data/anki-util.js'; import {OptionsUtil} from '../data/options-util.js'; import {PermissionsUtil} from '../data/permissions-util.js'; import {ArrayBufferUtil} from '../data/sandbox/array-buffer-util.js'; +import {DictionaryDatabase} from '../dictionary/dictionary-database.js'; import {Environment} from '../extension/environment.js'; import {ObjectPropertyAccessor} from '../general/object-property-accessor.js'; -import {DictionaryDatabase} from '../language/dictionary-database.js'; import {JapaneseUtil} from '../language/sandbox/japanese-util.js'; import {Translator} from '../language/translator.js'; import {AudioDownloader} from '../media/audio-downloader.js'; diff --git a/ext/js/background/offscreen.js b/ext/js/background/offscreen.js index 7e3576ba4a..05c655dfb0 100644 --- a/ext/js/background/offscreen.js +++ b/ext/js/background/offscreen.js @@ -20,7 +20,7 @@ import * as wanakana from '../../lib/wanakana.js'; import {ClipboardReader} from '../comm/clipboard-reader.js'; import {createApiMap, invokeApiMapHandler} from '../core/api-map.js'; import {ArrayBufferUtil} from '../data/sandbox/array-buffer-util.js'; -import {DictionaryDatabase} from '../language/dictionary-database.js'; +import {DictionaryDatabase} from '../dictionary/dictionary-database.js'; import {JapaneseUtil} from '../language/sandbox/japanese-util.js'; import {Translator} from '../language/translator.js'; diff --git a/ext/js/data/sandbox/anki-note-data-creator.js b/ext/js/data/sandbox/anki-note-data-creator.js index dce719381b..9d93b49789 100644 --- a/ext/js/data/sandbox/anki-note-data-creator.js +++ b/ext/js/data/sandbox/anki-note-data-creator.js @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -import {DictionaryDataUtil} from '../../language/sandbox/dictionary-data-util.js'; +import {DictionaryDataUtil} from '../../dictionary/dictionary-data-util.js'; /** * This class is used to convert the internal dictionary entry format to the diff --git a/ext/js/language/sandbox/dictionary-data-util.js b/ext/js/dictionary/dictionary-data-util.js similarity index 100% rename from ext/js/language/sandbox/dictionary-data-util.js rename to ext/js/dictionary/dictionary-data-util.js diff --git a/ext/js/language/dictionary-database.js b/ext/js/dictionary/dictionary-database.js similarity index 100% rename from ext/js/language/dictionary-database.js rename to ext/js/dictionary/dictionary-database.js diff --git a/ext/js/language/dictionary-importer-media-loader.js b/ext/js/dictionary/dictionary-importer-media-loader.js similarity index 100% rename from ext/js/language/dictionary-importer-media-loader.js rename to ext/js/dictionary/dictionary-importer-media-loader.js diff --git a/ext/js/language/dictionary-importer.js b/ext/js/dictionary/dictionary-importer.js similarity index 100% rename from ext/js/language/dictionary-importer.js rename to ext/js/dictionary/dictionary-importer.js diff --git a/ext/js/language/dictionary-worker-handler.js b/ext/js/dictionary/dictionary-worker-handler.js similarity index 100% rename from ext/js/language/dictionary-worker-handler.js rename to ext/js/dictionary/dictionary-worker-handler.js diff --git a/ext/js/language/dictionary-worker-main.js b/ext/js/dictionary/dictionary-worker-main.js similarity index 100% rename from ext/js/language/dictionary-worker-main.js rename to ext/js/dictionary/dictionary-worker-main.js diff --git a/ext/js/language/dictionary-worker-media-loader.js b/ext/js/dictionary/dictionary-worker-media-loader.js similarity index 100% rename from ext/js/language/dictionary-worker-media-loader.js rename to ext/js/dictionary/dictionary-worker-media-loader.js diff --git a/ext/js/language/dictionary-worker.js b/ext/js/dictionary/dictionary-worker.js similarity index 98% rename from ext/js/language/dictionary-worker.js rename to ext/js/dictionary/dictionary-worker.js index 3119dd7b22..669c65accc 100644 --- a/ext/js/language/dictionary-worker.js +++ b/ext/js/dictionary/dictionary-worker.js @@ -73,7 +73,7 @@ export class DictionaryWorker { */ _invoke(action, params, transfer, onProgress, formatResult) { return new Promise((resolve, reject) => { - const worker = new Worker('/js/language/dictionary-worker-main.js', {type: 'module'}); + const worker = new Worker('/js/dictionary/dictionary-worker-main.js', {type: 'module'}); /** @type {import('dictionary-worker').InvokeDetails} */ const details = { complete: false, diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 87b02f8a73..920d2c94c1 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -18,8 +18,8 @@ import {isObject} from '../core.js'; import {ExtensionError} from '../core/extension-error.js'; +import {DictionaryDataUtil} from '../dictionary/dictionary-data-util.js'; import {HtmlTemplateCollection} from '../dom/html-template-collection.js'; -import {DictionaryDataUtil} from '../language/sandbox/dictionary-data-util.js'; import {yomitan} from '../yomitan.js'; import {PronunciationGenerator} from './sandbox/pronunciation-generator.js'; import {StructuredContentGenerator} from './sandbox/structured-content-generator.js'; diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index ddbd857855..4590994039 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -31,7 +31,7 @@ export class Translator { constructor({japaneseUtil, database}) { /** @type {import('./sandbox/japanese-util.js').JapaneseUtil} */ this._japaneseUtil = japaneseUtil; - /** @type {import('./dictionary-database.js').DictionaryDatabase} */ + /** @type {import('../dictionary/dictionary-database.js').DictionaryDatabase} */ this._database = database; /** @type {?Deinflector} */ this._deinflector = null; diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js index 6e9522db01..db6a73d43f 100644 --- a/ext/js/pages/settings/dictionary-controller.js +++ b/ext/js/pages/settings/dictionary-controller.js @@ -17,8 +17,8 @@ */ import {EventListenerCollection, log} from '../../core.js'; +import {DictionaryWorker} from '../../dictionary/dictionary-worker.js'; import {querySelectorNotNull} from '../../dom/query-selector.js'; -import {DictionaryWorker} from '../../language/dictionary-worker.js'; import {yomitan} from '../../yomitan.js'; class DictionaryEntry { diff --git a/ext/js/pages/settings/dictionary-import-controller.js b/ext/js/pages/settings/dictionary-import-controller.js index 35b7c461fc..c478b26549 100644 --- a/ext/js/pages/settings/dictionary-import-controller.js +++ b/ext/js/pages/settings/dictionary-import-controller.js @@ -18,8 +18,8 @@ import {log} from '../../core.js'; import {ExtensionError} from '../../core/extension-error.js'; +import {DictionaryWorker} from '../../dictionary/dictionary-worker.js'; import {querySelectorNotNull} from '../../dom/query-selector.js'; -import {DictionaryWorker} from '../../language/dictionary-worker.js'; import {yomitan} from '../../yomitan.js'; import {DictionaryController} from './dictionary-controller.js'; diff --git a/ext/js/templates/sandbox/anki-template-renderer.js b/ext/js/templates/sandbox/anki-template-renderer.js index 515e85daa2..d69c7b476b 100644 --- a/ext/js/templates/sandbox/anki-template-renderer.js +++ b/ext/js/templates/sandbox/anki-template-renderer.js @@ -18,10 +18,10 @@ import {Handlebars} from '../../../lib/handlebars.js'; import {AnkiNoteDataCreator} from '../../data/sandbox/anki-note-data-creator.js'; +import {DictionaryDataUtil} from '../../dictionary/dictionary-data-util.js'; import {PronunciationGenerator} from '../../display/sandbox/pronunciation-generator.js'; import {StructuredContentGenerator} from '../../display/sandbox/structured-content-generator.js'; import {CssStyleApplier} from '../../dom/sandbox/css-style-applier.js'; -import {DictionaryDataUtil} from '../../language/sandbox/dictionary-data-util.js'; import {JapaneseUtil} from '../../language/sandbox/japanese-util.js'; import {AnkiTemplateRendererContentManager} from './anki-template-renderer-content-manager.js'; import {TemplateRendererMediaProvider} from './template-renderer-media-provider.js'; diff --git a/test/database.test.js b/test/database.test.js index 86c69a41c9..4a52f18d58 100644 --- a/test/database.test.js +++ b/test/database.test.js @@ -22,8 +22,8 @@ import path from 'path'; import {beforeEach, describe, expect, test, vi} from 'vitest'; import {parseJson} from '../dev/json.js'; import {createDictionaryArchive} from '../dev/util.js'; -import {DictionaryDatabase} from '../ext/js/language/dictionary-database.js'; -import {DictionaryImporter} from '../ext/js/language/dictionary-importer.js'; +import {DictionaryDatabase} from '../ext/js/dictionary/dictionary-database.js'; +import {DictionaryImporter} from '../ext/js/dictionary/dictionary-importer.js'; import {DictionaryImporterMediaLoader} from './mocks/dictionary-importer-media-loader.js'; const dirname = path.dirname(fileURLToPath(import.meta.url)); diff --git a/test/fixtures/translator-test.js b/test/fixtures/translator-test.js index 0afbe1f0b1..83644513aa 100644 --- a/test/fixtures/translator-test.js +++ b/test/fixtures/translator-test.js @@ -24,8 +24,8 @@ import {expect, vi} from 'vitest'; import {parseJson} from '../../dev/json.js'; import {createDictionaryArchive} from '../../dev/util.js'; import {AnkiNoteDataCreator} from '../../ext/js/data/sandbox/anki-note-data-creator.js'; -import {DictionaryDatabase} from '../../ext/js/language/dictionary-database.js'; -import {DictionaryImporter} from '../../ext/js/language/dictionary-importer.js'; +import {DictionaryDatabase} from '../../ext/js/dictionary/dictionary-database.js'; +import {DictionaryImporter} from '../../ext/js/dictionary/dictionary-importer.js'; import {JapaneseUtil} from '../../ext/js/language/sandbox/japanese-util.js'; import {Translator} from '../../ext/js/language/translator.js'; import {chrome, fetch} from '../mocks/common.js'; diff --git a/types/ext/translator.d.ts b/types/ext/translator.d.ts index 39d4be81b7..f1eb6bccf4 100644 --- a/types/ext/translator.d.ts +++ b/types/ext/translator.d.ts @@ -15,7 +15,7 @@ * along with this program. If not, see . */ -import type {DictionaryDatabase} from '../../ext/js/language/dictionary-database'; +import type {DictionaryDatabase} from '../../ext/js/dictionary/dictionary-database'; import type {JapaneseUtil} from '../../ext/js/language/sandbox/japanese-util'; import type * as Dictionary from './dictionary'; import type * as DictionaryDatabaseTypes from './dictionary-database'; From 1ffb531ea42e2227a5cb10e36e1bb4e17e66242e Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sat, 23 Dec 2023 14:43:40 +0100 Subject: [PATCH 04/19] add ipa term meta --- .eslintrc.json | 2 +- dev/jsconfig.json | 2 +- .../default-anki-field-templates.handlebars | 19 ++++ ext/js/data/sandbox/anki-note-data-creator.js | 99 +++++++++++++++-- ext/js/dictionary/dictionary-data-util.js | 100 ++++++++++-------- ext/js/display/display-generator.js | 15 +-- ext/js/language/translator.js | 26 +++-- ext/js/pages/settings/anki-controller.js | 1 + test/utilities/anki.js | 1 + types/ext/anki-templates.d.ts | 44 +++++++- types/ext/dictionary-data-util.d.ts | 4 +- types/ext/dictionary.d.ts | 16 +-- 12 files changed, 241 insertions(+), 88 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index bd90f4fc12..cb5d754c03 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -652,7 +652,7 @@ "ext/js/general/text-source-map.js", "ext/js/language/deinflector.js", "ext/js/dictionary/dictionary-database.js", - "ext/js/language/sandbox/dictionary-data-util.js", + "ext/js/dictionary/dictionary-data-util.js", "ext/js/language/sandbox/japanese-util.js", "ext/js/language/translator.js", "ext/js/media/audio-downloader.js", diff --git a/dev/jsconfig.json b/dev/jsconfig.json index a754006890..c791b5c0d2 100644 --- a/dev/jsconfig.json +++ b/dev/jsconfig.json @@ -66,7 +66,7 @@ "../ext/js/language/deinflector.js", "../ext/js/dictionary/dictionary-importer.js", "../ext/js/dictionary/dictionary-database.js", - "../ext/js/language/sandbox/dictionary-data-util.js", + "../ext/js/dictionary/dictionary-data-util.js", "../ext/js/language/sandbox/japanese-util.js", "../ext/js/language/translator.js", "../ext/js/media/media-util.js", diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index d94f6d709f..7785737ed2 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -229,6 +229,25 @@ {{/inline}} {{! End Pitch Accents }} +{{#*inline "phonetic-transcriptions"}} +
    + {{~#each definition.transcriptions~}} + {{~#each transcriptions~}} +
  • + {{~set "any" false~}} + {{~#each tags~}} + {{~#if (get "any")}}, {{else}}({{/if~}} + {{name}} + {{~set "any" true~}} + {{~/each~}} + {{~#if (get "any")}}) {{/if~}} + {{ipa}} +
  • + {{~/each~}} + {{~/each~}} +
+{{/inline}} + {{#*inline "clipboard-image"}} {{~#if (hasMedia "clipboardImage")~}} diff --git a/ext/js/data/sandbox/anki-note-data-creator.js b/ext/js/data/sandbox/anki-note-data-creator.js index 9d93b49789..624a334dc2 100644 --- a/ext/js/data/sandbox/anki-note-data-creator.js +++ b/ext/js/data/sandbox/anki-note-data-creator.js @@ -55,6 +55,8 @@ export class AnkiNoteDataCreator { const context2 = this.createCachedValue(this._getPublicContext.bind(this, context)); const pitches = this.createCachedValue(this._getPitches.bind(this, dictionaryEntry)); const pitchCount = this.createCachedValue(this._getPitchCount.bind(this, pitches)); + const phoneticTranscriptions = this.createCachedValue(this._getPhoneticTranscriptions.bind(this, dictionaryEntry)); + if (typeof media !== 'object' || media === null || Array.isArray(media)) { media = { audio: void 0, @@ -82,6 +84,7 @@ export class AnkiNoteDataCreator { get uniqueReadings() { return self.getCachedValue(uniqueReadings); }, get pitches() { return self.getCachedValue(pitches); }, get pitchCount() { return self.getCachedValue(pitchCount); }, + get phoneticTranscriptions() { return self.getCachedValue(phoneticTranscriptions); }, get context() { return self.getCachedValue(context2); }, media, dictionaryEntry @@ -193,7 +196,9 @@ export class AnkiNoteDataCreator { for (const {dictionary, pronunciations} of DictionaryDataUtil.getGroupedPronunciations(dictionaryEntry)) { /** @type {import('anki-templates').Pitch[]} */ const pitches = []; - for (const {terms, reading, position, nasalPositions, devoicePositions, tags, exclusiveTerms, exclusiveReadings} of pronunciations) { + for (const pronunciation of pronunciations) { + if (pronunciation.type !== 'pitch-accent') { continue; } + const {terms, reading, position, nasalPositions, devoicePositions, tags, exclusiveTerms, exclusiveReadings} = pronunciation; pitches.push({ expressions: terms, reading, @@ -211,6 +216,33 @@ export class AnkiNoteDataCreator { return results; } + /** + * @param {import('dictionary').DictionaryEntry} dictionaryEntry + * @returns {import('anki-templates').TranscriptionGroup[]} + */ + _getPhoneticTranscriptions(dictionaryEntry) { + const results = []; + if (dictionaryEntry.type === 'term') { + for (const {dictionary, pronunciations} of DictionaryDataUtil.getGroupedPronunciations(dictionaryEntry)) { + const transcriptions = []; + for (const pronunciation of pronunciations) { + if (pronunciation.type !== 'phonetic-transcription') { continue; } + const {terms, reading, ipa, tags, exclusiveTerms, exclusiveReadings} = pronunciation; + transcriptions.push({ + expressions: terms, + reading, + ipa, + tags, + exclusiveExpressions: exclusiveTerms, + exclusiveReadings + }); + } + results.push({dictionary, transcriptions}); + } + } + return results; + } + /** * @param {import('anki-templates-internal').CachedValue} cachedPitches * @returns {number} @@ -353,6 +385,7 @@ export class AnkiNoteDataCreator { const expressions = this.createCachedValue(this._getTermExpressions.bind(this, dictionaryEntry)); const frequencies = this.createCachedValue(this._getTermFrequencies.bind(this, dictionaryEntry)); const pitches = this.createCachedValue(this._getTermPitches.bind(this, dictionaryEntry)); + const transcriptions = this.createCachedValue(this._getTermPhoneticTranscriptions.bind(this, dictionaryEntry)); const glossary = this.createCachedValue(this._getTermGlossaryArray.bind(this, dictionaryEntry, type)); const cloze = this.createCachedValue(this._getCloze.bind(this, dictionaryEntry, context)); const furiganaSegments = this.createCachedValue(this._getTermFuriganaSegments.bind(this, dictionaryEntry, type)); @@ -389,6 +422,7 @@ export class AnkiNoteDataCreator { get definitions() { return self.getCachedValue(commonInfo).definitions; }, get frequencies() { return self.getCachedValue(frequencies); }, get pitches() { return self.getCachedValue(pitches); }, + get transcriptions() { return self.getCachedValue(transcriptions); }, sourceTermExactMatchCount, url, get cloze() { return self.getCachedValue(cloze); }, @@ -485,15 +519,17 @@ export class AnkiNoteDataCreator { /** * @param {import('dictionary').TermDictionaryEntry} dictionaryEntry - * @returns {import('anki-templates').TermPronunciation[]} + * @returns {import('anki-templates').TermPitchAccent[]} */ _getTermPitches(dictionaryEntry) { // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; const results = []; const {headwords} = dictionaryEntry; - for (const {headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pitches} of dictionaryEntry.pronunciations) { + for (const {headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations} of dictionaryEntry.pronunciations) { const {term, reading} = headwords[headwordIndex]; + /** @type {import('dictionary').PitchAccent[]} */ + const pitches = pronunciations.filter((v) => v.type === 'pitch-accent'); const cachedPitches = this.createCachedValue(this._getTermPitchesInner.bind(this, pitches)); results.push({ index: results.length, @@ -512,8 +548,8 @@ export class AnkiNoteDataCreator { } /** - * @param {import('dictionary').TermPitch[]} pitches - * @returns {import('anki-templates').TermPitch[]} + * @param {import('dictionary').PitchAccent[]} pitches + * @returns {import('anki-templates').PitchAccent[]} */ _getTermPitchesInner(pitches) { // eslint-disable-next-line @typescript-eslint/no-this-alias @@ -529,6 +565,52 @@ export class AnkiNoteDataCreator { return results; } + /** + * @param {import('dictionary').TermDictionaryEntry} dictionaryEntry + * @returns {import('anki-templates').TermIpaTranscription[]} + */ + _getTermPhoneticTranscriptions(dictionaryEntry) { + const results = []; + const {headwords} = dictionaryEntry; + for (const {headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations} of dictionaryEntry.pronunciations) { + const {term, reading} = headwords[headwordIndex]; + const phoneticTranscriptions = pronunciations.filter((v) => v.type === 'phonetic-transcription'); + const termPhoneticTranscriptions = this._getTermPhoneticTranscriptionsInner(phoneticTranscriptions); + results.push({ + index: results.length, + expressionIndex: headwordIndex, + dictionary, + dictionaryOrder: { + index: dictionaryIndex, + priority: dictionaryPriority + }, + expression: term, + reading, + get transcriptions() { return termPhoneticTranscriptions; } + }); + } + + return results; + } + + /** + * @param {import('dictionary').IpaTranscription[]} phoneticTranscriptions + * @returns {import('anki-templates').IpaTranscription[]} + */ + _getTermPhoneticTranscriptionsInner(phoneticTranscriptions) { + // eslint-disable-next-line @typescript-eslint/no-this-alias + const self = this; + const results = []; + for (const {ipa, tags} of phoneticTranscriptions) { + const cachedTags = this.createCachedValue(this._convertTags.bind(this, tags)); + results.push({ + ipa, + get tags() { return self.getCachedValue(cachedTags); } + }); + } + return results; + } + /** * @param {import('dictionary').TermDictionaryEntry} dictionaryEntry * @returns {import('anki-templates').TermHeadword[]} @@ -592,16 +674,17 @@ export class AnkiNoteDataCreator { /** * @param {import('dictionary').TermDictionaryEntry} dictionaryEntry * @param {number} i - * @returns {import('anki-templates').TermPronunciation[]} + * @returns {import('anki-templates').TermPitchAccent[]} */ _getTermExpressionPitches(dictionaryEntry, i) { // eslint-disable-next-line @typescript-eslint/no-this-alias const self = this; const results = []; - const {headwords, pronunciations} = dictionaryEntry; - for (const {headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pitches} of pronunciations) { + const {headwords, pronunciations: termPronunciations} = dictionaryEntry; + for (const {headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations} of termPronunciations) { if (headwordIndex !== i) { continue; } const {term, reading} = headwords[headwordIndex]; + const pitches = pronunciations.filter((v) => v.type === 'pitch-accent'); const cachedPitches = this.createCachedValue(this._getTermPitchesInner.bind(this, pitches)); results.push({ index: results.length, diff --git a/ext/js/dictionary/dictionary-data-util.js b/ext/js/dictionary/dictionary-data-util.js index c3393804f7..df4a7737d5 100644 --- a/ext/js/dictionary/dictionary-data-util.js +++ b/ext/js/dictionary/dictionary-data-util.js @@ -135,7 +135,7 @@ export class DictionaryDataUtil { * @returns {import('dictionary-data-util').DictionaryGroupedPronunciations[]} */ static getGroupedPronunciations(dictionaryEntry) { - const {headwords, pronunciations} = dictionaryEntry; + const {headwords, pronunciations: termPronunciations} = dictionaryEntry; const allTerms = new Set(); const allReadings = new Set(); @@ -146,38 +146,20 @@ export class DictionaryDataUtil { /** @type {Map} */ const groupedPronunciationsMap = new Map(); - for (const {headwordIndex, dictionary, pitches, transcriptions} of pronunciations) { + for (const {headwordIndex, dictionary, pronunciations} of termPronunciations) { const {term, reading} = headwords[headwordIndex]; let dictionaryGroupedPronunciationList = groupedPronunciationsMap.get(dictionary); if (typeof dictionaryGroupedPronunciationList === 'undefined') { dictionaryGroupedPronunciationList = []; groupedPronunciationsMap.set(dictionary, dictionaryGroupedPronunciationList); } - for (const {position, nasalPositions, devoicePositions, tags} of pitches) { - let groupedPronunciation = this._findExistingGroupedPronunciation(reading, position, nasalPositions, devoicePositions, tags, dictionaryGroupedPronunciationList); + for (const pronunciation of pronunciations) { + let groupedPronunciation = this._findExistingGroupedPronunciation(reading, pronunciation, dictionaryGroupedPronunciationList); if (groupedPronunciation === null) { groupedPronunciation = { - type: 'pitch-accent', + ...pronunciation, terms: new Set(), - reading, - position, - nasalPositions, - devoicePositions, - tags - }; - dictionaryGroupedPronunciationList.push(groupedPronunciation); - } - groupedPronunciation.terms.add(term); - } - for (const {ipa, tags = []} of transcriptions) { - let groupedPronunciation = this._findExistingGroupedPronunciation(reading, ipa, null, null, null, tags, dictionaryGroupedPronunciationList); - if (groupedPronunciation === null) { - groupedPronunciation = { - type: 'phonetic-transcription', - terms: new Set(), - reading, - ipa, - tags + reading }; dictionaryGroupedPronunciationList.push(groupedPronunciation); } @@ -192,22 +174,41 @@ export class DictionaryDataUtil { /** @type {import('dictionary-data-util').GroupedPronunciation[]} */ const pronunciations2 = []; for (const groupedPronunciation of dictionaryGroupedPronunciationList) { - const {terms, reading, position, nasalPositions, devoicePositions, tags} = groupedPronunciation; + const {terms, reading} = groupedPronunciation; const exclusiveTerms = !this._areSetsEqual(terms, allTerms) ? this._getSetIntersection(terms, allTerms) : []; const exclusiveReadings = []; if (multipleReadings) { exclusiveReadings.push(reading); } - pronunciations2.push({ - terms: [...terms], - reading, - position, - nasalPositions, - devoicePositions, - tags, - exclusiveTerms, - exclusiveReadings - }); + switch (groupedPronunciation.type) { + case 'pitch-accent': { + const {position, nasalPositions, devoicePositions, tags} = groupedPronunciation; + pronunciations2.push({ + type: 'pitch-accent', + terms: [...terms], + reading, + position, + nasalPositions, + devoicePositions, + tags, + exclusiveTerms, + exclusiveReadings + }); + break; + } case 'phonetic-transcription': { + const {ipa, tags} = groupedPronunciation; + pronunciations2.push({ + type: 'phonetic-transcription', + terms: [...terms], + reading, + ipa, + tags, + exclusiveTerms, + exclusiveReadings + }); + break; + } + } } results2.push({dictionary, pronunciations: pronunciations2}); } @@ -303,23 +304,28 @@ export class DictionaryDataUtil { /** * @param {string} reading - * @param {number} position - * @param {number[]} nasalPositions - * @param {number[]} devoicePositions - * @param {import('dictionary').Tag[]} tags + * @param {import('dictionary').Pronunciation} pronunciation * @param {import('dictionary-data-util').GroupedPronunciationInternal[]} groupedPronunciationList * @returns {?import('dictionary-data-util').GroupedPronunciationInternal} */ - static _findExistingGroupedPronunciation(reading, position, nasalPositions, devoicePositions, tags, groupedPronunciationList) { - for (const pitchInfo of groupedPronunciationList) { + static _findExistingGroupedPronunciation(reading, pronunciation, groupedPronunciationList) { + for (const groupedPronunciation of groupedPronunciationList) { if ( - pitchInfo.reading === reading && - pitchInfo.position === position && - this._areArraysEqual(pitchInfo.nasalPositions, nasalPositions) && - this._areArraysEqual(pitchInfo.devoicePositions, devoicePositions) && - this._areTagListsEqual(pitchInfo.tags, tags) + groupedPronunciation.reading === reading && + this._areTagListsEqual(groupedPronunciation.tags, pronunciation.tags) && + ( + pronunciation.type === 'pitch-accent' && + groupedPronunciation.type === 'pitch-accent' && + groupedPronunciation.position === pronunciation.position && + this._areArraysEqual(groupedPronunciation.nasalPositions, pronunciation.nasalPositions) && + this._areArraysEqual(groupedPronunciation.devoicePositions, pronunciation.devoicePositions) + || + pronunciation.type === 'phonetic-transcription' && + groupedPronunciation.type === 'phonetic-transcription' && + groupedPronunciation.ipa === pronunciation.ipa + ) ) { - return pitchInfo; + return groupedPronunciation; } } return null; diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index ec62236583..9cfcf04723 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -975,20 +975,21 @@ export class DisplayGenerator { /** * @param {string} reading - * @param {import('dictionary').TermPronunciation[]} pronunciations + * @param {import('dictionary').TermPronunciation[]} termPronounciations * @param {string[]} wordClasses * @param {number} headwordIndex * @returns {?string} */ - _getPronunciationCategories(reading, pronunciations, wordClasses, headwordIndex) { - if (pronunciations.length === 0) { return null; } + _getPronunciationCategories(reading, termPronounciations, wordClasses, headwordIndex) { + if (termPronounciations.length === 0) { return null; } const isVerbOrAdjective = DictionaryDataUtil.isNonNounVerbOrAdjective(wordClasses); /** @type {Set} */ const categories = new Set(); - for (const pronunciation of pronunciations) { - if (pronunciation.headwordIndex !== headwordIndex) { continue; } - for (const {position} of pronunciation.pitches) { - const category = this._japaneseUtil.getPitchCategory(reading, position, isVerbOrAdjective); + for (const termPronunciation of termPronounciations) { + if (termPronunciation.headwordIndex !== headwordIndex) { continue; } + for (const pronunciation of termPronunciation.pronunciations) { + if (pronunciation.type !== 'pitch-accent'){ continue; } + const category = this._japaneseUtil.getPitchCategory(reading, pronunciation.position, isVerbOrAdjective); if (category !== null) { categories.add(category); } diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 9316352349..358a29054e 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -964,7 +964,7 @@ export class Translator { case 'pitch': { if (data.reading !== reading) { continue; } - /** @type {import('dictionary').TermPitch[]} */ + /** @type {import('dictionary').PitchAccent[]} */ const pitches = []; for (const {position, tags, nasal, devoice} of data.pitches) { /** @type {import('dictionary').Tag[]} */ @@ -974,7 +974,13 @@ export class Translator { } const nasalPositions = this._toNumberArray(nasal); const devoicePositions = this._toNumberArray(devoice); - pitches.push({position, nasalPositions, devoicePositions, tags: tags2}); + pitches.push({ + type: 'pitch-accent', + position, + nasalPositions, + devoicePositions, + tags: tags2 + }); } for (const {pronunciations, headwordIndex} of targets) { pronunciations.push(this._createTermPronunciation( @@ -991,7 +997,7 @@ export class Translator { case 'ipa': { if (data.reading !== reading) { continue; } - /** @type {import('dictionary').TermIPA[]} */ + /** @type {import('dictionary').IpaTranscription[]} */ const phoneticTranscriptions = []; for (const {ipa, tags} of data.transcriptions) { /** @type {import('dictionary').Tag[]} */ @@ -999,7 +1005,11 @@ export class Translator { if (Array.isArray(tags)) { tagAggregator.addTags(tags2, dictionary, tags); } - phoneticTranscriptions.push({ipa, tags: tags2}); + phoneticTranscriptions.push({ + type: 'phonetic-transcription', + ipa, + tags: tags2 + }); } for (const {pronunciations, headwordIndex} of targets) { pronunciations.push(this._createTermPronunciation( @@ -1008,7 +1018,6 @@ export class Translator { dictionary, dictionaryIndex, dictionaryPriority, - [], phoneticTranscriptions )); } @@ -1366,12 +1375,11 @@ export class Translator { * @param {string} dictionary * @param {number} dictionaryIndex * @param {number} dictionaryPriority - * @param {import('dictionary').TermPitch[]} pitches - * @param {import('dictionary').TermIPA[]} transcriptions + * @param {import('dictionary').Pronunciation[]} pronunciations * @returns {import('dictionary').TermPronunciation} */ - _createTermPronunciation(index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pitches, transcriptions) { - return {index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pitches, transcriptions}; + _createTermPronunciation(index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations) { + return {index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations}; } /** diff --git a/ext/js/pages/settings/anki-controller.js b/ext/js/pages/settings/anki-controller.js index 6f357680d0..aea94b652b 100644 --- a/ext/js/pages/settings/anki-controller.js +++ b/ext/js/pages/settings/anki-controller.js @@ -145,6 +145,7 @@ export class AnkiController { 'pitch-accents', 'pitch-accent-graphs', 'pitch-accent-positions', + 'phonetic-transcriptions', 'reading', 'screenshot', 'search-query', diff --git a/test/utilities/anki.js b/test/utilities/anki.js index 4b73f6b90a..aa6c83d289 100644 --- a/test/utilities/anki.js +++ b/test/utilities/anki.js @@ -75,6 +75,7 @@ function getFieldMarkers(type) { 'pitch-accents', 'pitch-accent-graphs', 'pitch-accent-positions', + 'phonetic-transcriptions', 'reading', 'screenshot', 'search-query', diff --git a/types/ext/anki-templates.d.ts b/types/ext/anki-templates.d.ts index 5c40f40633..1221ce17b2 100644 --- a/types/ext/anki-templates.d.ts +++ b/types/ext/anki-templates.d.ts @@ -76,6 +76,7 @@ export type NoteData = { readonly uniqueReadings: string[]; readonly pitches: PitchGroup[]; readonly pitchCount: number; + readonly phoneticTranscriptions: TranscriptionGroup[]; readonly context: Context; media: Media; readonly dictionaryEntry: Dictionary.DictionaryEntry; @@ -97,6 +98,20 @@ export type Pitch = { exclusiveReadings: string[]; }; +export type TranscriptionGroup = { + dictionary: string; + transcriptions: Transcription[]; +}; + +export type Transcription = { + expressions: string[]; + reading: string; + ipa: string; + tags: Dictionary.Tag[]; + exclusiveExpressions: string[]; + exclusiveReadings: string[]; +}; + /** * For legacy reasons, {@link Pitch} has a custom tag type that resembles {@link Dictionary.Tag}. */ @@ -175,7 +190,8 @@ export type TermDictionaryEntry = { readonly termTags?: Tag[]; readonly definitions?: TermDefinition[]; readonly frequencies: TermFrequency[]; - readonly pitches: TermPronunciation[]; + readonly pitches: TermPitchAccent[]; + readonly transcriptions: TermIpaTranscription[]; sourceTermExactMatchCount: number; url: string; readonly cloze: Cloze; @@ -225,7 +241,7 @@ export type TermFrequency = { frequency: number | string; }; -export type TermPronunciation = { +export type TermPitchAccent = { index: number; expressionIndex: number; dictionary: string; @@ -235,14 +251,32 @@ export type TermPronunciation = { }; expression: string; reading: string; - readonly pitches: TermPitch[]; + readonly pitches: PitchAccent[]; }; -export type TermPitch = { +export type PitchAccent = { position: number; tags: Tag[]; }; +export type TermIpaTranscription = { + index: number; + expressionIndex: number; + dictionary: string; + dictionaryOrder: { + index: number; + priority: number; + }; + expression: string; + reading: string; + readonly transcriptions: IpaTranscription[]; +}; + +export type IpaTranscription = { + ipa: string; + tags: Tag[]; +}; + export type TermFrequencyType = DictionaryDataUtil.TermFrequencyType; export type TermHeadword = { @@ -251,7 +285,7 @@ export type TermHeadword = { reading: string; readonly termTags: Tag[]; readonly frequencies: TermFrequency[]; - readonly pitches: TermPronunciation[]; + readonly pitches: TermPitchAccent[]; readonly furiganaSegments: FuriganaSegment[]; readonly termFrequency: TermFrequencyType; wordClasses: string[]; diff --git a/types/ext/dictionary-data-util.d.ts b/types/ext/dictionary-data-util.d.ts index 21a4a6e8e9..385171a47c 100644 --- a/types/ext/dictionary-data-util.d.ts +++ b/types/ext/dictionary-data-util.d.ts @@ -85,7 +85,7 @@ export type GroupedPronunciationInternal = GroupedPitchAccentInternal | GroupedI export type GroupedPitchAccent = { type: 'pitch-accent'; - terms: Set; + terms: string[]; reading: string; position: number; nasalPositions: number[]; @@ -97,7 +97,7 @@ export type GroupedPitchAccent = { export type GroupedIpa = { type: 'phonetic-transcription'; - terms: Set; + terms: string[]; reading: string; tags: Dictionary.Tag[]; ipa: string; diff --git a/types/ext/dictionary.d.ts b/types/ext/dictionary.d.ts index 35730c1cb5..2ec21a3ed6 100644 --- a/types/ext/dictionary.d.ts +++ b/types/ext/dictionary.d.ts @@ -365,19 +365,18 @@ export type TermPronunciation = { */ dictionaryPriority: number; /** - * The pitch accent representations for the term. + * The pronunciations for the term. */ - pitches: TermPitch[]; - /** - * The phonetic transcriptions for the term. - */ - transcriptions: TermIPA[]; + pronunciations: Pronunciation[]; }; +export type Pronunciation = PitchAccent | IpaTranscription; + /** * Pitch accent information for a term, represented as the position of the downstep. */ -export type TermPitch = { +export type PitchAccent = { + type: 'pitch-accent'; /** * Position of the downstep, as a number of mora. */ @@ -396,7 +395,8 @@ export type TermPitch = { tags: Tag[]; }; -export type TermIPA = { +export type IpaTranscription = { + type: 'phonetic-transcription'; /** * An IPA transcription. */ From d4e6a2b11e18ea85b066f56f3c06856282233b41 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sat, 23 Dec 2023 15:00:15 +0100 Subject: [PATCH 05/19] wip --- ext/data/schemas/dictionary-term-meta-bank-v3-schema.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ext/data/schemas/dictionary-term-meta-bank-v3-schema.json b/ext/data/schemas/dictionary-term-meta-bank-v3-schema.json index 1a8ac3b840..1401b1eb16 100644 --- a/ext/data/schemas/dictionary-term-meta-bank-v3-schema.json +++ b/ext/data/schemas/dictionary-term-meta-bank-v3-schema.json @@ -31,6 +31,7 @@ "type": "array", "description": "Metadata about a single term.", "minItems": 3, + "maxItems": 3, "additionalItems": false, "items": [ { @@ -48,6 +49,8 @@ ], "oneOf": [ { + "minItems": 3, + "maxItems": 3, "items": [ {}, {"const": "freq"}, @@ -80,6 +83,8 @@ ] }, { + "minItems": 3, + "maxItems": 3, "items": [ {}, {"const": "pitch"}, @@ -161,6 +166,8 @@ ] }, { + "minItems": 3, + "maxItems": 3, "items": [ {}, {"const": "ipa"}, From fdf21a6f3b4b100990a020561025a1034055253b Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sat, 23 Dec 2023 16:13:00 +0100 Subject: [PATCH 06/19] fixing comments wip --- .../default-anki-field-templates.handlebars | 4 ++-- ext/js/data/sandbox/anki-note-data-creator.js | 18 +++++++++--------- ext/js/language/translator.js | 2 +- types/ext/anki-templates.d.ts | 10 +++++----- types/ext/dictionary-data-util.d.ts | 8 ++++---- types/ext/dictionary-data.d.ts | 2 +- types/ext/dictionary-database.d.ts | 16 ++++++++-------- types/ext/dictionary.d.ts | 10 ++++++++-- 8 files changed, 38 insertions(+), 32 deletions(-) diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index 7785737ed2..e7fcf5ea93 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -231,8 +231,8 @@ {{#*inline "phonetic-transcriptions"}}
    - {{~#each definition.transcriptions~}} - {{~#each transcriptions~}} + {{~#each definition.phoneticTranscriptions~}} + {{~#each phoneticTranscriptions~}}
  • {{~set "any" false~}} {{~#each tags~}} diff --git a/ext/js/data/sandbox/anki-note-data-creator.js b/ext/js/data/sandbox/anki-note-data-creator.js index 624a334dc2..b078941f72 100644 --- a/ext/js/data/sandbox/anki-note-data-creator.js +++ b/ext/js/data/sandbox/anki-note-data-creator.js @@ -224,11 +224,11 @@ export class AnkiNoteDataCreator { const results = []; if (dictionaryEntry.type === 'term') { for (const {dictionary, pronunciations} of DictionaryDataUtil.getGroupedPronunciations(dictionaryEntry)) { - const transcriptions = []; + const phoneticTranscriptions = []; for (const pronunciation of pronunciations) { if (pronunciation.type !== 'phonetic-transcription') { continue; } const {terms, reading, ipa, tags, exclusiveTerms, exclusiveReadings} = pronunciation; - transcriptions.push({ + phoneticTranscriptions.push({ expressions: terms, reading, ipa, @@ -237,7 +237,7 @@ export class AnkiNoteDataCreator { exclusiveReadings }); } - results.push({dictionary, transcriptions}); + results.push({dictionary, phoneticTranscriptions}); } } return results; @@ -385,7 +385,7 @@ export class AnkiNoteDataCreator { const expressions = this.createCachedValue(this._getTermExpressions.bind(this, dictionaryEntry)); const frequencies = this.createCachedValue(this._getTermFrequencies.bind(this, dictionaryEntry)); const pitches = this.createCachedValue(this._getTermPitches.bind(this, dictionaryEntry)); - const transcriptions = this.createCachedValue(this._getTermPhoneticTranscriptions.bind(this, dictionaryEntry)); + const phoneticTranscriptions = this.createCachedValue(this._getTermPhoneticTranscriptions.bind(this, dictionaryEntry)); const glossary = this.createCachedValue(this._getTermGlossaryArray.bind(this, dictionaryEntry, type)); const cloze = this.createCachedValue(this._getCloze.bind(this, dictionaryEntry, context)); const furiganaSegments = this.createCachedValue(this._getTermFuriganaSegments.bind(this, dictionaryEntry, type)); @@ -422,7 +422,7 @@ export class AnkiNoteDataCreator { get definitions() { return self.getCachedValue(commonInfo).definitions; }, get frequencies() { return self.getCachedValue(frequencies); }, get pitches() { return self.getCachedValue(pitches); }, - get transcriptions() { return self.getCachedValue(transcriptions); }, + get phoneticTranscriptions() { return self.getCachedValue(phoneticTranscriptions); }, sourceTermExactMatchCount, url, get cloze() { return self.getCachedValue(cloze); }, @@ -567,7 +567,7 @@ export class AnkiNoteDataCreator { /** * @param {import('dictionary').TermDictionaryEntry} dictionaryEntry - * @returns {import('anki-templates').TermIpaTranscription[]} + * @returns {import('anki-templates').TermPhoneticTranscription[]} */ _getTermPhoneticTranscriptions(dictionaryEntry) { const results = []; @@ -586,7 +586,7 @@ export class AnkiNoteDataCreator { }, expression: term, reading, - get transcriptions() { return termPhoneticTranscriptions; } + get phoneticTranscriptions() { return termPhoneticTranscriptions; } }); } @@ -594,8 +594,8 @@ export class AnkiNoteDataCreator { } /** - * @param {import('dictionary').IpaTranscription[]} phoneticTranscriptions - * @returns {import('anki-templates').IpaTranscription[]} + * @param {import('dictionary').PhoneticTranscription[]} phoneticTranscriptions + * @returns {import('anki-templates').PhoneticTranscription[]} */ _getTermPhoneticTranscriptionsInner(phoneticTranscriptions) { // eslint-disable-next-line @typescript-eslint/no-this-alias diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 358a29054e..733955c248 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -997,7 +997,7 @@ export class Translator { case 'ipa': { if (data.reading !== reading) { continue; } - /** @type {import('dictionary').IpaTranscription[]} */ + /** @type {import('dictionary').PhoneticTranscription[]} */ const phoneticTranscriptions = []; for (const {ipa, tags} of data.transcriptions) { /** @type {import('dictionary').Tag[]} */ diff --git a/types/ext/anki-templates.d.ts b/types/ext/anki-templates.d.ts index 1221ce17b2..098873e622 100644 --- a/types/ext/anki-templates.d.ts +++ b/types/ext/anki-templates.d.ts @@ -100,7 +100,7 @@ export type Pitch = { export type TranscriptionGroup = { dictionary: string; - transcriptions: Transcription[]; + phoneticTranscriptions: Transcription[]; }; export type Transcription = { @@ -191,7 +191,7 @@ export type TermDictionaryEntry = { readonly definitions?: TermDefinition[]; readonly frequencies: TermFrequency[]; readonly pitches: TermPitchAccent[]; - readonly transcriptions: TermIpaTranscription[]; + readonly phoneticTranscriptions: TermPhoneticTranscription[]; sourceTermExactMatchCount: number; url: string; readonly cloze: Cloze; @@ -259,7 +259,7 @@ export type PitchAccent = { tags: Tag[]; }; -export type TermIpaTranscription = { +export type TermPhoneticTranscription = { index: number; expressionIndex: number; dictionary: string; @@ -269,10 +269,10 @@ export type TermIpaTranscription = { }; expression: string; reading: string; - readonly transcriptions: IpaTranscription[]; + readonly phoneticTranscriptions: PhoneticTranscription[]; }; -export type IpaTranscription = { +export type PhoneticTranscription = { ipa: string; tags: Tag[]; }; diff --git a/types/ext/dictionary-data-util.d.ts b/types/ext/dictionary-data-util.d.ts index 385171a47c..f952da620f 100644 --- a/types/ext/dictionary-data-util.d.ts +++ b/types/ext/dictionary-data-util.d.ts @@ -73,7 +73,7 @@ export type GroupedPitchAccentInternal = { tags: Dictionary.Tag[]; }; -export type GroupedIpaInternal = { +export type GroupedPhoneticTranscriptionInternal = { type: 'phonetic-transcription'; terms: Set; reading: string; @@ -81,7 +81,7 @@ export type GroupedIpaInternal = { ipa: string; }; -export type GroupedPronunciationInternal = GroupedPitchAccentInternal | GroupedIpaInternal; +export type GroupedPronunciationInternal = GroupedPitchAccentInternal | GroupedPhoneticTranscriptionInternal; export type GroupedPitchAccent = { type: 'pitch-accent'; @@ -95,7 +95,7 @@ export type GroupedPitchAccent = { exclusiveReadings: string[]; }; -export type GroupedIpa = { +export type GroupedPhoneticTranscription = { type: 'phonetic-transcription'; terms: string[]; reading: string; @@ -106,7 +106,7 @@ export type GroupedIpa = { }; -export type GroupedPronunciation = GroupedPitchAccent | GroupedIpa; +export type GroupedPronunciation = GroupedPitchAccent | GroupedPhoneticTranscription; export type DictionaryGroupedPronunciations = { dictionary: string; diff --git a/types/ext/dictionary-data.d.ts b/types/ext/dictionary-data.d.ts index 3c610d2587..4f7c447798 100644 --- a/types/ext/dictionary-data.d.ts +++ b/types/ext/dictionary-data.d.ts @@ -154,7 +154,7 @@ export type TermMetaPitch = [ data: TermMetaPitchData, ]; -export type TermMetaIpaData = { +export type TermMetaPhonetic = { reading: string; transcriptions: { ipa: string; diff --git a/types/ext/dictionary-database.d.ts b/types/ext/dictionary-database.d.ts index d9238b05a9..876ca5159a 100644 --- a/types/ext/dictionary-database.d.ts +++ b/types/ext/dictionary-database.d.ts @@ -102,7 +102,7 @@ export type Tag = { dictionary: string; }; -export type DatabaseTermMeta = DatabaseTermMetaFrequency | DatabaseTermMetaPitch | DatabaseTermMetaIpa; +export type DatabaseTermMeta = DatabaseTermMetaFrequency | DatabaseTermMetaPitch | DatabaseTermMetaPhonetic; export type DatabaseTermMetaFrequency = { expression: string; @@ -118,10 +118,10 @@ export type DatabaseTermMetaPitch = { dictionary: string; }; -export type DatabaseTermMetaIpa = { +export type DatabaseTermMetaPhonetic = { expression: string; mode: 'ipa'; - data: DictionaryData.TermMetaIpaData; + data: DictionaryData.TermMetaPhonetic; dictionary: string; }; @@ -130,7 +130,7 @@ export type TermMetaFrequencyDataWithReading = { frequency: DictionaryData.GenericFrequencyData; }; -export type TermMeta = TermMetaFrequency | TermMetaPitch | TermMetaIPA; +export type TermMeta = TermMetaFrequency | TermMetaPitch | TermMetaPhonetic; export type TermMetaType = TermMeta['mode']; @@ -143,18 +143,18 @@ export type TermMetaFrequency = { }; export type TermMetaPitch = { + mode: 'pitch'; index: number; term: string; - mode: 'pitch'; data: DictionaryData.TermMetaPitchData; dictionary: string; }; -export type TermMetaIPA = { +export type TermMetaPhonetic = { + mode: 'ipa'; index: number; term: string; - mode: 'ipa'; - data: DictionaryData.TermMetaIpaData; + data: DictionaryData.TermMetaPhonetic; dictionary: string; }; diff --git a/types/ext/dictionary.d.ts b/types/ext/dictionary.d.ts index 2ec21a3ed6..72b85d9e9a 100644 --- a/types/ext/dictionary.d.ts +++ b/types/ext/dictionary.d.ts @@ -370,12 +370,15 @@ export type TermPronunciation = { pronunciations: Pronunciation[]; }; -export type Pronunciation = PitchAccent | IpaTranscription; +export type Pronunciation = PitchAccent | PhoneticTranscription; /** * Pitch accent information for a term, represented as the position of the downstep. */ export type PitchAccent = { + /** + * Type of the pronunciation, for disambiguation between union type members. + */ type: 'pitch-accent'; /** * Position of the downstep, as a number of mora. @@ -395,7 +398,10 @@ export type PitchAccent = { tags: Tag[]; }; -export type IpaTranscription = { +export type PhoneticTranscription = { + /** + * Type of the pronunciation, for disambiguation between union type members. + */ type: 'phonetic-transcription'; /** * An IPA transcription. From f0d6fecd1e2988c97570beada02f6835bb3759ae Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sat, 23 Dec 2023 16:47:55 +0100 Subject: [PATCH 07/19] fixing comments wip --- ext/js/data/sandbox/anki-note-data-creator.js | 24 ++++- ext/js/dictionary/dictionary-data-util.js | 48 ++++++---- ext/js/display/display-generator.js | 88 +++++++++++-------- types/ext/dictionary.d.ts | 4 + 4 files changed, 105 insertions(+), 59 deletions(-) diff --git a/ext/js/data/sandbox/anki-note-data-creator.js b/ext/js/data/sandbox/anki-note-data-creator.js index b078941f72..0d2dbdad07 100644 --- a/ext/js/data/sandbox/anki-note-data-creator.js +++ b/ext/js/data/sandbox/anki-note-data-creator.js @@ -528,8 +528,7 @@ export class AnkiNoteDataCreator { const {headwords} = dictionaryEntry; for (const {headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations} of dictionaryEntry.pronunciations) { const {term, reading} = headwords[headwordIndex]; - /** @type {import('dictionary').PitchAccent[]} */ - const pitches = pronunciations.filter((v) => v.type === 'pitch-accent'); + const pitches = this._getPronunciationsOfType(pronunciations, 'pitch-accent'); const cachedPitches = this.createCachedValue(this._getTermPitchesInner.bind(this, pitches)); results.push({ index: results.length, @@ -574,7 +573,7 @@ export class AnkiNoteDataCreator { const {headwords} = dictionaryEntry; for (const {headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations} of dictionaryEntry.pronunciations) { const {term, reading} = headwords[headwordIndex]; - const phoneticTranscriptions = pronunciations.filter((v) => v.type === 'phonetic-transcription'); + const phoneticTranscriptions = this._getPronunciationsOfType(pronunciations, 'phonetic-transcription'); const termPhoneticTranscriptions = this._getTermPhoneticTranscriptionsInner(phoneticTranscriptions); results.push({ index: results.length, @@ -684,7 +683,7 @@ export class AnkiNoteDataCreator { for (const {headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations} of termPronunciations) { if (headwordIndex !== i) { continue; } const {term, reading} = headwords[headwordIndex]; - const pitches = pronunciations.filter((v) => v.type === 'pitch-accent'); + const pitches = this._getPronunciationsOfType(pronunciations, 'pitch-accent'); const cachedPitches = this.createCachedValue(this._getTermPitchesInner.bind(this, pitches)); results.push({ index: results.length, @@ -702,6 +701,23 @@ export class AnkiNoteDataCreator { return results; } + /** + * @template {import('dictionary').PronunciationType} T + * @param {import('dictionary').Pronunciation[]} pronunciations + * @param {T} type + * @returns {import('dictionary').PronunciationGeneric[]} + */ + _getPronunciationsOfType(pronunciations, type) { + /** @type {import('dictionary').PronunciationGeneric[]} */ + const results = []; + for (const pronunciation of pronunciations) { + if (pronunciation.type !== type) { continue; } + // This is type safe, but for some reason the cast is needed. + results.push(/** @type {import('dictionary').PronunciationGeneric} */ (pronunciation)); + } + return results; + } + /** * @param {import('anki-templates-internal').CachedValue} cachedTermTags * @returns {import('anki-templates').TermFrequencyType} diff --git a/ext/js/dictionary/dictionary-data-util.js b/ext/js/dictionary/dictionary-data-util.js index df4a7737d5..7fafa3988b 100644 --- a/ext/js/dictionary/dictionary-data-util.js +++ b/ext/js/dictionary/dictionary-data-util.js @@ -309,26 +309,38 @@ export class DictionaryDataUtil { * @returns {?import('dictionary-data-util').GroupedPronunciationInternal} */ static _findExistingGroupedPronunciation(reading, pronunciation, groupedPronunciationList) { - for (const groupedPronunciation of groupedPronunciationList) { - if ( - groupedPronunciation.reading === reading && - this._areTagListsEqual(groupedPronunciation.tags, pronunciation.tags) && - ( - pronunciation.type === 'pitch-accent' && - groupedPronunciation.type === 'pitch-accent' && - groupedPronunciation.position === pronunciation.position && - this._areArraysEqual(groupedPronunciation.nasalPositions, pronunciation.nasalPositions) && - this._areArraysEqual(groupedPronunciation.devoicePositions, pronunciation.devoicePositions) - || - pronunciation.type === 'phonetic-transcription' && - groupedPronunciation.type === 'phonetic-transcription' && - groupedPronunciation.ipa === pronunciation.ipa - ) - ) { - return groupedPronunciation; + const existingGroupedPronunciation = groupedPronunciationList.find((groupedPronunciation) => { + return groupedPronunciation.reading === reading && this._arePronunciationsEquivalent(groupedPronunciation, pronunciation); + }); + + return existingGroupedPronunciation || null; + } + + /** + * @param {import('dictionary-data-util').GroupedPronunciationInternal} groupedPronunciation + * @param {import('dictionary').Pronunciation} pronunciation + * @returns {boolean} + */ + static _arePronunciationsEquivalent(groupedPronunciation, pronunciation) { + if (!this._areTagListsEqual(groupedPronunciation.tags, pronunciation.tags)) { + return false; + } + + if (pronunciation.type === 'pitch-accent' && groupedPronunciation.type === 'pitch-accent') { + if (groupedPronunciation.position !== pronunciation.position || + !this._areArraysEqual(groupedPronunciation.nasalPositions, pronunciation.nasalPositions) || + !this._areArraysEqual(groupedPronunciation.devoicePositions, pronunciation.devoicePositions)) { + return false; + } + } else if (pronunciation.type === 'phonetic-transcription' && groupedPronunciation.type === 'phonetic-transcription') { + if (groupedPronunciation.ipa !== pronunciation.ipa) { + return false; } + } else { + return false; } - return null; + + return true; } /** diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 9cfcf04723..3d4934c891 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -640,61 +640,75 @@ export class DisplayGenerator { * @returns {HTMLElement} */ _createPronunciation(details) { - const jp = this._japaneseUtil; - switch (details.type) { - case 'pitch-accent': { - const {reading, position, nasalPositions, devoicePositions, tags, exclusiveTerms, exclusiveReadings} = details; - const morae = jp.getKanaMorae(reading); + case 'pitch-accent': + return this._createPronunciationPitchAccent(details); + case 'phonetic-transcription': + return this._createPronunciationPhoneticTranscription(details); + } + } - const node = this._instantiate('pronunciation'); - node.dataset.pitchAccentDownstepPosition = `${position}`; - if (nasalPositions.length > 0) { node.dataset.nasalMoraPosition = nasalPositions.join(' '); } - if (devoicePositions.length > 0) { node.dataset.devoiceMoraPosition = devoicePositions.join(' '); } - node.dataset.tagCount = `${tags.length}`; + /** + * @param {import('dictionary-data-util').GroupedPhoneticTranscription} details + * @returns {HTMLElement} + */ + _createPronunciationPhoneticTranscription(details) { + const {ipa, tags, exclusiveTerms, exclusiveReadings} = details; - let n = this._querySelector(node, '.pronunciation-tag-list'); - this._appendMultiple(n, this._createTag.bind(this), tags); + const node = this._instantiate('pronunciation'); - n = this._querySelector(node, '.pronunciation-disambiguation-list'); - this._createPronunciationDisambiguations(n, exclusiveTerms, exclusiveReadings); + node.dataset.tagCount = `${tags.length}`; - n = this._querySelector(node, '.pronunciation-downstep-notation-container'); - n.appendChild(this._pronunciationGenerator.createPronunciationDownstepPosition(position)); + let n = this._querySelector(node, '.pronunciation-tag-list'); + this._appendMultiple(n, this._createTag.bind(this), tags); - n = this._querySelector(node, '.pronunciation-text-container'); + n = this._querySelector(node, '.pronunciation-disambiguation-list'); + this._createPronunciationDisambiguations(n, exclusiveTerms, exclusiveReadings); - n.lang = 'ja'; - n.appendChild(this._pronunciationGenerator.createPronunciationText(morae, position, nasalPositions, devoicePositions)); + n = this._querySelector(node, '.pronunciation-text-container'); - n = this._querySelector(node, '.pronunciation-graph-container'); - n.appendChild(this._pronunciationGenerator.createPronunciationGraph(morae, position)); + this._setTextContent(n, ipa); - return node; - } - case 'phonetic-transcription': { - const {ipa, tags, exclusiveTerms, exclusiveReadings} = details; + return node; + } + + /** + * @param {import('dictionary-data-util').GroupedPitchAccent} details + * @returns {HTMLElement} + */ + _createPronunciationPitchAccent(details) { + const jp = this._japaneseUtil; - const node = this._instantiate('pronunciation'); + const {reading, position, nasalPositions, devoicePositions, tags, exclusiveTerms, exclusiveReadings} = details; + const morae = jp.getKanaMorae(reading); - node.dataset.tagCount = `${tags.length}`; + const node = this._instantiate('pronunciation'); - let n = this._querySelector(node, '.pronunciation-tag-list'); - this._appendMultiple(n, this._createTag.bind(this), tags); + node.dataset.pitchAccentDownstepPosition = `${position}`; + if (nasalPositions.length > 0) { node.dataset.nasalMoraPosition = nasalPositions.join(' '); } + if (devoicePositions.length > 0) { node.dataset.devoiceMoraPosition = devoicePositions.join(' '); } + node.dataset.tagCount = `${tags.length}`; - n = this._querySelector(node, '.pronunciation-disambiguation-list'); - this._createPronunciationDisambiguations(n, exclusiveTerms, exclusiveReadings); + let n = this._querySelector(node, '.pronunciation-tag-list'); + this._appendMultiple(n, this._createTag.bind(this), tags); - n = this._querySelector(node, '.pronunciation-text-container'); + n = this._querySelector(node, '.pronunciation-disambiguation-list'); + this._createPronunciationDisambiguations(n, exclusiveTerms, exclusiveReadings); - this._setTextContent(n, ipa); + n = this._querySelector(node, '.pronunciation-downstep-notation-container'); + n.appendChild(this._pronunciationGenerator.createPronunciationDownstepPosition(position)); - return node; - } - } - } + n = this._querySelector(node, '.pronunciation-text-container'); + + n.lang = 'ja'; + n.appendChild(this._pronunciationGenerator.createPronunciationText(morae, position, nasalPositions, devoicePositions)); + + n = this._querySelector(node, '.pronunciation-graph-container'); + n.appendChild(this._pronunciationGenerator.createPronunciationGraph(morae, position)); + return node; + } /** * @param {HTMLElement} container diff --git a/types/ext/dictionary.d.ts b/types/ext/dictionary.d.ts index 72b85d9e9a..7c348e7f5d 100644 --- a/types/ext/dictionary.d.ts +++ b/types/ext/dictionary.d.ts @@ -413,6 +413,10 @@ export type PhoneticTranscription = { tags: Tag[]; }; +export type PronunciationType = Pronunciation['type']; + +export type PronunciationGeneric = Extract; + /** * Frequency information corresponds to how frequently a term appears in a corpus, * which can be a number of occurrences or an overall rank. From af7755ea63bf12e1841ca43a1580d6022f48542a Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sat, 23 Dec 2023 17:00:08 +0100 Subject: [PATCH 08/19] fixing comments wip --- ext/js/data/sandbox/anki-note-data-creator.js | 23 +++---------------- ext/js/dictionary/dictionary-data-util.js | 17 ++++++++++++++ ext/js/display/display-generator.js | 8 +++---- .../sandbox/anki-template-renderer.js | 5 ++-- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/ext/js/data/sandbox/anki-note-data-creator.js b/ext/js/data/sandbox/anki-note-data-creator.js index 0d2dbdad07..e4e0b64d9a 100644 --- a/ext/js/data/sandbox/anki-note-data-creator.js +++ b/ext/js/data/sandbox/anki-note-data-creator.js @@ -528,7 +528,7 @@ export class AnkiNoteDataCreator { const {headwords} = dictionaryEntry; for (const {headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations} of dictionaryEntry.pronunciations) { const {term, reading} = headwords[headwordIndex]; - const pitches = this._getPronunciationsOfType(pronunciations, 'pitch-accent'); + const pitches = DictionaryDataUtil.getPronunciationsOfType(pronunciations, 'pitch-accent'); const cachedPitches = this.createCachedValue(this._getTermPitchesInner.bind(this, pitches)); results.push({ index: results.length, @@ -573,7 +573,7 @@ export class AnkiNoteDataCreator { const {headwords} = dictionaryEntry; for (const {headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations} of dictionaryEntry.pronunciations) { const {term, reading} = headwords[headwordIndex]; - const phoneticTranscriptions = this._getPronunciationsOfType(pronunciations, 'phonetic-transcription'); + const phoneticTranscriptions = DictionaryDataUtil.getPronunciationsOfType(pronunciations, 'phonetic-transcription'); const termPhoneticTranscriptions = this._getTermPhoneticTranscriptionsInner(phoneticTranscriptions); results.push({ index: results.length, @@ -683,7 +683,7 @@ export class AnkiNoteDataCreator { for (const {headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations} of termPronunciations) { if (headwordIndex !== i) { continue; } const {term, reading} = headwords[headwordIndex]; - const pitches = this._getPronunciationsOfType(pronunciations, 'pitch-accent'); + const pitches = DictionaryDataUtil.getPronunciationsOfType(pronunciations, 'pitch-accent'); const cachedPitches = this.createCachedValue(this._getTermPitchesInner.bind(this, pitches)); results.push({ index: results.length, @@ -701,23 +701,6 @@ export class AnkiNoteDataCreator { return results; } - /** - * @template {import('dictionary').PronunciationType} T - * @param {import('dictionary').Pronunciation[]} pronunciations - * @param {T} type - * @returns {import('dictionary').PronunciationGeneric[]} - */ - _getPronunciationsOfType(pronunciations, type) { - /** @type {import('dictionary').PronunciationGeneric[]} */ - const results = []; - for (const pronunciation of pronunciations) { - if (pronunciation.type !== type) { continue; } - // This is type safe, but for some reason the cast is needed. - results.push(/** @type {import('dictionary').PronunciationGeneric} */ (pronunciation)); - } - return results; - } - /** * @param {import('anki-templates-internal').CachedValue} cachedTermTags * @returns {import('anki-templates').TermFrequencyType} diff --git a/ext/js/dictionary/dictionary-data-util.js b/ext/js/dictionary/dictionary-data-util.js index 7fafa3988b..f889b8d06f 100644 --- a/ext/js/dictionary/dictionary-data-util.js +++ b/ext/js/dictionary/dictionary-data-util.js @@ -215,6 +215,23 @@ export class DictionaryDataUtil { return results2; } + /** + * @template {import('dictionary').PronunciationType} T + * @param {import('dictionary').Pronunciation[]} pronunciations + * @param {T} type + * @returns {import('dictionary').PronunciationGeneric[]} + */ + static getPronunciationsOfType(pronunciations, type) { + /** @type {import('dictionary').PronunciationGeneric[]} */ + const results = []; + for (const pronunciation of pronunciations) { + if (pronunciation.type !== type) { continue; } + // This is type safe, but for some reason the cast is needed. + results.push(/** @type {import('dictionary').PronunciationGeneric} */ (pronunciation)); + } + return results; + } + /** * @param {import('dictionary').Tag[]|import('anki-templates').Tag[]} termTags * @returns {import('dictionary-data-util').TermFrequencyType} diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 3d4934c891..393092a595 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -989,17 +989,17 @@ export class DisplayGenerator { /** * @param {string} reading - * @param {import('dictionary').TermPronunciation[]} termPronounciations + * @param {import('dictionary').TermPronunciation[]} termPronunciations * @param {string[]} wordClasses * @param {number} headwordIndex * @returns {?string} */ - _getPronunciationCategories(reading, termPronounciations, wordClasses, headwordIndex) { - if (termPronounciations.length === 0) { return null; } + _getPronunciationCategories(reading, termPronunciations, wordClasses, headwordIndex) { + if (termPronunciations.length === 0) { return null; } const isVerbOrAdjective = DictionaryDataUtil.isNonNounVerbOrAdjective(wordClasses); /** @type {Set} */ const categories = new Set(); - for (const termPronunciation of termPronounciations) { + for (const termPronunciation of termPronunciations) { if (termPronunciation.headwordIndex !== headwordIndex) { continue; } for (const pronunciation of termPronunciation.pronunciations) { if (pronunciation.type !== 'pitch-accent'){ continue; } diff --git a/ext/js/templates/sandbox/anki-template-renderer.js b/ext/js/templates/sandbox/anki-template-renderer.js index d69c7b476b..c8922b2cc0 100644 --- a/ext/js/templates/sandbox/anki-template-renderer.js +++ b/ext/js/templates/sandbox/anki-template-renderer.js @@ -543,12 +543,13 @@ export class AnkiTemplateRenderer { const [data] = /** @type {[data: import('anki-templates').NoteData]} */ (args); const {dictionaryEntry} = data; if (dictionaryEntry.type !== 'term') { return []; } - const {pronunciations, headwords} = dictionaryEntry; + const {pronunciations: termPronunciations, headwords} = dictionaryEntry; /** @type {Set} */ const categories = new Set(); - for (const {headwordIndex, pitches} of pronunciations) { + for (const {headwordIndex, pronunciations} of termPronunciations) { const {reading, wordClasses} = headwords[headwordIndex]; const isVerbOrAdjective = DictionaryDataUtil.isNonNounVerbOrAdjective(wordClasses); + const pitches = DictionaryDataUtil.getPronunciationsOfType(pronunciations, 'pitch-accent'); for (const {position} of pitches) { const category = this._japaneseUtil.getPitchCategory(reading, position, isVerbOrAdjective); if (category !== null) { From e5b91f0c6d11c4cff93341d61a8ae3331e2de98f Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sun, 24 Dec 2023 19:25:46 +0100 Subject: [PATCH 09/19] fixing comments wip --- .gitignore | 1 + .../default-anki-field-templates.handlebars | 32 +++++----- ext/js/dictionary/dictionary-data-util.js | 60 +++++++------------ ext/js/display/display-generator.js | 25 ++++---- types/ext/dictionary-data-util.d.ts | 39 ++---------- 5 files changed, 57 insertions(+), 100 deletions(-) diff --git a/.gitignore b/.gitignore index 459af2b711..79aff0f6c1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ node_modules/ builds/ dictionaries/ +dict/ /test-results/ /playwright-report/ diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index e7fcf5ea93..4012c05bc6 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -230,22 +230,24 @@ {{! End Pitch Accents }} {{#*inline "phonetic-transcriptions"}} -
      - {{~#each definition.phoneticTranscriptions~}} - {{~#each phoneticTranscriptions~}} -
    • - {{~set "any" false~}} - {{~#each tags~}} - {{~#if (get "any")}}, {{else}}({{/if~}} - {{name}} - {{~set "any" true~}} - {{~/each~}} - {{~#if (get "any")}}) {{/if~}} - {{ipa}} -
    • + {{~#if (op ">" definition.phoneticTranscriptions.length 0)~}} +
        + {{~#each definition.phoneticTranscriptions~}} + {{~#each phoneticTranscriptions~}} +
      • + {{~set "any" false~}} + {{~#each tags~}} + {{~#if (get "any")}}, {{else}}({{/if~}} + {{name}} + {{~set "any" true~}} + {{~/each~}} + {{~#if (get "any")}}) {{/if~}} + {{ipa}} +
      • + {{~/each~}} {{~/each~}} - {{~/each~}} -
      +
    + {{~/if~}} {{/inline}} {{#*inline "clipboard-image"}} diff --git a/ext/js/dictionary/dictionary-data-util.js b/ext/js/dictionary/dictionary-data-util.js index f889b8d06f..091c3a6dcb 100644 --- a/ext/js/dictionary/dictionary-data-util.js +++ b/ext/js/dictionary/dictionary-data-util.js @@ -157,7 +157,7 @@ export class DictionaryDataUtil { let groupedPronunciation = this._findExistingGroupedPronunciation(reading, pronunciation, dictionaryGroupedPronunciationList); if (groupedPronunciation === null) { groupedPronunciation = { - ...pronunciation, + pronunciation, terms: new Set(), reading }; @@ -174,42 +174,21 @@ export class DictionaryDataUtil { /** @type {import('dictionary-data-util').GroupedPronunciation[]} */ const pronunciations2 = []; for (const groupedPronunciation of dictionaryGroupedPronunciationList) { - const {terms, reading} = groupedPronunciation; + const {pronunciation, terms, reading} = groupedPronunciation; const exclusiveTerms = !this._areSetsEqual(terms, allTerms) ? this._getSetIntersection(terms, allTerms) : []; const exclusiveReadings = []; if (multipleReadings) { exclusiveReadings.push(reading); } - switch (groupedPronunciation.type) { - case 'pitch-accent': { - const {position, nasalPositions, devoicePositions, tags} = groupedPronunciation; - pronunciations2.push({ - type: 'pitch-accent', - terms: [...terms], - reading, - position, - nasalPositions, - devoicePositions, - tags, - exclusiveTerms, - exclusiveReadings - }); - break; - } case 'phonetic-transcription': { - const {ipa, tags} = groupedPronunciation; - pronunciations2.push({ - type: 'phonetic-transcription', - terms: [...terms], - reading, - ipa, - tags, - exclusiveTerms, - exclusiveReadings - }); - break; - } - } + pronunciations2.push({ + pronunciation, + terms: [...terms], + reading, + exclusiveTerms, + exclusiveReadings + }); } + results2.push({dictionary, pronunciations: pronunciations2}); } return results2; @@ -335,22 +314,23 @@ export class DictionaryDataUtil { /** * @param {import('dictionary-data-util').GroupedPronunciationInternal} groupedPronunciation - * @param {import('dictionary').Pronunciation} pronunciation + * @param {import('dictionary').Pronunciation} pronunciation2 * @returns {boolean} */ - static _arePronunciationsEquivalent(groupedPronunciation, pronunciation) { - if (!this._areTagListsEqual(groupedPronunciation.tags, pronunciation.tags)) { + static _arePronunciationsEquivalent({pronunciation: pronunciation1}, pronunciation2) { + if (!this._areTagListsEqual(pronunciation1.tags, pronunciation2.tags)) { return false; } + if (pronunciation1.type !== pronunciation2.type) { return false; } - if (pronunciation.type === 'pitch-accent' && groupedPronunciation.type === 'pitch-accent') { - if (groupedPronunciation.position !== pronunciation.position || - !this._areArraysEqual(groupedPronunciation.nasalPositions, pronunciation.nasalPositions) || - !this._areArraysEqual(groupedPronunciation.devoicePositions, pronunciation.devoicePositions)) { + if (pronunciation1.type === 'pitch-accent' && pronunciation2.type === 'pitch-accent') { + if (pronunciation1.position !== pronunciation2.position || + !this._areArraysEqual(pronunciation1.nasalPositions, pronunciation2.nasalPositions) || + !this._areArraysEqual(pronunciation1.devoicePositions, pronunciation2.devoicePositions)) { return false; } - } else if (pronunciation.type === 'phonetic-transcription' && groupedPronunciation.type === 'phonetic-transcription') { - if (groupedPronunciation.ipa !== pronunciation.ipa) { + } else if (pronunciation2.type === 'phonetic-transcription' && pronunciation1.type === 'phonetic-transcription') { + if (pronunciation1.ipa !== pronunciation2.ipa) { return false; } } else { diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 393092a595..5ad1445e5d 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -621,7 +621,7 @@ export class DisplayGenerator { n1.appendChild(tag); let hasTags = false; - for (const {tags} of pronunciations) { + for (const {pronunciation: {tags}} of pronunciations) { if (tags.length > 0) { hasTags = true; break; @@ -640,21 +640,24 @@ export class DisplayGenerator { * @returns {HTMLElement} */ _createPronunciation(details) { - switch (details.type) { + const {pronunciation} = details; + switch (pronunciation.type) { case 'pitch-accent': - return this._createPronunciationPitchAccent(details); + return this._createPronunciationPitchAccent(pronunciation, details); case 'phonetic-transcription': - return this._createPronunciationPhoneticTranscription(details); + return this._createPronunciationPhoneticTranscription(pronunciation, details); } } /** - * @param {import('dictionary-data-util').GroupedPhoneticTranscription} details + * @param {import('dictionary').PhoneticTranscription} pronunciation + * @param {import('dictionary-data-util').GroupedPronunciation} details * @returns {HTMLElement} */ - _createPronunciationPhoneticTranscription(details) { - const {ipa, tags, exclusiveTerms, exclusiveReadings} = details; + _createPronunciationPhoneticTranscription(pronunciation, details) { + const {ipa, tags} = pronunciation; + const {exclusiveTerms, exclusiveReadings} = details; const node = this._instantiate('pronunciation'); @@ -674,13 +677,15 @@ export class DisplayGenerator { } /** - * @param {import('dictionary-data-util').GroupedPitchAccent} details + * @param {import('dictionary').PitchAccent} pitchAccent + * @param {import('dictionary-data-util').GroupedPronunciation} details * @returns {HTMLElement} */ - _createPronunciationPitchAccent(details) { + _createPronunciationPitchAccent(pitchAccent, details) { const jp = this._japaneseUtil; - const {reading, position, nasalPositions, devoicePositions, tags, exclusiveTerms, exclusiveReadings} = details; + const {position, nasalPositions, devoicePositions, tags} = pitchAccent; + const {reading, exclusiveTerms, exclusiveReadings} = details; const morae = jp.getKanaMorae(reading); const node = this._instantiate('pronunciation'); diff --git a/types/ext/dictionary-data-util.d.ts b/types/ext/dictionary-data-util.d.ts index f952da620f..4ab06f11b8 100644 --- a/types/ext/dictionary-data-util.d.ts +++ b/types/ext/dictionary-data-util.d.ts @@ -63,51 +63,20 @@ export type KanjiFrequency = { export type TermFrequencyType = 'popular' | 'rare' | 'normal'; -export type GroupedPitchAccentInternal = { - type: 'pitch-accent'; +export type GroupedPronunciationInternal = { + pronunciation: Dictionary.Pronunciation; terms: Set; reading: string; - position: number; - nasalPositions: number[]; - devoicePositions: number[]; - tags: Dictionary.Tag[]; }; -export type GroupedPhoneticTranscriptionInternal = { - type: 'phonetic-transcription'; - terms: Set; - reading: string; - tags: Dictionary.Tag[]; - ipa: string; -}; - -export type GroupedPronunciationInternal = GroupedPitchAccentInternal | GroupedPhoneticTranscriptionInternal; - -export type GroupedPitchAccent = { - type: 'pitch-accent'; +export type GroupedPronunciation = { + pronunciation: Dictionary.Pronunciation; terms: string[]; reading: string; - position: number; - nasalPositions: number[]; - devoicePositions: number[]; - tags: Dictionary.Tag[]; exclusiveTerms: string[]; exclusiveReadings: string[]; }; -export type GroupedPhoneticTranscription = { - type: 'phonetic-transcription'; - terms: string[]; - reading: string; - tags: Dictionary.Tag[]; - ipa: string; - exclusiveTerms: string[]; - exclusiveReadings: string[]; -}; - - -export type GroupedPronunciation = GroupedPitchAccent | GroupedPhoneticTranscription; - export type DictionaryGroupedPronunciations = { dictionary: string; pronunciations: GroupedPronunciation[]; From 88364d8aac5494835b57506cf36f23ae40514f92 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sun, 24 Dec 2023 19:29:44 +0100 Subject: [PATCH 10/19] fixing comments wip --- ext/js/data/sandbox/anki-note-data-creator.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ext/js/data/sandbox/anki-note-data-creator.js b/ext/js/data/sandbox/anki-note-data-creator.js index e4e0b64d9a..c0a1186980 100644 --- a/ext/js/data/sandbox/anki-note-data-creator.js +++ b/ext/js/data/sandbox/anki-note-data-creator.js @@ -196,9 +196,11 @@ export class AnkiNoteDataCreator { for (const {dictionary, pronunciations} of DictionaryDataUtil.getGroupedPronunciations(dictionaryEntry)) { /** @type {import('anki-templates').Pitch[]} */ const pitches = []; - for (const pronunciation of pronunciations) { + for (const groupedPronunciation of pronunciations) { + const {pronunciation} = groupedPronunciation; if (pronunciation.type !== 'pitch-accent') { continue; } - const {terms, reading, position, nasalPositions, devoicePositions, tags, exclusiveTerms, exclusiveReadings} = pronunciation; + const {position, nasalPositions, devoicePositions, tags} = pronunciation; + const {terms, reading, exclusiveTerms, exclusiveReadings} = groupedPronunciation; pitches.push({ expressions: terms, reading, @@ -225,9 +227,11 @@ export class AnkiNoteDataCreator { if (dictionaryEntry.type === 'term') { for (const {dictionary, pronunciations} of DictionaryDataUtil.getGroupedPronunciations(dictionaryEntry)) { const phoneticTranscriptions = []; - for (const pronunciation of pronunciations) { + for (const groupedPronunciation of pronunciations) { + const {pronunciation} = groupedPronunciation; if (pronunciation.type !== 'phonetic-transcription') { continue; } - const {terms, reading, ipa, tags, exclusiveTerms, exclusiveReadings} = pronunciation; + const {ipa, tags} = pronunciation; + const {terms, reading, exclusiveTerms, exclusiveReadings} = groupedPronunciation; phoneticTranscriptions.push({ expressions: terms, reading, From 390ec81bbe9431a7092dad1de14ade4227721f2d Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sun, 24 Dec 2023 19:41:05 +0100 Subject: [PATCH 11/19] fixing comments wip --- ext/js/dictionary/dictionary-data-util.js | 36 ++++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/ext/js/dictionary/dictionary-data-util.js b/ext/js/dictionary/dictionary-data-util.js index 091c3a6dcb..0b6eff8fce 100644 --- a/ext/js/dictionary/dictionary-data-util.js +++ b/ext/js/dictionary/dictionary-data-util.js @@ -318,24 +318,32 @@ export class DictionaryDataUtil { * @returns {boolean} */ static _arePronunciationsEquivalent({pronunciation: pronunciation1}, pronunciation2) { - if (!this._areTagListsEqual(pronunciation1.tags, pronunciation2.tags)) { + if (pronunciation1.type !== pronunciation2.type) { return false; } - if (pronunciation1.type !== pronunciation2.type) { return false; } - - if (pronunciation1.type === 'pitch-accent' && pronunciation2.type === 'pitch-accent') { - if (pronunciation1.position !== pronunciation2.position || - !this._areArraysEqual(pronunciation1.nasalPositions, pronunciation2.nasalPositions) || - !this._areArraysEqual(pronunciation1.devoicePositions, pronunciation2.devoicePositions)) { - return false; - } - } else if (pronunciation2.type === 'phonetic-transcription' && pronunciation1.type === 'phonetic-transcription') { - if (pronunciation1.ipa !== pronunciation2.ipa) { - return false; - } - } else { + if (!this._areTagListsEqual(pronunciation1.tags, pronunciation2.tags)) { return false; } + switch (pronunciation1.type) { + case 'pitch-accent': + if ( + pronunciation2.type === 'pitch-accent' && + (pronunciation1.position !== pronunciation2.position || + !this._areArraysEqual(pronunciation1.nasalPositions, pronunciation2.nasalPositions) || + !this._areArraysEqual(pronunciation1.devoicePositions, pronunciation2.devoicePositions)) + ) { + return false; + } + break; + case 'phonetic-transcription': + if ( + pronunciation2.type === 'phonetic-transcription' && + pronunciation1.ipa !== pronunciation2.ipa + ) { + return false; + } + break; + } return true; } From 15b2a348f63e3de30d94d643eee055906f8604e1 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sun, 24 Dec 2023 22:49:31 +0100 Subject: [PATCH 12/19] fix comments --- ext/js/dictionary/dictionary-data-util.js | 39 +++++++++++------------ 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/ext/js/dictionary/dictionary-data-util.js b/ext/js/dictionary/dictionary-data-util.js index 0b6eff8fce..50ae4b1194 100644 --- a/ext/js/dictionary/dictionary-data-util.js +++ b/ext/js/dictionary/dictionary-data-util.js @@ -318,33 +318,30 @@ export class DictionaryDataUtil { * @returns {boolean} */ static _arePronunciationsEquivalent({pronunciation: pronunciation1}, pronunciation2) { - if (pronunciation1.type !== pronunciation2.type) { - return false; - } - if (!this._areTagListsEqual(pronunciation1.tags, pronunciation2.tags)) { + if ( + pronunciation1.type !== pronunciation2.type || + !this._areTagListsEqual(pronunciation1.tags, pronunciation2.tags) + ) { return false; } switch (pronunciation1.type) { case 'pitch-accent': - if ( - pronunciation2.type === 'pitch-accent' && - (pronunciation1.position !== pronunciation2.position || - !this._areArraysEqual(pronunciation1.nasalPositions, pronunciation2.nasalPositions) || - !this._areArraysEqual(pronunciation1.devoicePositions, pronunciation2.devoicePositions)) - ) { - return false; - } - break; + { + // This cast is valid based on the type check at the start of the function. + const pitchAccent2 = /** @type {import('dictionary').PitchAccent} */ (pronunciation2); + return ( + pronunciation1.position === pitchAccent2.position && + this._areArraysEqual(pronunciation1.nasalPositions, pitchAccent2.nasalPositions) && + this._areArraysEqual(pronunciation1.devoicePositions, pitchAccent2.devoicePositions) + ); + } case 'phonetic-transcription': - if ( - pronunciation2.type === 'phonetic-transcription' && - pronunciation1.ipa !== pronunciation2.ipa - ) { - return false; - } - break; + { + // This cast is valid based on the type check at the start of the function. + const phoneticTranscription2 = /** @type {import('dictionary').PhoneticTranscription} */ (pronunciation2); + return pronunciation1.ipa === phoneticTranscription2.ipa; + } } - return true; } From f6922c654e20d8b69366e44f100e079a1618a2c7 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sun, 24 Dec 2023 23:05:13 +0100 Subject: [PATCH 13/19] fix comments --- ext/js/display/display-generator.js | 2 +- types/ext/dictionary-database.d.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 5ad1445e5d..de1321186c 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -1007,7 +1007,7 @@ export class DisplayGenerator { for (const termPronunciation of termPronunciations) { if (termPronunciation.headwordIndex !== headwordIndex) { continue; } for (const pronunciation of termPronunciation.pronunciations) { - if (pronunciation.type !== 'pitch-accent'){ continue; } + if (pronunciation.type !== 'pitch-accent') { continue; } const category = this._japaneseUtil.getPitchCategory(reading, pronunciation.position, isVerbOrAdjective); if (category !== null) { categories.add(category); diff --git a/types/ext/dictionary-database.d.ts b/types/ext/dictionary-database.d.ts index 876ca5159a..f1d01e0d44 100644 --- a/types/ext/dictionary-database.d.ts +++ b/types/ext/dictionary-database.d.ts @@ -158,7 +158,6 @@ export type TermMetaPhonetic = { dictionary: string; }; - export type DatabaseKanjiMeta = DatabaseKanjiMetaFrequency; export type DatabaseKanjiMetaFrequency = { From 593df6b3ec7a73ffd672061a93fa782525ce7559 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sun, 24 Dec 2023 23:12:11 +0100 Subject: [PATCH 14/19] update test data --- test/data/anki-note-builder-test-results.json | 85 +++ .../translator-test-results-note-data1.json | 718 ++++++++++++++++++ test/data/translator-test-results.json | 121 ++- 3 files changed, 893 insertions(+), 31 deletions(-) diff --git a/test/data/anki-note-builder-test-results.json b/test/data/anki-note-builder-test-results.json index 49542e39db..766d8e2159 100644 --- a/test/data/anki-note-builder-test-results.json +++ b/test/data/anki-note-builder-test-results.json @@ -79,6 +79,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "だ", "screenshot": "", "search-query": "fullQuery", @@ -109,6 +110,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ダース", "screenshot": "", "search-query": "fullQuery", @@ -144,6 +146,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ", "screenshot": "", "search-query": "fullQuery", @@ -174,6 +177,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -204,6 +208,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ", "screenshot": "", "search-query": "fullQuery", @@ -234,6 +239,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -264,6 +270,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "だ", "screenshot": "", "search-query": "fullQuery", @@ -294,6 +301,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ダース", "screenshot": "", "search-query": "fullQuery", @@ -329,6 +337,7 @@ "pitch-accents": "
    ", "pitch-accent-graphs": "
    ", "pitch-accent-positions": "
    1. [0]
    2. [3]
    ", + "phonetic-transcriptions": "
      ", "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", @@ -359,6 +368,7 @@ "pitch-accents": "
      ", "pitch-accent-graphs": "
      ", "pitch-accent-positions": "
      1. [0]
      2. [3]
      ", + "phonetic-transcriptions": "
        ", "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", @@ -389,6 +399,7 @@ "pitch-accents": "
        ", "pitch-accent-graphs": "
        ", "pitch-accent-positions": "
        1. [0]
        2. [3]
        ", + "phonetic-transcriptions": "
          ", "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", @@ -419,6 +430,7 @@ "pitch-accents": "
          ", "pitch-accent-graphs": "
          ", "pitch-accent-positions": "
          1. [0]
          2. [3]
          ", + "phonetic-transcriptions": "
            ", "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", @@ -449,6 +461,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ", "screenshot": "", "search-query": "fullQuery", @@ -479,6 +492,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -509,6 +523,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ", "screenshot": "", "search-query": "fullQuery", @@ -539,6 +554,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -569,6 +585,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "だ", "screenshot": "", "search-query": "fullQuery", @@ -599,6 +616,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ダース", "screenshot": "", "search-query": "fullQuery", @@ -634,6 +652,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "がぞう", "screenshot": "", "search-query": "fullQuery", @@ -669,6 +688,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "だ", "screenshot": "", "search-query": "fullQuery", @@ -704,6 +724,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ダース", "screenshot": "", "search-query": "fullQuery", @@ -739,6 +760,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ", "screenshot": "", "search-query": "fullQuery", @@ -769,6 +791,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ", "screenshot": "", "search-query": "fullQuery", @@ -804,6 +827,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -834,6 +858,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -869,6 +894,7 @@ "pitch-accents": "
            ", "pitch-accent-graphs": "
            ", "pitch-accent-positions": "
            1. [0]
            2. [3]
            ", + "phonetic-transcriptions": "
              ", "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", @@ -899,6 +925,7 @@ "pitch-accents": "
              ", "pitch-accent-graphs": "
              ", "pitch-accent-positions": "
              1. [0]
              2. [3]
              ", + "phonetic-transcriptions": "
                ", "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", @@ -929,6 +956,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ", "screenshot": "", "search-query": "fullQuery", @@ -959,6 +987,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ", "screenshot": "", "search-query": "fullQuery", @@ -994,6 +1023,7 @@ "pitch-accents": "
                ", "pitch-accent-graphs": "
                ", "pitch-accent-positions": "
                1. [0]
                2. [3]
                ", + "phonetic-transcriptions": "
                  ", "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", @@ -1024,6 +1054,7 @@ "pitch-accents": "
                  ", "pitch-accent-graphs": "
                  ", "pitch-accent-positions": "
                  1. [0]
                  2. [3]
                  ", + "phonetic-transcriptions": "
                    ", "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", @@ -1054,6 +1085,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -1084,6 +1116,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -1119,6 +1152,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "がぞう", "screenshot": "", "search-query": "fullQuery", @@ -1166,6 +1200,7 @@ "pitch-accents": "
                    ", "pitch-accent-graphs": "
                    ", "pitch-accent-positions": "
                    1. [0]
                    2. [3]
                    ", + "phonetic-transcriptions": "
                      ", "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", @@ -1196,6 +1231,7 @@ "pitch-accents": "
                      ", "pitch-accent-graphs": "
                      ", "pitch-accent-positions": "
                      1. [0]
                      2. [3]
                      ", + "phonetic-transcriptions": "
                        ", "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", @@ -1226,6 +1262,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ", "screenshot": "", "search-query": "fullQuery", @@ -1256,6 +1293,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -1286,6 +1324,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "だ", "screenshot": "", "search-query": "fullQuery", @@ -1316,6 +1355,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ダース", "screenshot": "", "search-query": "fullQuery", @@ -1351,6 +1391,7 @@ "pitch-accents": "
                        1. (うちこむ only)
                        2. (うちこむ only)
                        3. (ぶちこむ only)
                        4. (ぶちこむ only)
                        ", "pitch-accent-graphs": "
                        1. (うちこむ only)
                        2. (うちこむ only)
                        3. (ぶちこむ only)
                        4. (ぶちこむ only)
                        ", "pitch-accent-positions": "
                        1. (うちこむ only) [0]
                        2. (うちこむ only) [3]
                        3. (ぶちこむ only) [0]
                        4. (ぶちこむ only) [3]
                        ", + "phonetic-transcriptions": "
                          ", "reading": "うちこむ、ぶちこむ", "screenshot": "", "search-query": "fullQuery", @@ -1381,6 +1422,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ、ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -1411,6 +1453,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "だ", "screenshot": "", "search-query": "fullQuery", @@ -1441,6 +1484,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ダース", "screenshot": "", "search-query": "fullQuery", @@ -1476,6 +1520,7 @@ "pitch-accents": "
                          ", "pitch-accent-graphs": "
                          ", "pitch-accent-positions": "
                          1. [0]
                          2. [3]
                          ", + "phonetic-transcriptions": "
                            ", "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", @@ -1506,6 +1551,7 @@ "pitch-accents": "
                            ", "pitch-accent-graphs": "
                            ", "pitch-accent-positions": "
                            1. [0]
                            2. [3]
                            ", + "phonetic-transcriptions": "
                              ", "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", @@ -1536,6 +1582,7 @@ "pitch-accents": "
                              ", "pitch-accent-graphs": "
                              ", "pitch-accent-positions": "
                              1. [0]
                              2. [3]
                              ", + "phonetic-transcriptions": "
                                ", "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", @@ -1566,6 +1613,7 @@ "pitch-accents": "
                                ", "pitch-accent-graphs": "
                                ", "pitch-accent-positions": "
                                1. [0]
                                2. [3]
                                ", + "phonetic-transcriptions": "
                                  ", "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", @@ -1596,6 +1644,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ", "screenshot": "", "search-query": "fullQuery", @@ -1626,6 +1675,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -1656,6 +1706,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ", "screenshot": "", "search-query": "fullQuery", @@ -1686,6 +1737,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -1716,6 +1768,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "だ", "screenshot": "", "search-query": "fullQuery", @@ -1746,6 +1799,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ダース", "screenshot": "", "search-query": "fullQuery", @@ -1781,6 +1835,7 @@ "pitch-accents": "
                                  ", "pitch-accent-graphs": "
                                  ", "pitch-accent-positions": "
                                  1. [0]
                                  2. [3]
                                  ", + "phonetic-transcriptions": "
                                    ", "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", @@ -1811,6 +1866,7 @@ "pitch-accents": "
                                    ", "pitch-accent-graphs": "
                                    ", "pitch-accent-positions": "
                                    1. [0]
                                    2. [3]
                                    ", + "phonetic-transcriptions": "
                                      ", "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", @@ -1841,6 +1897,7 @@ "pitch-accents": "
                                      ", "pitch-accent-graphs": "
                                      ", "pitch-accent-positions": "
                                      1. [0]
                                      2. [3]
                                      ", + "phonetic-transcriptions": "
                                        ", "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", @@ -1871,6 +1928,7 @@ "pitch-accents": "
                                        ", "pitch-accent-graphs": "
                                        ", "pitch-accent-positions": "
                                        1. [0]
                                        2. [3]
                                        ", + "phonetic-transcriptions": "
                                          ", "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", @@ -1901,6 +1959,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ", "screenshot": "", "search-query": "fullQuery", @@ -1931,6 +1990,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -1961,6 +2021,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ", "screenshot": "", "search-query": "fullQuery", @@ -1991,6 +2052,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -2021,6 +2083,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "だ", "screenshot": "", "search-query": "fullQuery", @@ -2051,6 +2114,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ダース", "screenshot": "", "search-query": "fullQuery", @@ -2086,6 +2150,7 @@ "pitch-accents": "
                                          ", "pitch-accent-graphs": "
                                          ", "pitch-accent-positions": "
                                          1. [0]
                                          2. [3]
                                          ", + "phonetic-transcriptions": "
                                            ", "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", @@ -2116,6 +2181,7 @@ "pitch-accents": "
                                            ", "pitch-accent-graphs": "
                                            ", "pitch-accent-positions": "
                                            1. [0]
                                            2. [3]
                                            ", + "phonetic-transcriptions": "
                                              ", "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", @@ -2146,6 +2212,7 @@ "pitch-accents": "
                                              ", "pitch-accent-graphs": "
                                              ", "pitch-accent-positions": "
                                              1. [0]
                                              2. [3]
                                              ", + "phonetic-transcriptions": "
                                                ", "reading": "うちこむ", "screenshot": "", "search-query": "fullQuery", @@ -2176,6 +2243,7 @@ "pitch-accents": "
                                                ", "pitch-accent-graphs": "
                                                ", "pitch-accent-positions": "
                                                1. [0]
                                                2. [3]
                                                ", + "phonetic-transcriptions": "
                                                  ", "reading": "ぶちこむ", "screenshot": "", "search-query": "fullQuery", @@ -2206,6 +2274,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ", "screenshot": "", "search-query": "fullQuery", @@ -2236,6 +2305,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -2266,6 +2336,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ", "screenshot": "", "search-query": "fullQuery", @@ -2296,6 +2367,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -2326,6 +2398,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "だ", "screenshot": "", "search-query": "fullQuery", @@ -2356,6 +2429,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "ダース", "screenshot": "", "search-query": "fullQuery", @@ -2391,6 +2465,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "よむ", "screenshot": "", "search-query": "fullQuery", @@ -2426,6 +2501,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "つよみ", "screenshot": "", "search-query": "fullQuery", @@ -2461,6 +2537,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "よむ", "screenshot": "", "search-query": "fullQuery", @@ -2496,6 +2573,7 @@ "pitch-accents": "
                                                  1. (うちこむ only)
                                                  2. (うちこむ only)
                                                  3. (ぶちこむ only)
                                                  4. (ぶちこむ only)
                                                  ", "pitch-accent-graphs": "
                                                  1. (うちこむ only)
                                                  2. (うちこむ only)
                                                  3. (ぶちこむ only)
                                                  4. (ぶちこむ only)
                                                  ", "pitch-accent-positions": "
                                                  1. (うちこむ only) [0]
                                                  2. (うちこむ only) [3]
                                                  3. (ぶちこむ only) [0]
                                                  4. (ぶちこむ only) [3]
                                                  ", + "phonetic-transcriptions": "
                                                    ", "reading": "うちこむ、ぶちこむ", "screenshot": "", "search-query": "fullQuery", @@ -2526,6 +2604,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "うつ、ぶつ", "screenshot": "", "search-query": "fullQuery", @@ -2561,6 +2640,7 @@ "pitch-accents": "
                                                    ", "pitch-accent-graphs": "
                                                    ", "pitch-accent-positions": "
                                                    1. [2]
                                                    2. [2]
                                                    3. [0]
                                                    ", + "phonetic-transcriptions": "
                                                      ", "reading": "おてまえ", "screenshot": "", "search-query": "fullQuery", @@ -2596,6 +2676,7 @@ "pitch-accents": "", "pitch-accent-graphs": "", "pitch-accent-positions": "[3]", + "phonetic-transcriptions": "
                                                        ", "reading": "ばんごう", "screenshot": "", "search-query": "fullQuery", @@ -2631,6 +2712,7 @@ "pitch-accents": "", "pitch-accent-graphs": "", "pitch-accent-positions": "[0]", + "phonetic-transcriptions": "
                                                          ", "reading": "ちゅうごし", "screenshot": "", "search-query": "fullQuery", @@ -2666,6 +2748,7 @@ "pitch-accents": "", "pitch-accent-graphs": "", "pitch-accent-positions": "[0]", + "phonetic-transcriptions": "
                                                            ", "reading": "しょぎょう", "screenshot": "", "search-query": "fullQuery", @@ -2701,6 +2784,7 @@ "pitch-accents": "", "pitch-accent-graphs": "", "pitch-accent-positions": "[4]", + "phonetic-transcriptions": "
                                                              ", "reading": "どぼくこうじ", "screenshot": "", "search-query": "fullQuery", @@ -2736,6 +2820,7 @@ "pitch-accents": "No pitch accent data", "pitch-accent-graphs": "No pitch accent data", "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", "reading": "こうぞう", "screenshot": "", "search-query": "fullQuery", diff --git a/test/data/translator-test-results-note-data1.json b/test/data/translator-test-results-note-data1.json index 34f7c21ab5..b1248c26e6 100644 --- a/test/data/translator-test-results-note-data1.json +++ b/test/data/translator-test-results-note-data1.json @@ -151,6 +151,7 @@ "uniqueReadings": [], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -313,6 +314,7 @@ "uniqueReadings": [], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -595,6 +597,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -626,6 +629,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -908,6 +912,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -939,6 +944,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -1213,6 +1219,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -1248,6 +1255,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -1517,6 +1525,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -1552,6 +1561,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -1821,6 +1831,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -1856,6 +1867,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -2125,6 +2137,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -2160,6 +2173,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -2433,6 +2447,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -2464,6 +2479,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -2746,6 +2762,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -2777,6 +2794,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -3103,6 +3121,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "うちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -3176,6 +3208,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -3497,6 +3535,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "ぶちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -3570,6 +3622,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -3891,6 +3949,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "うちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -3964,6 +4036,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -4285,6 +4363,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "ぶちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -4358,6 +4450,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -4629,6 +4727,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -4664,6 +4763,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -4935,6 +5035,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -4970,6 +5071,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -5241,6 +5343,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -5276,6 +5379,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -5547,6 +5651,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -5582,6 +5687,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -5855,6 +5961,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -5886,6 +5993,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -6168,6 +6276,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -6199,6 +6308,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -6320,6 +6430,7 @@ ], "frequencies": [], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -6351,6 +6462,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -6629,6 +6741,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -6660,6 +6773,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -6947,6 +7061,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -6978,6 +7093,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -7252,6 +7368,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -7287,6 +7404,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -7556,6 +7674,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -7591,6 +7710,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -7865,6 +7985,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -7900,6 +8021,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -8169,6 +8291,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -8204,6 +8327,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -8530,6 +8654,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "うちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -8603,6 +8741,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -8924,6 +9068,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "うちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -8997,6 +9155,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -9268,6 +9432,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -9303,6 +9468,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -9574,6 +9740,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -9609,6 +9776,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -9935,6 +10103,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "ぶちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -10008,6 +10190,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -10329,6 +10517,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "ぶちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -10402,6 +10604,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -10673,6 +10881,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -10708,6 +10917,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -10979,6 +11189,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -11014,6 +11225,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -11135,6 +11347,7 @@ ], "frequencies": [], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -11166,6 +11379,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -11545,6 +11759,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "うちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -11600,6 +11828,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -11962,6 +12196,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "ぶちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -12017,6 +12265,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -12329,6 +12583,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -12354,6 +12609,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -12666,6 +12922,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -12691,6 +12948,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -12968,6 +13226,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -12993,6 +13252,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -13279,6 +13539,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -13304,6 +13565,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -13954,6 +14216,32 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "うちこむ", + "phoneticTranscriptions": [] + }, + { + "index": 1, + "expressionIndex": 1, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "ぶちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 2, "url": "url:", "cloze": { @@ -14042,6 +14330,12 @@ } ], "pitchCount": 4, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -14586,6 +14880,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 2, "url": "url:", "cloze": { @@ -14612,6 +14907,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -14882,6 +15178,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -14907,6 +15204,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -15186,6 +15484,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -15211,6 +15510,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -15541,6 +15841,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "うちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -15614,6 +15928,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -15939,6 +16259,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "ぶちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -16012,6 +16346,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -16337,6 +16677,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "うちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -16410,6 +16764,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -16735,6 +17095,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "ぶちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -16808,6 +17182,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -17079,6 +17459,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -17114,6 +17495,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -17385,6 +17767,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -17420,6 +17803,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -17691,6 +18075,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -17726,6 +18111,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -17997,6 +18383,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -18032,6 +18419,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -18305,6 +18693,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -18336,6 +18725,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -18618,6 +19008,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -18649,6 +19040,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -18975,6 +19367,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "うちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -19048,6 +19454,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -19369,6 +19781,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "ぶちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -19442,6 +19868,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -19763,6 +20195,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "うちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -19836,6 +20282,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -20157,6 +20609,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "ぶちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -20230,6 +20696,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -20501,6 +20973,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -20536,6 +21009,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -20807,6 +21281,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -20842,6 +21317,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -21113,6 +21589,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -21148,6 +21625,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -21419,6 +21897,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -21454,6 +21933,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -21727,6 +22207,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -21758,6 +22239,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -22040,6 +22522,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -22071,6 +22554,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -22397,6 +22881,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "うちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -22470,6 +22968,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -22791,6 +23295,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "ぶちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -22864,6 +23382,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -23185,6 +23709,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "うちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -23258,6 +23796,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -23579,6 +24123,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "ぶちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -23652,6 +24210,12 @@ } ], "pitchCount": 2, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -23923,6 +24487,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -23958,6 +24523,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -24229,6 +24795,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -24264,6 +24831,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -24535,6 +25103,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -24570,6 +25139,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -24841,6 +25411,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -24876,6 +25447,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -25149,6 +25721,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -25180,6 +25753,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -25462,6 +26036,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -25493,6 +26068,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -25610,6 +26186,7 @@ ], "frequencies": [], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -25645,6 +26222,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -25760,6 +26338,7 @@ ], "frequencies": [], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -25795,6 +26374,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -25912,6 +26492,7 @@ ], "frequencies": [], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -25947,6 +26528,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -26597,6 +27179,32 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "うちこむ", + "phoneticTranscriptions": [] + }, + { + "index": 1, + "expressionIndex": 1, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "打ち込む", + "reading": "ぶちこむ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -26685,6 +27293,12 @@ } ], "pitchCount": 4, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -27229,6 +27843,7 @@ } ], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 0, "url": "url:", "cloze": { @@ -27255,6 +27870,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", @@ -27444,6 +28060,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "お手前", + "reading": "おてまえ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -27563,6 +28193,12 @@ } ], "pitchCount": 3, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -27672,6 +28308,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "番号", + "reading": "ばんごう", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -27723,6 +28373,12 @@ } ], "pitchCount": 1, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -27832,6 +28488,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "中腰", + "reading": "ちゅうごし", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -27883,6 +28553,12 @@ } ], "pitchCount": 1, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -27992,6 +28668,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "所業", + "reading": "しょぎょう", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -28043,6 +28733,12 @@ } ], "pitchCount": 1, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -28152,6 +28848,20 @@ ] } ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "土木工事", + "reading": "どぼくこうじ", + "phoneticTranscriptions": [] + } + ], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -28203,6 +28913,12 @@ } ], "pitchCount": 1, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [] + } + ], "context": { "query": "query", "fullQuery": "fullQuery", @@ -28322,6 +29038,7 @@ ], "frequencies": [], "pitches": [], + "phoneticTranscriptions": [], "sourceTermExactMatchCount": 1, "url": "url:", "cloze": { @@ -28353,6 +29070,7 @@ ], "pitches": [], "pitchCount": 0, + "phoneticTranscriptions": [], "context": { "query": "query", "fullQuery": "fullQuery", diff --git a/test/data/translator-test-results.json b/test/data/translator-test-results.json index 0a7155b885..a17a91d9ae 100644 --- a/test/data/translator-test-results.json +++ b/test/data/translator-test-results.json @@ -1740,14 +1740,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -1927,14 +1929,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -2114,14 +2118,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -2301,14 +2307,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -4637,14 +4645,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -4824,14 +4834,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -5351,14 +5363,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -5538,14 +5552,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -6820,14 +6836,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -7055,14 +7073,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -8194,14 +8214,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -8215,14 +8237,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -9227,14 +9251,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -9418,14 +9444,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -9609,14 +9637,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -9800,14 +9830,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -11000,14 +11032,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -11187,14 +11221,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -11374,14 +11410,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -11561,14 +11599,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -12761,14 +12801,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -12948,14 +12990,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -13135,14 +13179,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -13322,14 +13368,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -15012,14 +15060,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -15033,14 +15083,16 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], "tags": [] }, { + "type": "pitch-accent", "position": 3, "nasalPositions": [], "devoicePositions": [], @@ -15674,8 +15726,9 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 2, "nasalPositions": [], "devoicePositions": [], @@ -15696,6 +15749,7 @@ ] }, { + "type": "pitch-accent", "position": 2, "nasalPositions": [], "devoicePositions": [], @@ -15716,6 +15770,7 @@ ] }, { + "type": "pitch-accent", "position": 0, "nasalPositions": [], "devoicePositions": [], @@ -15820,8 +15875,9 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 3, "nasalPositions": [ 3 @@ -15914,8 +15970,9 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [ 3 @@ -16008,8 +16065,9 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 0, "nasalPositions": [ 2 @@ -16102,8 +16160,9 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "pitches": [ + "pronunciations": [ { + "type": "pitch-accent", "position": 4, "nasalPositions": [], "devoicePositions": [ From 7dc3a61483dab341a8a0036e31669ccaa8eddf9c Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Mon, 25 Dec 2023 18:04:32 +0100 Subject: [PATCH 15/19] fix gitignore --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 79aff0f6c1..459af2b711 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ node_modules/ builds/ dictionaries/ -dict/ /test-results/ /playwright-report/ From 4aa336c1c29efe585b81c4f33538d8798cef4ffa Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 27 Dec 2023 11:06:16 +0100 Subject: [PATCH 16/19] engines --- package-lock.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package-lock.json b/package-lock.json index d7c62cabb0..c8a5bad528 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,6 +54,9 @@ "ts-json-schema-generator": "^1.5.0", "typescript": "5.3.3", "vitest": "^0.34.6" + }, + "engines": { + "node": ">=20.0.0" } }, "node_modules/@aashutoshrathi/word-wrap": { From 48aa429b8a0657699721d52e1ae15280f3751f26 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 27 Dec 2023 11:43:34 +0100 Subject: [PATCH 17/19] add tests --- .../default-anki-field-templates.handlebars | 4 +- test/data/anki-note-builder-test-results.json | 36 +++ .../valid-dictionary1/term_bank_1.json | 1 + .../valid-dictionary1/term_meta_bank_1.json | 10 + test/data/translator-test-inputs.json | 7 + .../translator-test-results-note-data1.json | 210 +++++++++++++++++- test/data/translator-test-results.json | 114 +++++++++- 7 files changed, 378 insertions(+), 4 deletions(-) diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index 4012c05bc6..f23b9d0be9 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -241,8 +241,8 @@ {{name}} {{~set "any" true~}} {{~/each~}} - {{~#if (get "any")}}) {{/if~}} - {{ipa}} + {{~#if (get "any")}}) {{/if~}} + {{ipa~}}
                                                            • {{~/each~}} {{~/each~}} diff --git a/test/data/anki-note-builder-test-results.json b/test/data/anki-note-builder-test-results.json index 766d8e2159..86bffc6a0e 100644 --- a/test/data/anki-note-builder-test-results.json +++ b/test/data/anki-note-builder-test-results.json @@ -2796,6 +2796,42 @@ } ] }, + { + "name": "Test pronunciations 6 - phonetic transcriptions", + "results": [ + { + "audio": "", + "clipboard-image": "", + "clipboard-text": "", + "cloze-body": "好き", + "cloze-prefix": "cloze-prefix", + "cloze-suffix": "cloze-suffix", + "conjugation": "", + "dictionary": "Test Dictionary 2", + "document-title": "title", + "expression": "好き", + "frequencies": "", + "furigana": "き", + "furigana-plain": "好[す]き", + "glossary": "
                                                              (adj-na, n, Test Dictionary 2) suki definition
                                                              ", + "glossary-brief": "
                                                              suki definition
                                                              ", + "glossary-no-dictionary": "
                                                              (adj-na, n) suki definition
                                                              ", + "part-of-speech": "Unknown", + "pitch-accents": "No pitch accent data", + "pitch-accent-graphs": "No pitch accent data", + "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "
                                                              • (東京) [sɨᵝkʲi]
                                                              ", + "reading": "すき", + "screenshot": "", + "search-query": "fullQuery", + "selection-text": "", + "sentence": "cloze-prefix好きcloze-suffix", + "sentence-furigana": "cloze-prefix好きcloze-suffix", + "tags": "adj-na, n", + "url": "url:" + } + ] + }, { "name": "Structured content test", "results": [ diff --git a/test/data/dictionaries/valid-dictionary1/term_bank_1.json b/test/data/dictionaries/valid-dictionary1/term_bank_1.json index 14f66d951c..ce4290bdff 100644 --- a/test/data/dictionaries/valid-dictionary1/term_bank_1.json +++ b/test/data/dictionaries/valid-dictionary1/term_bank_1.json @@ -18,6 +18,7 @@ ["中腰", "ちゅうごし", "n", "n", 1, ["chuugoshi definition"], 11, ""], ["所業", "しょぎょう", "n", "n", 1, ["shogyouu definition"], 12, ""], ["土木工事", "どぼくこうじ", "n", "n", 1, ["dobokukouji definition"], 13, ""], + ["好き", "すき", "adj-na n", "", 1, ["suki definition"], 14, ""], [ "内容", "ないよう", "n", "n", 35, [ diff --git a/test/data/dictionaries/valid-dictionary1/term_meta_bank_1.json b/test/data/dictionaries/valid-dictionary1/term_meta_bank_1.json index 069ea16b30..562966482f 100644 --- a/test/data/dictionaries/valid-dictionary1/term_meta_bank_1.json +++ b/test/data/dictionaries/valid-dictionary1/term_meta_bank_1.json @@ -108,5 +108,15 @@ {"position": 4, "devoice": 3} ] } + ], + [ + "好き", + "ipa", + { + "reading": "すき", + "transcriptions": [ + {"ipa": "[sɨᵝkʲi]", "tags": ["東京"]} + ] + } ] ] \ No newline at end of file diff --git a/test/data/translator-test-inputs.json b/test/data/translator-test-inputs.json index 5afb6a6013..ec7f1a1121 100644 --- a/test/data/translator-test-inputs.json +++ b/test/data/translator-test-inputs.json @@ -330,6 +330,13 @@ "text": "土木工事", "options": "default" }, + { + "name": "Test pronunciations 6 - phonetic transcriptions", + "func": "findTerms", + "mode": "split", + "text": "好き", + "options": "default" + }, { "name": "Structured content test", "func": "findTerms", diff --git a/test/data/translator-test-results-note-data1.json b/test/data/translator-test-results-note-data1.json index b1248c26e6..1342a63fed 100644 --- a/test/data/translator-test-results-note-data1.json +++ b/test/data/translator-test-results-note-data1.json @@ -28930,6 +28930,214 @@ } ] }, + { + "name": "Test pronunciations 6 - phonetic transcriptions", + "noteDataList": [ + { + "marker": "{marker}", + "definition": { + "type": "term", + "id": 20, + "source": "好き", + "rawSource": "好き", + "sourceTerm": "好き", + "reasons": [], + "score": 1, + "isPrimary": true, + "sequence": 14, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "dictionaryNames": [ + "Test Dictionary 2" + ], + "expression": "好き", + "reading": "すき", + "expressions": [ + { + "sourceTerm": "好き", + "expression": "好き", + "reading": "すき", + "termTags": [], + "frequencies": [], + "pitches": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "好き", + "reading": "すき", + "pitches": [] + } + ], + "furiganaSegments": [ + { + "text": "好", + "furigana": "す" + }, + { + "text": "き", + "furigana": "" + } + ], + "termFrequency": "normal", + "wordClasses": [] + } + ], + "glossary": [ + "suki definition" + ], + "definitionTags": [ + { + "name": "adj-na", + "category": "default", + "notes": "", + "order": 0, + "score": 0, + "dictionary": "Test Dictionary 2", + "redundant": false + }, + { + "name": "n", + "category": "partOfSpeech", + "notes": "noun", + "order": 0, + "score": 0, + "dictionary": "Test Dictionary 2", + "redundant": false + } + ], + "termTags": [], + "frequencies": [], + "pitches": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "好き", + "reading": "すき", + "pitches": [] + } + ], + "phoneticTranscriptions": [ + { + "index": 0, + "expressionIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "expression": "好き", + "reading": "すき", + "phoneticTranscriptions": [ + { + "ipa": "[sɨᵝkʲi]", + "tags": [ + { + "name": "東京", + "category": "default", + "notes": "", + "order": 0, + "score": 0, + "dictionary": "Test Dictionary 2", + "redundant": false + } + ] + } + ] + } + ], + "sourceTermExactMatchCount": 1, + "url": "url:", + "cloze": { + "sentence": "", + "prefix": "", + "body": "", + "suffix": "" + }, + "furiganaSegments": [ + { + "text": "好", + "furigana": "す" + }, + { + "text": "き", + "furigana": "" + } + ] + }, + "glossaryLayoutMode": "default", + "compactTags": false, + "group": false, + "merge": false, + "modeTermKanji": false, + "modeTermKana": false, + "modeKanji": false, + "compactGlossaries": false, + "uniqueExpressions": [ + "好き" + ], + "uniqueReadings": [ + "すき" + ], + "pitches": [ + { + "dictionary": "Test Dictionary 2", + "pitches": [] + } + ], + "pitchCount": 0, + "phoneticTranscriptions": [ + { + "dictionary": "Test Dictionary 2", + "phoneticTranscriptions": [ + { + "expressions": [ + "好き" + ], + "reading": "すき", + "ipa": "[sɨᵝkʲi]", + "tags": [ + { + "name": "東京", + "category": "default", + "order": 0, + "score": 0, + "content": [], + "dictionaries": [ + "Test Dictionary 2" + ], + "redundant": false + } + ], + "exclusiveExpressions": [], + "exclusiveReadings": [] + } + ] + } + ], + "context": { + "query": "query", + "fullQuery": "fullQuery", + "document": { + "title": "title" + } + }, + "media": {} + } + ] + }, { "name": "Structured content test", "noteDataList": [ @@ -28937,7 +29145,7 @@ "marker": "{marker}", "definition": { "type": "term", - "id": 21, + "id": 22, "source": "構造", "rawSource": "構造", "sourceTerm": "構造", diff --git a/test/data/translator-test-results.json b/test/data/translator-test-results.json index a17a91d9ae..50d97775c0 100644 --- a/test/data/translator-test-results.json +++ b/test/data/translator-test-results.json @@ -16177,6 +16177,118 @@ } ] }, + { + "name": "Test pronunciations 6 - phonetic transcriptions", + "originalTextLength": 2, + "dictionaryEntries": [ + { + "type": "term", + "isPrimary": true, + "inflections": [], + "score": 1, + "frequencyOrder": 0, + "dictionaryIndex": 0, + "dictionaryPriority": 0, + "sourceTermExactMatchCount": 1, + "maxTransformedTextLength": 2, + "headwords": [ + { + "index": 0, + "term": "好き", + "reading": "すき", + "sources": [ + { + "originalText": "好き", + "transformedText": "好き", + "deinflectedText": "好き", + "matchType": "exact", + "matchSource": "term", + "isPrimary": true + } + ], + "tags": [], + "wordClasses": [] + } + ], + "definitions": [ + { + "index": 0, + "headwordIndices": [ + 0 + ], + "dictionary": "Test Dictionary 2", + "dictionaryIndex": 0, + "dictionaryPriority": 0, + "id": 20, + "score": 1, + "frequencyOrder": 0, + "sequences": [ + 14 + ], + "isPrimary": true, + "tags": [ + { + "name": "adj-na", + "category": "default", + "order": 0, + "score": 0, + "content": [], + "dictionaries": [ + "Test Dictionary 2" + ], + "redundant": false + }, + { + "name": "n", + "category": "partOfSpeech", + "order": 0, + "score": 0, + "content": [ + "noun" + ], + "dictionaries": [ + "Test Dictionary 2" + ], + "redundant": false + } + ], + "entries": [ + "suki definition" + ] + } + ], + "pronunciations": [ + { + "index": 0, + "headwordIndex": 0, + "dictionary": "Test Dictionary 2", + "dictionaryIndex": 0, + "dictionaryPriority": 0, + "pronunciations": [ + { + "type": "phonetic-transcription", + "ipa": "[sɨᵝkʲi]", + "tags": [ + { + "name": "東京", + "category": "default", + "order": 0, + "score": 0, + "content": [], + "dictionaries": [ + "Test Dictionary 2" + ], + "redundant": false + } + ] + } + ] + } + ], + "frequencies": [] + } + ] + }, { "name": "Structured content test", "originalTextLength": 2, @@ -16248,7 +16360,7 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "id": 21, + "id": 22, "score": 35, "frequencyOrder": 0, "sequences": [ From 2d00c8499e8674bb70b5a3c8312cc88d223f659f Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 27 Dec 2023 11:58:09 +0100 Subject: [PATCH 18/19] update database test --- test/database.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/database.test.js b/test/database.test.js index 7c3d560698..f5d2c307de 100644 --- a/test/database.test.js +++ b/test/database.test.js @@ -164,8 +164,8 @@ async function testDatabase1() { kanjiMeta: {total: 6, freq: 6}, media: {total: 6}, tagMeta: {total: 15}, - termMeta: {total: 38, freq: 31, pitch: 7}, - terms: {total: 22} + termMeta: {total: 39, freq: 31, pitch: 7, ipa: 1}, + terms: {total: 23} } }; @@ -192,8 +192,8 @@ async function testDatabase1() { true ); expect(counts).toStrictEqual({ - counts: [{kanji: 2, kanjiMeta: 6, terms: 22, termMeta: 38, tagMeta: 15, media: 6}], - total: {kanji: 2, kanjiMeta: 6, terms: 22, termMeta: 38, tagMeta: 15, media: 6} + counts: [{kanji: 2, kanjiMeta: 6, terms: 23, termMeta: 39, tagMeta: 15, media: 6}], + total: {kanji: 2, kanjiMeta: 6, terms: 23, termMeta: 39, tagMeta: 15, media: 6} }); // Test find* functions From 1b25828f8ad463996d9048c22f898a2c246b5cca Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 27 Dec 2023 12:14:07 +0100 Subject: [PATCH 19/19] fix test --- types/ext/dictionary-data.d.ts | 10 ++++++++-- types/ext/dictionary-database.d.ts | 12 ++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/types/ext/dictionary-data.d.ts b/types/ext/dictionary-data.d.ts index 4f7c447798..0e0edd5c46 100644 --- a/types/ext/dictionary-data.d.ts +++ b/types/ext/dictionary-data.d.ts @@ -125,7 +125,7 @@ export type GenericFrequencyData = string | number | { export type TermMetaArray = TermMeta[]; -export type TermMeta = TermMetaFrequency | TermMetaPitch; +export type TermMeta = TermMetaFrequency | TermMetaPitch | TermMetaPhonetic; export type TermMetaFrequencyDataWithReading = { reading: string; @@ -154,7 +154,13 @@ export type TermMetaPitch = [ data: TermMetaPitchData, ]; -export type TermMetaPhonetic = { +export type TermMetaPhonetic = [ + expression: string, + mode: 'ipa', + data: TermMetaPhoneticData, +]; + +export type TermMetaPhoneticData = { reading: string; transcriptions: { ipa: string; diff --git a/types/ext/dictionary-database.d.ts b/types/ext/dictionary-database.d.ts index f1d01e0d44..3cf68543cf 100644 --- a/types/ext/dictionary-database.d.ts +++ b/types/ext/dictionary-database.d.ts @@ -102,7 +102,7 @@ export type Tag = { dictionary: string; }; -export type DatabaseTermMeta = DatabaseTermMetaFrequency | DatabaseTermMetaPitch | DatabaseTermMetaPhonetic; +export type DatabaseTermMeta = DatabaseTermMetaFrequency | DatabaseTermMetaPitch | DatabaseTermMetaPhoneticData; export type DatabaseTermMetaFrequency = { expression: string; @@ -118,10 +118,10 @@ export type DatabaseTermMetaPitch = { dictionary: string; }; -export type DatabaseTermMetaPhonetic = { +export type DatabaseTermMetaPhoneticData = { expression: string; mode: 'ipa'; - data: DictionaryData.TermMetaPhonetic; + data: DictionaryData.TermMetaPhoneticData; dictionary: string; }; @@ -130,7 +130,7 @@ export type TermMetaFrequencyDataWithReading = { frequency: DictionaryData.GenericFrequencyData; }; -export type TermMeta = TermMetaFrequency | TermMetaPitch | TermMetaPhonetic; +export type TermMeta = TermMetaFrequency | TermMetaPitch | TermMetaPhoneticData; export type TermMetaType = TermMeta['mode']; @@ -150,11 +150,11 @@ export type TermMetaPitch = { dictionary: string; }; -export type TermMetaPhonetic = { +export type TermMetaPhoneticData = { mode: 'ipa'; index: number; term: string; - data: DictionaryData.TermMetaPhonetic; + data: DictionaryData.TermMetaPhoneticData; dictionary: string; };