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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
---
dataset_info:
  features:
  - name: file_name
    dtype: string
  - name: url_id
    dtype: int64
  - name: country
    dtype: string
  - name: lang
    dtype: string
  - name: pdf_bytes_base64
    dtype: binary
  - name: hosts
    struct:
    - name: country
      dtype: string
    - name: host
      dtype: string
    - name: ip_address
      dtype: string
    - name: latitude
      dtype: float64
    - name: longitude
      dtype: float64
    - name: tld
      dtype: string
  - name: provenance
    struct:
    - name: cc_detected_mime
      dtype: string
    - name: cc_digest
      dtype: string
    - name: cc_http_mime
      dtype: string
    - name: cc_truncated
      dtype: string
    - name: cc_warc_end
      dtype: int64
    - name: cc_warc_file_name
      dtype: string
    - name: cc_warc_start
      dtype: int64
    - name: fetched_digest
      dtype: string
    - name: fetched_length
      dtype: int64
    - name: fetched_status
      dtype: string
    - name: url
      dtype: string
  - name: info
    struct:
    - name: created
      dtype: string
    - name: creator
      dtype: string
    - name: custom_metadata
      dtype: string
    - name: exit_value
      dtype: int64
    - name: form
      dtype: string
    - name: javascript
      dtype: string
    - name: metadata_stream
      dtype: string
    - name: modified
      dtype: string
    - name: optimized
      dtype: string
    - name: page_rotation
      dtype: float64
    - name: page_size
      dtype: string
    - name: pages
      dtype: float64
    - name: parse_time_millis
      dtype: int64
    - name: pdf_version
      dtype: float64
    - name: producer
      dtype: string
    - name: stderr
      dtype: string
    - name: tagged
      dtype: string
    - name: timeout
      dtype: string
    - name: user_properties
      dtype: string
  - name: tika
    struct:
    - name: attachment_count
      dtype: float64
    - name: container_exception
      dtype: string
    - name: created
      dtype: string
    - name: encrypted
      dtype: string
    - name: has_collection
      dtype: string
    - name: has_marked_content
      dtype: string
    - name: has_signature
      dtype: string
    - name: has_xfa
      dtype: string
    - name: has_xmp
      dtype: string
    - name: location
      dtype: string
    - name: macro_count
      dtype: float64
    - name: mime
      dtype: string
    - name: modified
      dtype: string
    - name: num_pages
      dtype: float64
    - name: parse_status
      dtype: string
    - name: parse_time_millis
      dtype: int64
    - name: pdf_contains_damaged_font
      dtype: string
    - name: pdf_contains_non_embedded_font
      dtype: string
    - name: pdf_has_acroform_fields
      dtype: string
    - name: pdf_incremental_updates
      dtype: float64
    - name: pdf_num_3d_annotations
      dtype: float64
    - name: pdf_overall_unmapped_unicode_chars
      dtype: float64
    - name: pdf_producer
      dtype: string
    - name: pdf_version
      dtype: float64
    - name: pdfa_version
      dtype: string
    - name: pdfuaid_part
      dtype: float64
    - name: pdfvt_version
      dtype: float64
    - name: pdfx_conformance
      dtype: string
    - name: pdfx_version
      dtype: string
    - name: pdfxid_version
      dtype: string
    - name: tika_eval_lang
      dtype: string
    - name: tika_eval_num_alpha_tokens
      dtype: float64
    - name: tika_eval_num_tokens
      dtype: float64
    - name: tika_eval_oov
      dtype: float64
    - name: xmp_creator_tool
      dtype: string
  - name: tika_attachments
    list:
    - name: container_exception
      dtype: string
    - name: created
      dtype: string
    - name: emb_depth
      dtype: int64
    - name: embedded_exception
      dtype: float64
    - name: embedded_id
      dtype: float64
    - name: embedded_id_path
      dtype: string
    - name: embedded_resource_type
      dtype: string
    - name: encrypted
      dtype: string
    - name: has_collection
      dtype: string
    - name: has_marked_content
      dtype: string
    - name: has_signature
      dtype: string
    - name: has_xfa
      dtype: string
    - name: has_xmp
      dtype: string
    - name: location
      dtype: string
    - name: mime
      dtype: string
    - name: modified
      dtype: string
    - name: num_pages
      dtype: float64
    - name: parse_status
      dtype: string
    - name: parse_time_millis
      dtype: int64
    - name: pdf_contains_damaged_font
      dtype: string
    - name: pdf_contains_non_embedded_font
      dtype: string
    - name: pdf_has_acroform_fields
      dtype: string
    - name: pdf_incremental_updates
      dtype: float64
    - name: pdf_num_3d_annotations
      dtype: float64
    - name: pdf_overall_unmapped_unicode_chars
      dtype: float64
    - name: pdf_producer
      dtype: string
    - name: pdf_version
      dtype: float64
    - name: pdfa_version
      dtype: string
    - name: pdfuaid_part
      dtype: float64
    - name: pdfvt_version
      dtype: float64
    - name: pdfx_conformance
      dtype: string
    - name: pdfx_version
      dtype: string
    - name: pdfxid_version
      dtype: string
    - name: tika_eval_lang
      dtype: string
    - name: tika_eval_num_alpha_tokens
      dtype: float64
    - name: tika_eval_num_tokens
      dtype: float64
    - name: tika_eval_oov
      dtype: float64
    - name: xmp_creator_tool
      dtype: string
  splits:
  - name: train
    num_bytes: 1840299303
    num_examples: 1000
  download_size: 1756624272
  dataset_size: 1840299303
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
tags:
- PDF
size_categories:
- 1K<n<10K
---
# Dataset Card for SAFEDOCS 1k PDF

