CCB commited on
Commit
e9781b2
·
verified ·
1 Parent(s): 7ca415c

Update README for HW1-style layout

Browse files
Files changed (1) hide show
  1. README.md +32 -140
README.md CHANGED
@@ -1,155 +1,47 @@
1
- ---
2
- language:
3
- - en
4
- - af
5
- - zh
6
- - de
7
- - fi
8
- - fr
9
- - hi
10
- - fa
11
- - ur
12
- - zu
13
- license: cc-by-4.0
14
- task_categories:
15
- - text-classification
16
- - text-generation
17
- task_ids:
18
- - language-modeling
19
- - multi-class-classification
20
- pretty_name: Language Models and City Classification
21
- size_categories:
22
- - 10K<n<100K
23
- tags:
24
- - n-gram
25
- - language-model
26
- - city-classification
27
- - nlp-course
28
- configs:
29
- - config_name: cities
30
- data_files:
31
- - split: train
32
- path: cities/train-*
33
- - split: validation
34
- path: cities/validation-*
35
- - split: test
36
- path: cities/test-*
37
- dataset_info:
38
- config_name: cities
39
- features:
40
- - name: city
41
- dtype: string
42
- - name: country
43
- dtype: string
44
- - name: country_name
45
- dtype: string
46
- splits:
47
- - name: train
48
- num_bytes: 368187
49
- num_examples: 12392
50
- - name: validation
51
- num_bytes: 45988
52
- num_examples: 1548
53
- - name: test
54
- num_bytes: 33400
55
- num_examples: 1554
56
- download_size: 175270
57
- dataset_size: 447575
58
- ---
59
 
60
- # Language Models and City Classification (CIS 5300)
61
 
62
- ## Dataset Description
63
 
64
- This dataset supports two tasks for learning about **n-gram language models**:
65
-
66
- ### 1. Shakespeare Text Generation
67
- Raw text from Shakespeare's collected works (~4.5 MB, 167K lines) for training character-level n-gram language models. Students build models of increasing order (n=1 through n=7) and generate Shakespeare-style text.
68
-
69
- ### 2. City Name Classification
70
- Classify city names by country of origin using character-level language models. The idea: city names from different countries have distinctive character patterns (e.g., German cities often end in "-burg" or "-stadt", Chinese cities have different character distributions).
71
-
72
- **Countries**: Afghanistan, China, Germany, Finland, France, India, Iran, Pakistan, South Africa
73
-
74
- ## Usage
75
-
76
- ### City Classification Task
77
 
78
  ```python
79
  from datasets import load_dataset
80
-
81
- # Load city name classification data
82
  cities = load_dataset("CCB/cis5300-language-models", "cities")
83
- print(cities)
84
- # DatasetDict({
85
- # train: Dataset({features: ['city_name', 'country_code', 'country'], num_rows: 12392})
86
- # validation: Dataset({features: [...], num_rows: 1548})
87
- # test: Dataset({features: [...], num_rows: 1554})
88
- # })
89
-
90
- print(cities["train"][0])
91
- # {'city_name': 'shewah', 'country_code': 'af', 'country': 'Afghanistan'}
92
- ```
93
-
94
- ### Shakespeare Corpus
95
-
96
- ```python
97
- from huggingface_hub import hf_hub_download
98
-
99
- # Download Shakespeare text for language modeling
100
- path = hf_hub_download("CCB/cis5300-language-models", "shakespeare.txt", repo_type="dataset")
101
- with open(path) as f:
102
- text = f.read()
103
- print(f"Shakespeare corpus: {len(text):,} characters")
104
  ```
105
 
106
- ## Dataset Structure
107
-
108
- ### Cities Config
109
-
110
- | Split | Examples | Description |
111
- |-------|----------|-------------|
112
- | train | 12,392 | City names with country labels for training |
113
- | validation | 1,548 | Labeled validation set |
114
- | test | 1,554 | Labeled test set for evaluation |
115
 
116
- **Fields:**
 
 
117
 
118
- | Field | Type | Description |
119
- |-------|------|-------------|
120
- | `city_name` | string | Name of the city |
121
- | `country_code` | string | Two-letter country code (af, cn, de, fi, fr, in, ir, pk, za) |
122
- | `country` | ClassLabel | Full country name |
123
 
