From cea30465d8acf6333a2fde3b4008818e91cd6de4 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Wed, 7 Nov 2018 15:07:54 +0000 Subject: [PATCH] Changed 'Remove Letter Accents' to 'Remove Diacritics' --- src/core/config/Categories.json | 2 +- ...veLetterAccents.mjs => RemoveDiacritics.mjs} | 17 ++++++++--------- test/index.mjs | 2 +- ...veLetterAccents.mjs => RemoveDiacritics.mjs} | 6 +++--- 4 files changed, 13 insertions(+), 14 deletions(-) rename src/core/operations/{RemoveLetterAccents.mjs => RemoveDiacritics.mjs} (60%) rename test/tests/operations/{RemoveLetterAccents.mjs => RemoveDiacritics.mjs} (87%) diff --git a/src/core/config/Categories.json b/src/core/config/Categories.json index 758fe880..1891c460 100755 --- a/src/core/config/Categories.json +++ b/src/core/config/Categories.json @@ -168,7 +168,7 @@ "ops": [ "Encode text", "Decode text", - "Remove Letter Accents", + "Remove Diacritics", "Unescape Unicode Characters" ] }, diff --git a/src/core/operations/RemoveLetterAccents.mjs b/src/core/operations/RemoveDiacritics.mjs similarity index 60% rename from src/core/operations/RemoveLetterAccents.mjs rename to src/core/operations/RemoveDiacritics.mjs index a8fdb6e4..217fafe1 100644 --- a/src/core/operations/RemoveLetterAccents.mjs +++ b/src/core/operations/RemoveDiacritics.mjs @@ -7,24 +7,23 @@ import Operation from "../Operation"; /** - * Remove Letter Accents operation + * Remove Diacritics operation */ -class RemoveLetterAccents extends Operation { +class RemoveDiacritics extends Operation { /** - * RemoveLetterAccents constructor + * RemoveDiacritics constructor */ constructor() { super(); - this.name = "Remove Letter Accents"; + this.name = "Remove Diacritics"; this.module = "Default"; this.description = "Replaces accented characters with their latin character equivalent."; - this.infoURL = ""; + this.infoURL = "https://wikipedia.org/wiki/Diacritic"; this.inputType = "string"; this.outputType = "string"; - this.args = [ - ]; + this.args = []; } /** @@ -33,10 +32,10 @@ class RemoveLetterAccents extends Operation { * @returns {string} */ run(input, args) { - //reference: https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript/37511463 + // reference: https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript/37511463 return input.normalize("NFD").replace(/[\u0300-\u036f]/g, ""); } } -export default RemoveLetterAccents; +export default RemoveDiacritics; diff --git a/test/index.mjs b/test/index.mjs index 03ffa9d2..e40ad9d0 100644 --- a/test/index.mjs +++ b/test/index.mjs @@ -63,7 +63,7 @@ import "./tests/operations/ParseIPRange"; import "./tests/operations/PowerSet"; import "./tests/operations/Regex"; import "./tests/operations/Register"; -import "./tests/operations/RemoveLetterAccents"; +import "./tests/operations/RemoveDiacritics"; import "./tests/operations/Rotate"; import "./tests/operations/SeqUtils"; import "./tests/operations/SetDifference"; diff --git a/test/tests/operations/RemoveLetterAccents.mjs b/test/tests/operations/RemoveDiacritics.mjs similarity index 87% rename from test/tests/operations/RemoveLetterAccents.mjs rename to test/tests/operations/RemoveDiacritics.mjs index 638cbea1..52bf188f 100644 --- a/test/tests/operations/RemoveLetterAccents.mjs +++ b/test/tests/operations/RemoveDiacritics.mjs @@ -1,6 +1,6 @@ /** - * Remove Letter Accents tests. + * Remove Diacritics tests. * * @author Klaxon [klaxon@veyr.com] * @copyright Crown Copyright 2017 @@ -10,12 +10,12 @@ import TestRegister from "../../TestRegister"; TestRegister.addTests([ { - name: "Remove Letter Accents", + name: "Remove Diacritics", input: "\xe0, \xe8, \xec, \xf2, \xf9 \xc0, \xc8, \xcc, \xd2, \xd9\n\xe1, \xe9, \xed, \xf3, \xfa, \xfd \xc1, \xc9, \xcd, \xd3, \xda, \xdd\n\xe2, \xea, \xee, \xf4, \xfb \xc2, \xca, \xce, \xd4, \xdb\n\xe3, \xf1, \xf5 \xc3, \xd1, \xd5\n\xe4, \xeb, \xef, \xf6, \xfc, \xff \xc4, \xcb, \xcf, \xd6, \xdc, \u0178\n\xe5, \xc5", expectedOutput: "a, e, i, o, u A, E, I, O, U\na, e, i, o, u, y A, E, I, O, U, Y\na, e, i, o, u A, E, I, O, U\na, n, o A, N, O\na, e, i, o, u, y A, E, I, O, U, Y\na, A", recipeConfig: [ { - "op": "Remove Letter Accents", + "op": "Remove Diacritics", "args": [] }, ],