**This dataset is a subset (first 1,000 PDFs) of the original [SAFEDOCS (CC-MAIN-2021-31-PDF-UNTRUNCATED)](https://digitalcorpora.org/corpora/file-corpora/cc-main-2021-31-pdf-untruncated/) merged with the corresponding [metadata](https://digitalcorpora.org/corpora/file-corpora/cc-main-2021-31-pdf-untruncated/cc-main-2021-31-pdf-untruncated-metadata/).**

The PDFs in this dataset are found in the `0000.zip` file available [here](https://corp.digitalcorpora.org/corpora/files/CC-MAIN-2021-31-PDF-UNTRUNCATED/zipfiles/0000-0999/). The metadata files are available [here](https://corp.digitalcorpora.org/corpora/files/CC-MAIN-2021-31-PDF-UNTRUNCATED/metadata/). 

Each file corresponds to a feature in the dataset:

- `hosts`: [cc-hosts-20230324-1k.csv](https://digitalcorpora.s3.amazonaws.com/corpora/files/CC-MAIN-2021-31-PDF-UNTRUNCATED/metadata/cc-hosts-20230324-1k.csv)
- `provenance`: [cc-provenance-20230324-1k.csv](https://digitalcorpora.s3.amazonaws.com/corpora/files/CC-MAIN-2021-31-PDF-UNTRUNCATED/metadata/cc-provenance-20230324-1k.csv)
- `info`: [pdfinfo-20230324-1k.csv](https://digitalcorpora.s3.amazonaws.com/corpora/files/CC-MAIN-2021-31-PDF-UNTRUNCATED/metadata/pdfinfo-20230324-1k.csv)
- `tika`: [tika-20230714-1k.csv](https://digitalcorpora.s3.amazonaws.com/corpora/files/CC-MAIN-2021-31-PDF-UNTRUNCATED/metadata/tika-20230714-1k.csv)
- `tika_attachments`: [tika-with-attachments-20230714-1k.csv](https://digitalcorpora.s3.amazonaws.com/corpora/files/CC-MAIN-2021-31-PDF-UNTRUNCATED/metadata/tika-with-attachments-20230714-1k.csv)

The PDFs were encoded in base64 and added as the `pdf_bytes_base64` feature.

The keys `country` (from `hosts`) and `lang` (from `tika`, as `tika_eval_lang`) were replicated as features to make it easier to filter the data based on origin and language.

You can easily and quickly load it:

```python
dataset = load_dataset("dvgodoy/SAFEDOCS_1k")
```

```
Dataset({
    features: ['file_name', 'url_id', 'country', 'lang', 'pdf_bytes_base64', 'hosts', 'provenance', 'info', 'tika', 'tika_attachments'],
    num_rows: 1000
})
```

## Decoding PDFs

To handle the PDFs, you will need to decode the `pdf_bytes_base64` feature and load it into a PDF object using your favorite PDF library (e.g. `pdfplumber`):

```python
import io
import pdfplumber

# load the bytes into your favorite PDF library e.g., `pdfplumber`
for encoded in mini_batch['pdf_bytes_base64']:
    bytes_content = io.BytesIO(base64.b64decode(encoded))
    pdf_obj = pdfplumber.open(bytes_content)
    # process the PDFs
    # ...
    # CLOSE the objects after you've used them
    bytes_content.close()
    pdf_obj.close()
```

You can use any other library/package to load the PDF, just make sure it can open a PDF from bytes.

## Table of Contents
- [Dataset Description](#dataset-description)
  - [Dataset Summary](#dataset-summary)
- [Dataset Structure](#dataset-structure)
  - [Data Instances](#data-instances)
- [Dataset Creation](#dataset-creation)
  - [Curation Rationale](#curation-rationale)
  - [Source Data](#source-data)
- [Additional Information](#additional-information)
  - [Credits](#credits)
  - [Licensing Information](#licensing-information)

## Dataset Description

- **Homepage:** [SAFEDOCS (CC-MAIN-2021-31-PDF-UNTRUNCATED)](https://digitalcorpora.org/corpora/file-corpora/cc-main-2021-31-pdf-untruncated/)
- **Repository:**
- **Paper:** [Making more sense of PDF structures in the wild at scale](https://pdfa.org/presentation/making-more-sense-of-pdf-structures-in-the-wild-at-scale/)
- **Leaderboard:**
- **Point of Contact:**

### Dataset Summary

The original  SAFEDOCS (CC-MAIN-2021-31-PDF-UNTRUNCATED) consists of nearly 8,000,000 PDFs gathered from across the web in July/August of 2021.

**This "1k" version contains only the first 1,000 PDFs from the original dataset.**

## Dataset Structure

### Data Instances

A sample from the training set is provided below :
```
{
    'file_name': '0000000.pdf',
    'url_id': 6368476,
    'country': 'US',
    'lang': 'eng',
    'pdf_bytes_base64': b'JVBERi0xLjcKJe...',
    'hosts': {
        'host': 'augustaarchives.com',
        'tld': 'com',
        'ip_address': '66.228.60.224',
        'country': 'US',
        'latitude': 33.7485,
        'longitude': -84.3871
    },
    'provenance': {
        'url': 'http://augustaarchives.com/cgi-bin/content/view.php?data=ib_math_sl_practice_questions_and_answers&filetype=pdf&id=14310d60ac64f9023c7dbc458f0f7b38',
        'cc_digest': 'H66IGSGFXBJLJIKKN7LSHQSM3YTX4TDF',
        'cc_http_mime': 'application/pdf',
        'cc_detected_mime': 'application/pdf',
        'cc_warc_file_name': 'crawl-data/CC-MAIN-2021-31/segments/1627046154042.23/warc/CC-MAIN-20210731011529-20210731041529-00143.warc.gz',
        'cc_warc_start': 3724499,
        'cc_warc_end': 3742341,
        'cc_truncated': '',
        'fetched_status': 'ADDED_TO_REPOSITORY',
        'fetched_digest': '00000836a41510292765a86e57a80f1e182360ca5c6ff0841482b31c8f25ab84',
        'fetched_length': 29690
    },
    'info': {
        'parse_time_millis': 385,
        'exit_value': 0,
        'timeout': 'f',
        'stderr': '',
        'pdf_version': 1.7,
        'creator': 'Acrobat 9.0.0',
        'producer': 'Adobe InDesign CC 2015 (Macintosh)|x|Adobe PDF Library 15.0; modified using iText 2.1.7 by 1T3XT',
        'created': '2021-07-31T03:13:33Z',
        'modified': '2021-07-31T03:13:33Z',
        'custom_metadata': 'no',
        'metadata_stream': 'yes',
        'tagged': 'no',
        'user_properties': 'no',
        'form': 'none',
        'javascript': 'no',
        'pages': 12.0,
        'page_size': '297.638 x 419.528 pts',
        'page_rotation': 0.0,
        'optimized': 'no'
    },
    'tika': {
        'parse_status': 'OK',
        'parse_time_millis': 1430,
        'mime': 'application/pdf',
        'macro_count': nan,
        'attachment_count': nan,
        'created': '2021-07-31 03:13:33',
        'modified': '2021-07-31 03:13:33',
        'encrypted': 'f',
        'has_xfa': 'f',
        'has_xmp': 't',
        'has_collection': 'f',
        'has_marked_content': 'f',
        'num_pages': 12.0,
        'xmp_creator_tool': 'Acrobat 9.0.0',
        'pdf_producer': 'Microsoft Word|x|DocuCom PDF Driver 4.61 for NT',
        'pdf_version': 1.7,
        'pdfa_version': '',
        'pdfuaid_part': nan,
        'pdfx_conformance': '',
        'pdfx_version': '',
        'pdfxid_version': '',
        'pdfvt_version': nan,
        'pdf_num_3d_annotations': 0.0,
        'pdf_has_acroform_fields': '',
        'pdf_incremental_updates': 0.0,
        'pdf_overall_unmapped_unicode_chars': 0.0,
        'pdf_contains_damaged_font': 'f',
        'pdf_contains_non_embedded_font': 't',
        'has_signature': '',
        'location': '',
        'tika_eval_num_tokens': 1489.0,
        'tika_eval_num_alpha_tokens': 1344.0,
        'tika_eval_lang': 'eng',
        'tika_eval_oov': 0.2961309552192688,
        'container_exception': ''
    },
    'tika_attachments': [{
        'parse_status': 'OK',
        'parse_time_millis': 1430,
        'mime': 'application/pdf',
        'emb_depth': 0,
        'embedded_id': nan,
        'embedded_id_path': '',
        'embedded_resource_type': '',
        'created': '2021-07-31 03:13:33',
        'modified': '2021-07-31 03:13:33',
        'encrypted': 'f',
        'has_xfa': 'f',
        'has_xmp': 't',
        'has_collection': 'f',
        'has_marked_content': 'f',
        'num_pages': 12.0,
        'xmp_creator_tool': 'Acrobat 9.0.0',
        'pdf_producer': 'Microsoft Word|x|DocuCom PDF Driver 4.61 for NT',
        'pdf_version': 1.7,
        'pdfa_version': '',
        'pdfuaid_part': nan,
        'pdfx_conformance': '',
        'pdfx_version': '',
        'pdfxid_version': '',
        'pdfvt_version': nan,
        'pdf_num_3d_annotations': 0.0,
        'pdf_has_acroform_fields': '',
        'pdf_incremental_updates': 0.0,
        'pdf_overall_unmapped_unicode_chars': 0.0,
        'pdf_contains_damaged_font': 'f',
        'pdf_contains_non_embedded_font': 't',
        'has_signature': '',
        'location': '',
        'tika_eval_num_tokens': 1489.0,
        'tika_eval_num_alpha_tokens': 1344.0,
        'tika_eval_lang': 'eng',
        'tika_eval_oov': 0.2961309552192688,
        'container_exception': '',
        'embedded_exception': nan
    }]
}
```

## Dataset Creation

### Curation Rationale

PDF is a ubiquitous format and is used across many industrial and research domains. Many existing corpora focusing on extant data (such as GovDocs1) are now quite old and no longer reflect current changes and trends in both PDF itself (as a file format) or in PDF-creating and authoring applications. With advances in machine learning technology, the need for larger data sets is also in high demand. This corpus is thus helpful for:

- PDF technology and software testing, assessment, and evaluation
- Information privacy research
- Document understanding, text extraction, table identification, OCR/ICR, formula identification, document recognition and analysis, and related document engineering domains
- Malware and cyber-security research
- ML/AI applications and research (document classification, document content, text extraction, etc)
- Preservation and archival research
- Usability and accessibility research
- Software engineering research (parsing, formal methods, etc.)

### Source Data

#### Initial Data Collection and Normalization

The PDF files were initially identified by [Common Crawl](https://commoncrawl.org/) as part of their [July/August 2021 crawl](https://commoncrawl.org/2021/08/july-august-2021-crawl-archive-available/) (identified as CC-MAIN-2021-31) and subsequently updated and collated as part of the [DARPA SafeDocs program](https://www.darpa.mil/program/safe-documents).

## Additional Information

### Credits

The original dataset was gathered by a team at NASA’s Jet Propulsion Laboratory (JPL), California Institute of Technology while supporting the Defense Advance Research Project Agency (DARPA)’s SafeDocs Program. The JPL team included Chris Mattmann (PI), Wayne Burke, Dustin Graf, Tim Allison, Ryan Stonebraker, Mike Milano, Philip Southam and Anastasia Menshikova.

The JPL team collaborated with Peter Wyatt, the Chief Technology Officer of the PDF Association and PI on the SafeDocs program, in the design and documentation of this corpus.

The JPL team and PDF Association would like to thank Simson Garfinkel and Digital Corpora for taking ownership of this dataset and publishing it. Our thanks are extended to the [Amazon Open Data Sponsorship Program](https://aws.amazon.com/opendata/open-data-sponsorship-program/) for enabling this large corpus to be free and publicly available as part of Digital Corpora initiative.

Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise, does not constitute or imply its endorsement by the United States Government or the Jet Propulsion Laboratory, California Institute of Technology.

The research was carried out at the NASA (National Aeronautics and Space Administration) Jet Propulsion Laboratory, California Institute of Technology under a contract with the Defense Advanced Research Projects Agency (DARPA) SafeDocs program. Government sponsorship acknowledged.

### Licensing Information

- [Common Crawl](https://commoncrawl.org/terms-of-use)
- [Digital Corpora](https://digitalcorpora.org/about-digitalcorpora/terms-of-use/)