Skip to content

Commit

Permalink
Update ALLOWED_CHARS in constants.ts to include additional characters.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioanlucut committed Sep 29, 2023
1 parent b845f54 commit 0c34c2e
Show file tree
Hide file tree
Showing 9 changed files with 410 additions and 370 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Acest repository conține cântări scrise/folosite de trupele de laudă și în

_inspirat din `EasySlides`, `OpenSongs` și https://www.learnchordal.com/how-to-read-charts_.

Formatul folosit este unul simplu, similar cu cel din `OpenSong`, după cum urmează:
Formatul folosit este unul simplu, după cum urmează:

```
[title]
Expand Down Expand Up @@ -123,24 +123,24 @@ Domn al veșniciei, în veci! Amin!

#### Caractere

Caracterele pe care le putem folosi sunt foarte importante, așa că am definit o listă pe care o putem folosi:
Caracterele pe care le putem folosi sunt foarte importante, așa că am definit o listă:

```
!(),-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZY[\]abcdefghijklmnopqrstuvwxyzÎâîăÂȘșĂȚț’”„
*_{}&!(),-./][1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZYQabcdefghijklmnopqrstuvwxyzÎâîăÂȘșĂȚț‘’”„\n
```

Întrucât sunt foarte multe versiuni ale caracterelor e.g. `ş` în loc de `ș`, e nevoie să folosim aceleași caractere cu
același format unicode. Un exemplu de variațiuni poate fi văzut aici: https://www.compart.com/en/unicode/U+201D.
> Detalii despre `‘’` poți să găsești și aici: https://github.com/ioanlucut/bes-lyrics/issues/105.
#### Dacă vrei să imporți cântece din resurse creștine

- Asigură-te că ultima versiune a repo-ului https://github.com/ioanlucut/bes-lyrics-parser este instalată in același
folder părinte cu acest repository.
- Copiază ID-ul din URL. E.g. https://www.resursecrestine.ro/cantece/212152/cuvantul-intrupat (-> **212152**)
- Copiază `ID`-ul din `URL`. E.g. https://www.resursecrestine.ro/cantece/212152/cuvantul-intrupat (-> **212152**)
- Adaugă-l în fișierul `temp_runners/rc_ids_to_process.txt` într-o linie nouă.
- Rulează scriptul `npm run import:rc:by-ids`
- Rulează scriptul `npm run meta:ci`
- Commit, push & branch nou.
- Branch nou, commit, push și `PR`.

#### Cum poți să te implici altfel?

Expand Down
210 changes: 89 additions & 121 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.1",
"description": "Cântări pentru Biserica Emanuel Sibiu",
"dependencies": {
"@types/nspell": "^2.1.3",
"@types/nspell": "^2.1.4",
"@types/string-similarity": "^4.0.0",
"chalk": "^4.1.2",
"dictionary-ro": "^2.1.0",
Expand All @@ -20,15 +20,15 @@
"devDependencies": {
"@tsconfig/node-lts": "^18.12.5",
"@types/fs-extra": "^11.0.2",
"@types/iconv": "^3.0.1",
"@types/iconv": "^3.0.2",
"@types/jest": "^29.5.5",
"@types/lodash": "^4.14.198",
"@types/lodash": "^4.14.199",
"@types/lodash-es": "^4.17.9",
"@types/node": "^20.6.5",
"@types/recursive-readdir": "^2.2.1",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.7.0",
"eslint": "^8.49.0",
"@types/node": "^20.7.1",
"@types/recursive-readdir": "^2.2.2",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"eslint": "^8.50.0",
"eslint-plugin-require-extensions": "^0.1.3",
"is-ci-cli": "^2.2.0",
"jest": "^29.7.0",
Expand All @@ -37,7 +37,7 @@
"jest-watch-typeahead": "^2.2.2",
"lodash": "^4.17.21",
"prettier": "^3.0.3",
"prettier-plugin-latex": "1.2.4",
"prettier-plugin-latex": "2.0.1",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"tslib": "^2.6.2",
Expand Down
212 changes: 105 additions & 107 deletions src/charsStatsCollector.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,119 +4,117 @@ describe('fileNameNormalizer', () => {
it('should work correctly and not signalize any differences when only allowed chars exist', () => {
const stats = assemblyCharsStats(
'file.txt',
'!(),-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZY' +
'[\\]abcdefghijklmnopqrstuvwxyzÎâîăÂȘșĂȚț’”„!(),-./1234567890:;?' +
'ABCDEFGHIJKLMNOPRSTUVWXZY[\\]abcdefghijklmnopqrstuvwxyzÎâîăÂȘșĂȚț’”„',
'!(),-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZY][abcdefghijklmnopqrstuvwxyzÎâîăÂȘșĂȚț’‘”„!(),-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZY][abcdefghijklmnopqrstuvwxyzÎâîăÂȘșĂȚț’”„',
);

expect(stats.differenceInContent).toHaveLength(0);
expect(stats.differenceInFileName).toHaveLength(0);

expect(stats).toMatchInlineSnapshot(`
{
"differenceInContent": [],
"differenceInFileName": [],
"fileName": "file.txt",
"uniqueCharsFromContent": [
"!",
"(",
")",
",",
"-",
".",
"/",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
":",
";",
"?",
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
"[",
"\\",
"]",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
",
",
",
",
",
",
",
",
",
",
"’",
"”",
"„",
],
"uniqueCharsFromFileName": [
".",
"e",
"f",
"i",
"l",
"t",
"x",
],
}
`);
{
"differenceInContent": [],
"differenceInFileName": [],
"fileName": "file.txt",
"uniqueCharsFromContent": [
"!",
"(",
")",
",",
"-",
".",
"/",
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
":",
";",
"?",
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
"[",
"]",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
",
",
",
",
",
",
",
",
",
",
"‘",
"’",
"”",
"„",
],
"uniqueCharsFromFileName": [
".",
"e",
"f",
"i",
"l",
"t",
"x",
],
}
`);
});

