Skip to content

Commit b570656

Browse files
JLHwungmathiasbynens
authored andcommitted
Generate correction aliases from historical two-field data
Register and bundle NameAliases.txt for Unicode 5.0 through 6.0, and interpret records without a type field as correction aliases. Assisted-By: GPT-6 Issue: #110
1 parent e82c9ef commit b570656

8 files changed

Lines changed: 196 additions & 1 deletion

‎data/5.0.0-name-aliases.txt‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# NameAliases-5.0.0.txt
2+
# Date: 2006-05-25, 11:10:00 PST [AF/KW]
3+
#
4+
# This file is a normative contributory data file in the
5+
# Unicode Character Database.
6+
#
7+
# Copyright (c) 2005-2006 Unicode, Inc.
8+
# For terms of use, see http://www.unicode.org/terms_of_use.html
9+
#
10+
# This file defines the formal name aliases for Unicode characters.
11+
#
12+
# For informative aliases see NamesList.txt
13+
#
14+
# For documentation, see UCD.html and NamesList.html
15+
#
16+
# FORMAT
17+
#
18+
# Each line has two fields
19+
# First field: Code point
20+
# Second field: Alias
21+
#
22+
# In case multiple aliases are assigned, additional aliases
23+
# would be provided on separate lines
24+
#
25+
#-----------------------------------------------------------------
26+
01A2;LATIN CAPITAL LETTER GHA
27+
01A3;LATIN SMALL LETTER GHA
28+
0CDE;KANNADA LETTER LLLA
29+
0E9D;LAO LETTER FO FON
30+
0E9F;LAO LETTER FO FAY
31+
0EA3;LAO LETTER RO
32+
0EA5;LAO LETTER LO
33+
0FD0;TIBETAN MARK BKA- SHOG GI MGO RGYAN
34+
A015;YI SYLLABLE ITERATION MARK
35+
FE18;PRESENTATION FORM FOR VERTICAL RIGHT WHITE LENTICULAR BRACKET
36+
1D0C5;BYZANTINE MUSICAL SYMBOL FTHORA SKLIRON CHROMA VASIS
37+
38+
# Total code points: 11
39+
40+
# EOF

‎data/5.1.0-name-aliases.txt‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# NameAliases-5.1.0.txt
2+
# Date: 2008-02-11, 11:36:00 PST [KW]
3+
#
4+
# This file is a normative contributory data file in the
5+
# Unicode Character Database.
6+
#
7+
# Copyright (c) 2005-2008 Unicode, Inc.
8+
# For terms of use, see http://www.unicode.org/terms_of_use.html
9+
#
10+
# This file defines the formal name aliases for Unicode characters.
11+
#
12+
# For informative aliases see NamesList.txt
13+
#
14+
# For documentation, see UCD.html and NamesList.html
15+
#
16+
# FORMAT
17+
#
18+
# Each line has two fields
19+
# First field: Code point
20+
# Second field: Alias
21+
#
22+
# In case multiple aliases are assigned, additional aliases
23+
# would be provided on separate lines
24+
#
25+
#-----------------------------------------------------------------
26+
01A2;LATIN CAPITAL LETTER GHA
27+
01A3;LATIN SMALL LETTER GHA
28+
0CDE;KANNADA LETTER LLLA
29+
0E9D;LAO LETTER FO FON
30+
0E9F;LAO LETTER FO FAY
31+
0EA3;LAO LETTER RO
32+
0EA5;LAO LETTER LO
33+
0FD0;TIBETAN MARK BKA- SHOG GI MGO RGYAN
34+
A015;YI SYLLABLE ITERATION MARK
35+
FE18;PRESENTATION FORM FOR VERTICAL RIGHT WHITE LENTICULAR BRACKET
36+
1D0C5;BYZANTINE MUSICAL SYMBOL FTHORA SKLIRON CHROMA VASIS
37+
38+
# Total code points: 11
39+
40+
# EOF