124
- ### Supplementary Files
125
 
126
  | File | Size | Description |
127
  |------|------|-------------|
128
- | `shakespeare.txt` | 4.5 MB | Complete Shakespeare works for training language models |
129
- | `shakespeare_sonnets.txt` | 9 KB | Shakespeare's sonnets (additional training data) |
130
- | `nytimes_article.txt` | 5 KB | News article for cross-domain perplexity evaluation |
131
- | `cities_test_unlabeled.csv` | 20 KB | Unlabeled test cities (for student predictions) |
132
-
133
- ## Source
134
-
135
- City name data sourced from [GeoNames](https://www.geonames.org/) (CC BY 4.0). Shakespeare text from Project Gutenberg (public domain).
136
-
137
- ## Intended Use
138
-
139
- This dataset is used for **Homework 3** in [CIS 5300: Natural Language Processing](https://www.seas.upenn.edu/~cis5300/) at the University of Pennsylvania. Students:
140
-
141
- 1. Build character-level n-gram language models on Shakespeare
142
- 2. Implement smoothing (add-k) and evaluate with perplexity
143
- 3. Use interpolation to combine models of different orders
144
- 4. Apply language models to classify city names by country of origin
145
-
146
- ## Citation
147
-
148
- ```bibtex
149
- @misc{cis5300-language-models,
150
- title = {CIS 5300 Language Models Dataset},
151
- author = {Callison-Burch, Chris},
152
- year = {2026},
153
- publisher = {University of Pennsylvania},
154
- }
155
- ```
 
1
+ # CIS 5300 Language Models Dataset
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
+ Dataset for Homework 3 of CIS 5300 (Natural Language Processing) at Penn.
4
 
5
+ ## Cities config
6
 
7
+ Country-of-origin classification over short city-name strings, drawn from
8
+ nine countries (Afghanistan, China, Germany, Finland, France, India, Iran,
9
+ Pakistan, South Africa).
 
 
 
 
 
 
 
 
 
 
10
 
11
  ```python
12
  from datasets import load_dataset
 
 
13
  cities = load_dataset("CCB/cis5300-language-models", "cities")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  ```
15
 
16
+ | Split | Rows | Has labels? |
17
+ |--------------|--------|-------------|
18
+ | `train` | 12,392 | yes |
19
+ | `validation` | 1,548 | yes |
20
+ | `test` | 1,554 | **no** (students predict) |
 
 
 
 
21
 
22
+ Each row has `city`, `country` (ISO code), and `country_name`. For the
23
+ `test` split, `country` and `country_name` are empty strings -- ground
24
+ truth is held back so students must submit predictions for grading.
25
 
26
+ ## Raw corpus files
 
 
 
 
27
 
28
+ For character-level language modeling and cross-domain perplexity work:
29
 
30
  | File | Size | Description |
31
  |------|------|-------------|
32
+ | `shakespeare_input.txt` | 4.5 MB | Complete Shakespeare works |
33
+ | `shakespeare_sonnets.txt` | 9 KB | Held-out Shakespeare sonnets |
34
+ | `modern_english_sample.txt` | 4.4 KB | Modern-English prose for cross-domain perplexity |
35
+
36
+ Fetch with `huggingface_hub.hf_hub_download(..., repo_type="dataset")`.
37
+
38
+ ## Licensing and attribution
39
+
40
+ - `shakespeare_input.txt` and `shakespeare_sonnets.txt` are in the public domain.
41
+ - `modern_english_sample.txt` is an excerpt from the English Wikipedia article
42
+ "Natural language processing" (https://en.wikipedia.org/wiki/Natural_language_processing),
43
+ used under the Creative Commons Attribution-ShareAlike 4.0 license
44
+ (https://creativecommons.org/licenses/by-sa/4.0/). The excerpt covers the
45
+ article's introduction and history sections, with Wikipedia section headers
46
+ removed so the text reads as continuous prose. See ATTRIBUTIONS.md for details.
47
+ - The `cities` config is released under CC BY 4.0.