From 330cacc620fc63eca27f64dbd8d331e4d7b0a734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Bergstr=C3=B6m?= Date: Fri, 24 May 2024 13:59:26 +0200 Subject: [PATCH] Adjusted the MapBrailleToSwedishCharacters file --- src/data/MapBrailleToSwedishCharacters.js | 44 ++++++++++++------- src/functions/translator/brailleTranslator.js | 18 ++++---- 2 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/data/MapBrailleToSwedishCharacters.js b/src/data/MapBrailleToSwedishCharacters.js index 21ea578..ab29843 100644 --- a/src/data/MapBrailleToSwedishCharacters.js +++ b/src/data/MapBrailleToSwedishCharacters.js @@ -4,16 +4,20 @@ export const upperCaseSign = '⠠' export const stopSign = "⠱" export const blankSign = "⠀" export const ignoreBrailleCharacters = [ // Remove and correct later if needed - "⠨","⠱","⠬","⠣", // single character - "⠠⠄","⠠⠤","⠨⠔","⠱⠔","⠨⠨","⠨⠶","⠱⠶","⠨⠤", "⠱⠤","⠨⠢","⠱⠢","⠱⠂","⠨⠖","⠱⠖" // double characters + "⠨", "⠱", "⠬", "⠣", // single character + "⠠⠄", "⠠⠤", "⠨⠔", "⠱⠔", "⠨⠨", "⠨⠶", "⠱⠶", "⠨⠤", "⠱⠤", "⠨⠢", "⠱⠢", "⠱⠂", "⠨⠖", "⠱⠖" // double characters ] +/* Scandinavian Braille */ +// Reference: https://www.pharmabraille.com/wp-content/uploads/2015/01/Svenska_skrivregler_for_punktskrift.pdf by Punktskriftsnämnden + export const mapBrailleToAlpha = { '⠁': 'a', '⠃': 'b', '⠉': 'c', '⠙': 'd', '⠑': 'e', + '⠿': 'é', '⠋': 'f', '⠛': 'g', '⠓': 'h', @@ -30,6 +34,7 @@ export const mapBrailleToAlpha = { '⠎': 's', '⠞': 't', '⠥': 'u', + '⠳': 'ü', '⠧': 'v', '⠺': 'w', '⠭': 'x', @@ -37,10 +42,9 @@ export const mapBrailleToAlpha = { '⠵': 'z', '⠜': 'ä', '⠡': 'å', - '⠷': 'á', // remove? '⠪': 'ö', - '⠳': 'ü', // remove? - '⠿': 'é', // remove? + + // '⠷': 'á', corresponds to '[' in braille } export const mapBrailleToNumber = { @@ -58,7 +62,7 @@ export const mapBrailleToNumber = { export const mapBrailleToPunctuation = { - /* simple braille to punctuation */ + /* translating one-letter Braille sequences into punctuation */ "⠦": "(", "⠴": ")", "⠷": "[", @@ -77,11 +81,12 @@ export const mapBrailleToPunctuation = { "⠌": "/", "⠐": "'", "⠤": "-", + "⠹": "%", - /* double brailles to punctuation */ - "⠘⠉": "¢", - "⠘⠎": "$", - "⠘⠑": "€", + /* translating two-letter Braille sequences into punctuation */ + "⠘⠉": "¢", + "⠘⠎": "$", + "⠘⠑": "€", "⠘⠇": "£", "⠘⠽": "¥", "⠠⠷": "{", @@ -92,19 +97,24 @@ export const mapBrailleToPunctuation = { "⠘⠼": "#", "⠘⠲": "†", "⠘⠒": "~", - "⠤⠤": "–" + "⠤⠤": "–", + "⠹⠹": "‰", + "⠼⠪" : "<", + "⠼⠕" : ">", + + /* translating three-letter Braille sequences into punctuation (not yet tested and requires adjustments in the brailleTranslator code) */ + "⠦⠉⠴": "©", + "⠦⠗⠴": "®", - /* triple brailles to punctuation */ - // add more characters + /* translating four-letter Braille sequences into punctuation (not yet tested and requires adjustments in the brailleTranslator code) */ + "⠦⠞⠍⠴": "™", }; /* missing: - -single: %, - -double: ‰, <, >, +single: "•" +double: */ \ No newline at end of file diff --git a/src/functions/translator/brailleTranslator.js b/src/functions/translator/brailleTranslator.js index 72f8490..96506ad 100644 --- a/src/functions/translator/brailleTranslator.js +++ b/src/functions/translator/brailleTranslator.js @@ -28,22 +28,17 @@ export default function brailleTranslator(braillePhrase) { continue } - if ((newChar = brailleCharToLetter(currentBrailleChar))) { - newPhrase += newChar - continue - } - - if (i + 1 < braillePhrase.length) { // If longer than the current phrase's length + if (i +1 <= braillePhrase.length) { // If equals or longer than the current phrase's length //Check for next character - let nextChar = braillePhrase.charAt(i + 1) + let nextChar = braillePhrase.charAt(i +1) // add current and next symbols together const doubleSymbols = currentBrailleChar + nextChar if (isIgnoreSymbol(doubleSymbols)) { newPhrase += doubleSymbols - i++ // should this be +2 ? + i += 2 continue } @@ -52,11 +47,16 @@ export default function brailleTranslator(braillePhrase) { if (newChar) { newPhrase += newChar - i++ // should this be +2 ? + i += 2 continue } } + if ((newChar = brailleCharToLetter(currentBrailleChar))) { + newPhrase += newChar + continue + } + if ((newChar = brailleCharToPunctuation(currentBrailleChar))) { newPhrase += newChar continue