[iso_3166-2] remove hash field, rank code and name first
Browse files
README.md
CHANGED
|
@@ -2,7 +2,6 @@
|
|
| 2 |
tags:
|
| 3 |
- name
|
| 4 |
- lang
|
| 5 |
-
- hash
|
| 6 |
- iso-3166
|
| 7 |
- subdivisions
|
| 8 |
configs:
|
|
@@ -50,22 +49,20 @@ dataset_info:
|
|
| 50 |
dataset_size: 1167519
|
| 51 |
---
|
| 52 |
|
| 53 |
-
# ISO 3166-2 Subdivision Codes with Lang
|
| 54 |
|
| 55 |
-
Regional subdivision codes with language selection
|
| 56 |
|
| 57 |
## Fields
|
| 58 |
|
| 59 |
- **code** (string): ISO 3166-2 subdivision code (e.g., 'US-CA', 'RU-MOW')
|
| 60 |
-
- **region** (string): Parent ISO 3166-1 alpha-2 region code
|
| 61 |
- **name** (string): Primary name in selected language
|
|
|
|
| 62 |
- **name_en** (string): English name
|
| 63 |
- **name_ru** (string): Russian name
|
| 64 |
- **name_zh** (string): Chinese name
|
| 65 |
- **lang** (string): Language of primary name field (en, ru, or zh)
|
| 66 |
- Determined by parent region's language rule
|
| 67 |
-
- **hash** (string): SHA256 hash of `name` field (64 hex chars)
|
| 68 |
-
- Used for sharding and collision detection
|
| 69 |
- **parent** (string): Parent subdivision code (if applicable)
|
| 70 |
- **children** (list): Child subdivision codes
|
| 71 |
- **names_en_alt** (list): Alternative English names
|
|
@@ -79,14 +76,6 @@ Regional subdivision codes with language selection and deterministic hashing.
|
|
| 79 |
|
| 80 |
Languages are determined by parent region using hardcoded mapping (same as iso_3166-1_alpha-2).
|
| 81 |
|
| 82 |
-
## Hash Field
|
| 83 |
-
|
| 84 |
-
The `hash` field is the SHA256 hash of the `name` field:
|
| 85 |
-
- Format: 64-character hexadecimal string
|
| 86 |
-
- Deterministic: same name always produces same hash
|
| 87 |
-
- Used for entry sharding in doc repositories (first 6 hex chars = shard ID)
|
| 88 |
-
- Enables collision detection
|
| 89 |
-
|
| 90 |
## Usage
|
| 91 |
|
| 92 |
```python
|
|
@@ -98,17 +87,16 @@ ru_subdivs = ds.filter(lambda x: x['region'] == 'RU')
|
|
| 98 |
print(ru_subdivs[0])
|
| 99 |
# {
|
| 100 |
# 'code': 'RU-MOW',
|
| 101 |
-
# 'region': 'RU',
|
| 102 |
# 'name': 'Москва',
|
|
|
|
| 103 |
# 'lang': 'ru',
|
| 104 |
-
# 'hash': '...'
|
| 105 |
# }
|
| 106 |
```
|
| 107 |
|
| 108 |
## See Also
|
| 109 |
|
| 110 |
-
- `cterdam/iso_3166-1_alpha-2`: Countries/regions with lang
|
| 111 |
-
- `cterdam/iata-metro`: IATA metro codes with lang and
|
| 112 |
|
| 113 |
|
| 114 |
## Invariants
|
|
@@ -128,19 +116,13 @@ All entries in this dataset maintain the following invariants (verified by `test
|
|
| 128 |
- **Sinophone regions** (CN, TW, HK, JP, etc.) → `lang: zh`
|
| 129 |
- **All others** → `lang: en`
|
| 130 |
|
| 131 |
-
### Hash Field
|
| 132 |
-
- **Required**: Every entry with a non-null `name` has a `hash` field
|
| 133 |
-
- **Format**: 64-character hexadecimal string (SHA256)
|
| 134 |
-
- **Constraint**: `hash == SHA256(name)`
|
| 135 |
-
- **Usage**: First 6 hex digits used for sharding in source repositories
|
| 136 |
-
|
| 137 |
## Verify Invariants
|
| 138 |
|
| 139 |
Clone the dataset and run tests:
|
| 140 |
|
| 141 |
\`\`\`bash
|
| 142 |
-
git clone https://huggingface.co/datasets/cterdam/iso_3166-
|
| 143 |
-
cd iso_3166-
|
| 144 |
|
| 145 |
# Install dependencies
|
| 146 |
pip install datasets
|
|
|
|
| 2 |
tags:
|
| 3 |
- name
|
| 4 |
- lang
|
|
|
|
| 5 |
- iso-3166
|
| 6 |
- subdivisions
|
| 7 |
configs:
|
|
|
|
| 49 |
dataset_size: 1167519
|
| 50 |
---
|
| 51 |
|
| 52 |
+
# ISO 3166-2 Subdivision Codes with Lang
|
| 53 |
|
| 54 |
+
Regional subdivision codes with language selection.
|
| 55 |
|
| 56 |
## Fields
|
| 57 |
|
| 58 |
- **code** (string): ISO 3166-2 subdivision code (e.g., 'US-CA', 'RU-MOW')
|
|
|
|
| 59 |
- **name** (string): Primary name in selected language
|
| 60 |
+
- **region** (string): Parent ISO 3166-1 alpha-2 region code
|
| 61 |
- **name_en** (string): English name
|
| 62 |
- **name_ru** (string): Russian name
|
| 63 |
- **name_zh** (string): Chinese name
|
| 64 |
- **lang** (string): Language of primary name field (en, ru, or zh)
|
| 65 |
- Determined by parent region's language rule
|
|
|
|
|
|
|
| 66 |
- **parent** (string): Parent subdivision code (if applicable)
|
| 67 |
- **children** (list): Child subdivision codes
|
| 68 |
- **names_en_alt** (list): Alternative English names
|
|
|
|
| 76 |
|
| 77 |
Languages are determined by parent region using hardcoded mapping (same as iso_3166-1_alpha-2).
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
## Usage
|
| 80 |
|
| 81 |
```python
|
|
|
|
| 87 |
print(ru_subdivs[0])
|
| 88 |
# {
|
| 89 |
# 'code': 'RU-MOW',
|
|
|
|
| 90 |
# 'name': 'Москва',
|
| 91 |
+
# 'region': 'RU',
|
| 92 |
# 'lang': 'ru',
|
|
|
|
| 93 |
# }
|
| 94 |
```
|
| 95 |
|
| 96 |
## See Also
|
| 97 |
|
| 98 |
+
- `cterdam/iso_3166-1_alpha-2`: Countries/regions with lang
|
| 99 |
+
- `cterdam/iata-metro`: IATA metro codes with lang and coordinates
|
| 100 |
|
| 101 |
|
| 102 |
## Invariants
|
|
|
|
| 116 |
- **Sinophone regions** (CN, TW, HK, JP, etc.) → `lang: zh`
|
| 117 |
- **All others** → `lang: en`
|
| 118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
## Verify Invariants
|
| 120 |
|
| 121 |
Clone the dataset and run tests:
|
| 122 |
|
| 123 |
\`\`\`bash
|
| 124 |
+
git clone https://huggingface.co/datasets/cterdam/iso_3166-2
|
| 125 |
+
cd iso_3166-2
|
| 126 |
|
| 127 |
# Install dependencies
|
| 128 |
pip install datasets
|