‎data/5.2.0-name-aliases.txt‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# NameAliases-5.2.0.txt
2+
# Date: 2009-05-22, 13:05:00 PDT [KW]
3+
#
4+
# This file is a normative contributory data file in the
5+
# Unicode Character Database.
6+
#
7+
# Copyright (c) 2005-2009 Unicode, Inc.
8+
# For terms of use, see http://www.unicode.org/terms_of_use.html
9+
#
10+
# This file defines the formal name aliases for Unicode characters.
11+
#
12+
# For informative aliases see NamesList.txt
13+
#
14+
# For documentation, see NamesList.html and http://www.unicode.org/reports/tr44/
15+
#
16+
# FORMAT
17+
#
18+
# Each line has two fields
19+
# First field: Code point
20+
# Second field: Alias
21+
#
22+
# In case multiple aliases are assigned, additional aliases
23+
# would be provided on separate lines
24+
#
25+
#-----------------------------------------------------------------
26+
01A2;LATIN CAPITAL LETTER GHA
27+
01A3;LATIN SMALL LETTER GHA
28+
0CDE;KANNADA LETTER LLLA
29+
0E9D;LAO LETTER FO FON
30+
0E9F;LAO LETTER FO FAY
31+
0EA3;LAO LETTER RO
32+
0EA5;LAO LETTER LO
33+
0FD0;TIBETAN MARK BKA- SHOG GI MGO RGYAN
34+
A015;YI SYLLABLE ITERATION MARK
35+
FE18;PRESENTATION FORM FOR VERTICAL RIGHT WHITE LENTICULAR BRACKET
36+
1D0C5;BYZANTINE MUSICAL SYMBOL FTHORA SKLIRON CHROMA VASIS
37+
38+
# Total code points: 11
39+
40+
# EOF

‎data/6.0.0-name-aliases.txt‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# NameAliases-6.0.0.txt
2+
# Date: 2010-05-10, 11:58:00 PDT [KW]
3+
#
4+
# This file is a normative contributory data file in the
5+
# Unicode Character Database.
6+
#
7+
# Copyright (c) 2005-2010 Unicode, Inc.
8+
# For terms of use, see http://www.unicode.org/terms_of_use.html
9+
#
10+
# This file defines the formal name aliases for Unicode characters.
11+
#
12+
# For informative aliases see NamesList.txt
13+
#
14+
# For documentation, see NamesList.html and http://www.unicode.org/reports/tr44/
15+
#
16+
# FORMAT
17+
#
18+
# Each line has two fields
19+
# First field: Code point
20+
# Second field: Alias
21+
#
22+
# In case multiple aliases are assigned, additional aliases
23+
# would be provided on separate lines
24+
#
25+
#-----------------------------------------------------------------
26+
01A2;LATIN CAPITAL LETTER GHA
27+
01A3;LATIN SMALL LETTER GHA
28+
0CDE;KANNADA LETTER LLLA
29+
0E9D;LAO LETTER FO FON
30+
0E9F;LAO LETTER FO FAY
31+
0EA3;LAO LETTER RO
32+
0EA5;LAO LETTER LO
33+
0FD0;TIBETAN MARK BKA- SHOG GI MGO RGYAN
34+
A015;YI SYLLABLE ITERATION MARK
35+
FE18;PRESENTATION FORM FOR VERTICAL RIGHT WHITE LENTICULAR BRACKET
36+
1D0C5;BYZANTINE MUSICAL SYMBOL FTHORA SKLIRON CHROMA VASIS
37+
38+
# Total code points: 11
39+
40+
# EOF

