Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UCDXML and TR42 v2 #1030

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ perf-*.xml
test-*.xml

# Directories
.idea/
.settings/
.vs/
.vscode/
Expand Down
69 changes: 69 additions & 0 deletions docs/ucdxml.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# UCDXML

There are three separate processes for generating and validating UCDXML files and their corresponding UAX42 report.

1. Generate the UCDXML files.
2. (Optional) You can compare the generated UCDXML files against each other (e.g., Flat vs Grouped) or against
previous versions.
3. Generate UAX42. There are three steps involved:

1. Generate the property value fragments. The updated versions should live in
unicodetools/src/main/resources/org/unicode/uax42/fragments
2. Generate the index.html and index.rnc files for UAX42.
3. (Optional) Validate the UCDXML files using index.rnc.

## Generate UCDXML files

- You can generate flat or grouped versions of UCDXML.
- You can generate UCDXML files for:
- the full range of code points
- the Unihan code points
- code points that are not Unihan code points

```
mvn compile exec:java '-Dexec.mainClass="org.unicode.xml.UCDXML"' '-Dexec.args="--range ALL --output FLAT"' -DCLDR_DIR=$(cd ../cldr; pwd) -DUNICODETOOLS_GEN_DIR=$(cd ../Generated; pwd) -DUNICODETOOLS_REPO_DIR=$(pwd)
mvn compile exec:java '-Dexec.mainClass="org.unicode.xml.UCDXML"' '-Dexec.args="--range UNIHAN --output FLAT"' -DCLDR_DIR=$(cd ../cldr; pwd) -DUNICODETOOLS_GEN_DIR=$(cd ../Generated; pwd) -DUNICODETOOLS_REPO_DIR=$(pwd)
mvn compile exec:java '-Dexec.mainClass="org.unicode.xml.UCDXML"' '-Dexec.args="--range NOUNIHAN --output FLAT"' -DCLDR_DIR=$(cd ../cldr; pwd) -DUNICODETOOLS_GEN_DIR=$(cd ../Generated; pwd) -DUNICODETOOLS_REPO_DIR=$(pwd)
mvn compile exec:java '-Dexec.mainClass="org.unicode.xml.UCDXML"' '-Dexec.args="--range ALL --output GROUPED"' -DCLDR_DIR=$(cd ../cldr; pwd) -DUNICODETOOLS_GEN_DIR=$(cd ../Generated; pwd) -DUNICODETOOLS_REPO_DIR=$(pwd)
mvn compile exec:java '-Dexec.mainClass="org.unicode.xml.UCDXML"' '-Dexec.args="--range UNIHAN --output GROUPED"' -DCLDR_DIR=$(cd ../cldr; pwd) -DUNICODETOOLS_GEN_DIR=$(cd ../Generated; pwd) -DUNICODETOOLS_REPO_DIR=$(pwd)
mvn compile exec:java '-Dexec.mainClass="org.unicode.xml.UCDXML"' '-Dexec.args="--range NOUNIHAN --output GROUPED"' -DCLDR_DIR=$(cd ../cldr; pwd) -DUNICODETOOLS_GEN_DIR=$(cd ../Generated; pwd) -DUNICODETOOLS_REPO_DIR=$(pwd)
```

## Compare UCDXML files

After generating UCDXML files, you can compare:

- Different versions of the same type (range and output) of UCDXML file
- Grouped and flat versions of the same code point range

```
mvn compile exec:java '-Dexec.mainClass="org.unicode.xml.CompareUCDXML"' '-Dexec.args="-a {path to file} -b {path to file}"'
```

## Generating TR42

### Step 1 - Generate property value fragments

```
mvn compile exec:java '-Dexec.mainClass="org.unicode.xml.GeneratePropertyValues"' -DCLDR_DIR=$(cd ../cldr ; pwd) -DUNICODETOOLS_GEN_DIR=$(cd ../Generated ; pwd) -DUNICODETOOLS_REPO_DIR=$(pwd)
```

UAX42 fragments live in unicodetools/src/main/resources/org/unicode/uax42/fragments

### Step 2 - Generate TR42 index.html and index.rnc

```
mvn xml:transform -f $(cd ./unicodetools/src/main/resources/org/unicode/uax42; pwd) -Doutputdir=$(cd ../Generated/uax42; pwd)
```

### Step 3 - Validate generated UAX XML files

You'll need a [RELAX NG](https://relaxng.org/) schema validator.
We'll use [jing-trang](https://github.com/relaxng/jing-trang) in this example.

1. Clone and build [jing-trang](https://github.com/relaxng/jing-trang)
2. Run the following:
```
java -jar C:\_git\jing-trang\build\jing.jar -c UNICODETOOLS_REPO_DIR\uax\uax42\output\index.rnc <path to UAX xml file>
```
Note that the UAX xml file has to be saved as NFD as the Unihan syntax regular expressions are expecting NFD.
4 changes: 4 additions & 0 deletions unicodetools/src/main/java/org/unicode/props/UcdProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,16 @@ public enum UcdProperty {
Emoji_SB(PropertyType.Miscellaneous, "ESB"),
ISO_Comment(PropertyType.Miscellaneous, "isc"),
Jamo_Short_Name(PropertyType.Miscellaneous, "JSN"),
NC_Corrected(PropertyType.Miscellaneous, "ncCorrected"),
NC_Original(PropertyType.Miscellaneous, "ncOriginal"),
NC_Version(PropertyType.Miscellaneous, "ncVersion"),
Name(PropertyType.Miscellaneous, "na"),
Name_Alias(PropertyType.Miscellaneous, null, ValueCardinality.Unordered, "Name_Alias"),
Named_Sequences(PropertyType.Miscellaneous, "NS"),
Named_Sequences_Prov(PropertyType.Miscellaneous, "NSP"),
Standardized_Variant(PropertyType.Miscellaneous, null, ValueCardinality.Unordered, "SV"),
Unicode_1_Name(PropertyType.Miscellaneous, "na1"),
emoji_variation_sequence(PropertyType.Miscellaneous, "EVS"),
kAlternateHanYu(PropertyType.Miscellaneous, "cjkAlternateHanYu"),
kAlternateJEF(PropertyType.Miscellaneous, "cjkAlternateJEF"),
kAlternateKangXi(PropertyType.Miscellaneous, "cjkAlternateKangXi"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ public static East_Asian_Width_Values forName(String name) {
// Emoji_DCM
// Emoji_KDDI
// Emoji_SB
// emoji_variation_sequence
// Equivalent_Unified_Ideograph
// FC_NFKC_Closure
public enum General_Category_Values implements Named {
Expand Down Expand Up @@ -1668,6 +1669,9 @@ public static Line_Break_Values forName(String name) {
// Name_Alias
// Named_Sequences
// Named_Sequences_Prov
// NC_Corrected
// NC_Original
// NC_Version
public enum NFC_Quick_Check_Values implements Named {
Maybe("M"),
No("N"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,8 @@ public static void doSb(String outputDir) throws IOException {
// try {
// copy(new URL(url), new File(outputDir + "/sb","sb_" + code + ".gif"));
//// BufferedImage sourceImage = ImageIO.read(new URL(url));
//// writeImage(sourceImage,outputDir + "/sb","sb_" + code, "gif");
//// writeImage(sourceImage,outputDir + "/sb","sb_" + code,
// "gif");
// System.out.println(code);
// } catch (Exception e) {
// System.out.println("Skipping " + code);
Expand Down
Loading
Loading