Skip to content

Commit

Permalink
rename transform to process
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanVukovic99 committed Feb 5, 2024
1 parent ddb9b97 commit 183215a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
16 changes: 8 additions & 8 deletions ext/js/language/ja/text-preprocessors.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {convertAlphabeticToKana} from './japanese-wanakana.js';
import {collapseEmphaticSequences, convertHalfWidthKanaToFullWidth, convertHiraganaToKatakana, convertKatakanaToHiragana, convertNumericToFullWidth} from './japanese.js';

/** @type {import('language').TextPreprocessor<[collapseEmphatic: boolean, collapseEmphaticFull: boolean]>}*/
const collapseEmphaticSequencesTransform = {
const collapseEmphaticSequencesPrerocessor = {
id: 'collapseEmphaticSequences',
name: 'Collapse emphatic character sequences',
description: 'すっっごーーい → すっごーい / すごい',
Expand All @@ -29,7 +29,7 @@ const collapseEmphaticSequencesTransform = {
['true', 'Collapse into single character', [[false, false], [true, false]]],
['full', 'Remove all characters', [[false, false], [true, false], [true, true]]]
],
transform: (str, setting, sourceMap) => {
process: (str, setting, sourceMap) => {
const [collapseEmphatic, collapseEmphaticFull] = setting;
if (collapseEmphatic) {
str = collapseEmphaticSequences(str, collapseEmphaticFull, sourceMap);
Expand All @@ -45,35 +45,35 @@ export const textPreprocessors = [
name: 'Convert half width characters to full width',
description: 'ヨミチャン → ヨミチャン',
options: basicTextPreprocessorOptions,
transform: (str, setting, sourceMap) => setting ? convertHalfWidthKanaToFullWidth(str, sourceMap) : str
process: (str, setting, sourceMap) => setting ? convertHalfWidthKanaToFullWidth(str, sourceMap) : str
},
{
id: 'convertNumericCharacters',
name: 'Convert numeric characters to full width',
description: '1234 → 1234',
options: basicTextPreprocessorOptions,
transform: (str, setting) => setting ? convertNumericToFullWidth(str) : str
process: (str, setting) => setting ? convertNumericToFullWidth(str) : str
},
{
id: 'convertAlphabeticCharacters',
name: 'Convert alphabetic characters to hiragana',
description: 'yomichan → よみちゃん',
options: basicTextPreprocessorOptions,
transform: (str, setting, sourceMap) => setting ? convertAlphabeticToKana(str, sourceMap) : str
process: (str, setting, sourceMap) => setting ? convertAlphabeticToKana(str, sourceMap) : str
},
{
id: 'convertHiraganaToKatakana',
name: 'Convert hiragana to katakana',
description: 'よみちゃん → ヨミチャン',
options: basicTextPreprocessorOptions,
transform: (str, setting) => setting ? convertHiraganaToKatakana(str) : str
process: (str, setting) => setting ? convertHiraganaToKatakana(str) : str
},
{
id: 'convertKatakanaToHiragana',
name: 'Convert katakana to hiragana',
description: 'ヨミチャン → よみちゃん',
options: basicTextPreprocessorOptions,
transform: (str, setting) => setting ? convertKatakanaToHiragana(str) : str
process: (str, setting) => setting ? convertKatakanaToHiragana(str) : str
},
collapseEmphaticSequencesTransform
collapseEmphaticSequencesPrerocessor
];
4 changes: 2 additions & 2 deletions ext/js/language/text-preprocessors.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const decapitalize = {
name: 'Decapitalize text',
description: 'CAPITALIZED TEXT → capitalized text',
options: basicTextPreprocessorOptions,
transform: (str, setting) => setting ? str.toLowerCase() : str
process: (str, setting) => setting ? str.toLowerCase() : str
};

/** @type {import('language').TextPreprocessor} */
Expand All @@ -37,6 +37,6 @@ export const capitalizeFirstLetter = {
name: 'Capitalize first letter',
description: 'lowercase text → Lowercase text',
options: basicTextPreprocessorOptions,
transform: (str, setting) => setting ? str.charAt(0).toUpperCase() + str.slice(1) : str
process: (str, setting) => setting ? str.charAt(0).toUpperCase() + str.slice(1) : str
};

4 changes: 2 additions & 2 deletions ext/js/language/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,9 @@ export class Translator {
}

for (const {preprocessor} of textPreprocessors.values()) {
const {id, transform} = preprocessor;
const {id, process} = preprocessor;
const setting = arrayVariant.get(id);
text2 = transform(text2, setting, sourceMap);
text2 = process(text2, setting, sourceMap);
}

for (
Expand Down
2 changes: 2 additions & 0 deletions test/data/anki-note-builder-test-results.json
Original file line number Diff line number Diff line change
Expand Up @@ -3731,6 +3731,7 @@
"pitch-accents": "No pitch accent data",
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"pitch-accent-categories": "",
"phonetic-transcriptions": "",
"reading": "English",
"screenshot": "",
Expand Down Expand Up @@ -3771,6 +3772,7 @@
"pitch-accents": "No pitch accent data",
"pitch-accent-graphs": "No pitch accent data",
"pitch-accent-positions": "No pitch accent data",
"pitch-accent-categories": "",
"phonetic-transcriptions": "",
"reading": "language",
"screenshot": "",
Expand Down
2 changes: 1 addition & 1 deletion types/ext/language.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export type TextPreprocessor<T = unknown> = {
name: string;
description: string;
options: TextPreprocessorOption<T>[];
transform: (str: string, setting: T, sourceMap?: TextSourceMap) => string;
process: (str: string, setting: T, sourceMap?: TextSourceMap) => string;
};

export type Language = {
Expand Down

0 comments on commit 183215a

Please sign in to comment.