Skip to content

Commit

Permalink
Adjusted the MapBrailleToSwedishCharacters file
Browse files Browse the repository at this point in the history
  • Loading branch information
Björn Bergström committed May 24, 2024
1 parent a2ce480 commit 330cacc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
44 changes: 27 additions & 17 deletions src/data/MapBrailleToSwedishCharacters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -30,17 +34,17 @@ export const mapBrailleToAlpha = {
'⠎': 's',
'⠞': 't',
'⠥': 'u',
'⠳': 'ü',
'⠧': 'v',
'⠺': 'w',
'⠭': 'x',
'⠽': 'y',
'⠵': 'z',
'⠜': 'ä',
'⠡': 'å',
'⠷': 'á', // remove?
'⠪': 'ö',
'⠳': 'ü', // remove?
'⠿': 'é', // remove?

// '⠷': 'á', corresponds to '[' in braille
}

export const mapBrailleToNumber = {
Expand All @@ -58,7 +62,7 @@ export const mapBrailleToNumber = {

export const mapBrailleToPunctuation = {

/* simple braille to punctuation */
/* translating one-letter Braille sequences into punctuation */
"⠦": "(",
"⠴": ")",
"⠷": "[",
Expand All @@ -77,11 +81,12 @@ export const mapBrailleToPunctuation = {
"⠌": "/",
"⠐": "'",
"⠤": "-",
"⠹": "%",

/* double brailles to punctuation */
"⠘⠉": "¢",
"⠘⠎": "$",
"⠘⠑": "€",
/* translating two-letter Braille sequences into punctuation */
"⠘⠉": "¢",
"⠘⠎": "$",
"⠘⠑": "€",
"⠘⠇": "£",
"⠘⠽": "¥",
"⠠⠷": "{",
Expand All @@ -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:
*/
18 changes: 9 additions & 9 deletions src/functions/translator/brailleTranslator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
Expand Down

0 comments on commit 330cacc

Please sign in to comment.