‎data/resources.mjs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ const resources = [
206206
scripts: 'https://unicode.org/Public/5.0.0/ucd/Scripts.txt',
207207
blocks: 'https://unicode.org/Public/5.0.0/ucd/Blocks.txt',
208208
properties: 'https://unicode.org/Public/5.0.0/ucd/PropList.txt',
209+
'name-aliases': 'https://unicode.org/Public/5.0.0/ucd/NameAliases.txt',
209210
'derived-binary-properties':
210211
'https://unicode.org/Public/5.0.0/ucd/extracted/DerivedBinaryProperties.txt',
211212
'derived-core-properties':
@@ -238,6 +239,7 @@ const resources = [
238239
scripts: 'https://unicode.org/Public/5.1.0/ucd/Scripts.txt',
239240
blocks: 'https://unicode.org/Public/5.1.0/ucd/Blocks.txt',
240241
properties: 'https://unicode.org/Public/5.1.0/ucd/PropList.txt',
242+
'name-aliases': 'https://unicode.org/Public/5.1.0/ucd/NameAliases.txt',
241243
'derived-binary-properties':
242244
'https://unicode.org/Public/5.1.0/ucd/extracted/DerivedBinaryProperties.txt',
243245
'derived-core-properties':
@@ -270,6 +272,7 @@ const resources = [
270272
scripts: 'https://unicode.org/Public/5.2.0/ucd/Scripts.txt',
271273
blocks: 'https://unicode.org/Public/5.2.0/ucd/Blocks.txt',
272274
properties: 'https://unicode.org/Public/5.2.0/ucd/PropList.txt',
275+
'name-aliases': 'https://unicode.org/Public/5.2.0/ucd/NameAliases.txt',
273276
'derived-binary-properties':
274277
'https://unicode.org/Public/5.2.0/ucd/extracted/DerivedBinaryProperties.txt',
275278
'derived-core-properties':
@@ -304,6 +307,7 @@ const resources = [
304307
'https://unicode.org/Public/6.0.0/ucd/ScriptExtensions.txt',
305308
blocks: 'https://unicode.org/Public/6.0.0/ucd/Blocks.txt',
306309
properties: 'https://unicode.org/Public/6.0.0/ucd/PropList.txt',
310+
'name-aliases': 'https://unicode.org/Public/6.0.0/ucd/NameAliases.txt',
307311
'derived-binary-properties':
308312
'https://unicode.org/Public/6.0.0/ucd/extracted/DerivedBinaryProperties.txt',
309313
'derived-core-properties':

‎scripts/parse-name-aliases.mjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ const parseNameAliases = async (version) => {
1616
const data = record.split(';').map((field) => field.trim());
1717
const codePoint = parseInt(data[0], 16);
1818
const name = data[1];
19-
const type = data[2];
19+
// Before Unicode 6.1, the two-field format lists only name corrections.
20+
const type = data[2] ?? 'correction';
2021

2122
if (!isNaN(codePoint)) {
2223
if (map[type] === undefined) {

‎tests/parser-formats.mjs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,21 @@ test('Name aliases ignore inline comments without splitting alias groups', async
180180
});
181181
});
182182

183+
test('Two-field historical name aliases are corrections', async (t) => {
184+
t.mock.method(
185+
utils,
186+
'readDataFile',
187+
() =>
188+
' # Historical format\n01A2;LATIN CAPITAL LETTER GHA # corrected name\n01A3; LATIN SMALL LETTER GHA\n',
189+
);
190+
t.assert.deepEqual(await parseNameAliases('6.0.0'), {
191+
correction: {
192+
418: ['LATIN CAPITAL LETTER GHA'],
193+
419: ['LATIN SMALL LETTER GHA'],
194+
},
195+
});
196+
});
197+
183198
test('Emoji properties accept compact and padded field separators', async (t) => {
184199
let source;
185200
t.mock.method(utils, 'readDataFile', () => source);

‎tests/parsers.mjs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import parseDecompositionMapping from '../scripts/parse-decomposition-mapping.mj
88
import parseIndicConjunctBreak from '../scripts/parse-indic-conjunct-break.mjs';
99
import parseJoiningType from '../scripts/parse-joining-type.mjs';
1010
import parseSimpleCaseMapping from '../scripts/parse-simple-case-mapping.mjs';
11+
import parseNameAliases from '../scripts/parse-name-aliases.mjs';
1112
import {
1213
parseBlocks,
1314
parseDerivedCoreProperties,
@@ -16,6 +17,20 @@ import {
1617
parseScripts,
1718
} from '../scripts/parse-blocks-scripts-properties.mjs';
1819

20+
test('Unicode 5.0 through 6.0 provide their historical correction aliases', async (t) => {
21+
for (const version of ['5.0.0', '5.1.0', '5.2.0', '6.0.0']) {
22+
const aliases = await parseNameAliases(version);
23+
t.assert.deepEqual(Object.keys(aliases), ['correction']);
24+
t.assert.equal(Object.keys(aliases.correction).length, 11);
25+
t.assert.deepEqual(aliases.correction[0x1a2], ['LATIN CAPITAL LETTER GHA']);
26+
t.assert.deepEqual(aliases.correction[0x1a3], ['LATIN SMALL LETTER GHA']);
27+
t.assert.deepEqual(aliases.correction[0x1d0c5], [
28+
'BYZANTINE MUSICAL SYMBOL FTHORA SKLIRON CHROMA VASIS',
29+
]);
30+
}
31+
t.assert.equal(await parseNameAliases('4.1.0'), undefined);
32+
});
33+
1934
test('Historical titlecase digraphs retain their identity mapping', async (t) => {
2035
for (const version of ['1.1.5', '2.0.14', '3.2.0', '4.0.0', '18.0.0']) {
2136
const { Titlecase, Uppercase } = await parseSimpleCaseMapping(version);

0 commit comments

Comments
 (0)