it('should work correctly by signalize differences', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const TXT_EXTENSION = '.txt';
export const TEST_FILE = 'TEMPLATE.txt';

export const ALLOWED_CHARS =
` *_{}&!(),-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZYQ[\\]abcdefghijklmnopqrstuvwxyzÎâîăÂȘșĂȚț’”„\n`.split(
` *_{}&!()][\\,-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZYQabcdefghijklmnopqrstuvwxyzÎâîăÂȘșĂȚț‘’”„\n`.split(
EMPTY_STRING,
);

Expand Down
34 changes: 22 additions & 12 deletions src/core.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
isKnownSongSequence,
} from './core.js';
import { SIMPLE_SONG_MOCK_FILE_CONTENT } from '../mocks/index.js';
import { ALLOWED_CHARS, EMPTY_STRING } from './constants.js';

describe('core', () => {
describe('isKnownSongSequence', () => {
Expand Down Expand Up @@ -119,8 +120,8 @@ describe('core', () => {
describe('computeUniqueContentHash', () => {
it('should work correctly', () => {
expect(
computeUniqueContentHash(SIMPLE_SONG_MOCK_FILE_CONTENT)).
toMatchInlineSnapshot(`"44c93b"`);
computeUniqueContentHash(SIMPLE_SONG_MOCK_FILE_CONTENT),
).toMatchInlineSnapshot(`"44c93b"`);

expect(computeUniqueContentHash(SIMPLE_SONG_MOCK_FILE_CONTENT)).toEqual(
computeUniqueContentHash(SIMPLE_SONG_MOCK_FILE_CONTENT),
Expand All @@ -137,16 +138,16 @@ toMatchInlineSnapshot(`"44c93b"`);

it('should update correctly', () => {
expect(
computeUniqueContentHash(SIMPLE_SONG_MOCK_FILE_CONTENT + ' ')).
toMatchInlineSnapshot(`"543f06"`);
computeUniqueContentHash(SIMPLE_SONG_MOCK_FILE_CONTENT + ' '),
).toMatchInlineSnapshot(`"543f06"`);

expect(
computeUniqueContentHash(SIMPLE_SONG_MOCK_FILE_CONTENT + 'X')).
toMatchInlineSnapshot(`"c3c407"`);
computeUniqueContentHash(SIMPLE_SONG_MOCK_FILE_CONTENT + 'X'),
).toMatchInlineSnapshot(`"c3c407"`);

expect(
computeUniqueContentHash(SIMPLE_SONG_MOCK_FILE_CONTENT + 'Y')).
toMatchInlineSnapshot(`"2a48fa"`);
computeUniqueContentHash(SIMPLE_SONG_MOCK_FILE_CONTENT + 'Y'),
).toMatchInlineSnapshot(`"2a48fa"`);
});
});

Expand Down Expand Up @@ -184,6 +185,15 @@ toMatchInlineSnapshot(`"2a48fa"`);
"[b3]",
"Row for b3",
]
`);
});

it('should work correctly', () => {
expect(getSongInSectionTuples(ALLOWED_CHARS.join(EMPTY_STRING)))
.toMatchInlineSnapshot(`
[
"*_{}&!()][\\,-./1234567890:;?ABCDEFGHIJKLMNOPRSTUVWXZYQabcdefghijklmnopqrstuvwxyzÎâîăÂȘșĂȚț‘’”„",
]
`);
});
});
Expand All @@ -205,10 +215,10 @@ describe('getTitleWithoutMeta', () => {
describe('getMetaSectionsFromTitle', () => {
it('should work correctly', () => {
expect(
getMetaSectionsFromTitle(
'Any title {alternative: {ANY_alternative}, arranger: {ANY_arranger}, band: {ANY_band}, composer: {ANY_composer}, contentHash: {ANY_contentHash}, genre: {ANY_genre}, id: {ANY_id}, interpreter: {ANY_interpreter}, key: {ANY_key}, rcId: {ANY_rcId}, tags: {ANY_tags}, tempo: {ANY_tempo}, title: {ANY_title}, version: {ANY_version}, writer: {ANY_writer}}')).

toMatchInlineSnapshot(`
getMetaSectionsFromTitle(
'Any title {alternative: {ANY_alternative}, arranger: {ANY_arranger}, band: {ANY_band}, composer: {ANY_composer}, contentHash: {ANY_contentHash}, genre: {ANY_genre}, id: {ANY_id}, interpreter: {ANY_interpreter}, key: {ANY_key}, rcId: {ANY_rcId}, tags: {ANY_tags}, tempo: {ANY_tempo}, title: {ANY_title}, version: {ANY_version}, writer: {ANY_writer}}',
),
).toMatchInlineSnapshot(`
{
"alternative": "ANY_alternative",
"arranger": "ANY_arranger",
Expand Down
Loading

0 comments on commit 0c34c2e

Please sign in to comment.