DeepInstinct commited on
Commit
b8a9b88
·
verified ·
1 Parent(s): 641af3b

Create dataset.py

Browse files
Files changed (1) hide show
  1. dataset.py +68 -0
dataset.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import datasets
2
+
3
+ _CITATION = """\
4
+ @misc{deepurlbench2025,
5
+ author = {Deep Instinct Research Team},
6
+ title = {DeepURLBench: A large-scale benchmark for URL classification},
7
+ year = {2025},
8
+ howpublished = {\\url{https://huggingface.co/datasets/DeepInstinct/DeepURLBench}}
9
+ }
10
+ """
11
+
12
+ _DESCRIPTION = """\
13
+ DeepURLBench is a large-scale benchmark for real-world URL classification.
14
+ It includes two subsets: one with DNS resolution information and one without.
15
+ """
16
+
17
+ _HOMEPAGE = "https://huggingface.co/datasets/DeepInstinct/DeepURLBench"
18
+
19
+ _LICENSE = "cc-by-nc-4.0"
20
+
21
+ # If your files are hosted in the root of the repo
22
+ _URLS = {
23
+ "with_dns": "https://huggingface.co/datasets/DeepInstinct/DeepURLBench/resolve/main/urls_with_dns.parquet",
24
+ "without_dns": "https://huggingface.co/datasets/DeepInstinct/DeepURLBench/resolve/main/urls_without_dns.parquet",
25
+ }
26
+
27
+
28
+ class DeepURLBench(datasets.GeneratorBasedBuilder):
29
+ VERSION = datasets.Version("1.0.0")
30
+
31
+ BUILDER_CONFIGS = [
32
+ datasets.BuilderConfig(name="with_dns", version=VERSION, description="URLs with DNS info"),
33
+ datasets.BuilderConfig(name="without_dns", version=VERSION, description="URLs without DNS info"),
34
+ ]
35
+
36
+ def _info(self):
37
+ if self.config.name == "with_dns":
38
+ features = datasets.Features({
39
+ "url": datasets.Value("string"),
40
+ "first_seen": datasets.Value("string"),
41
+ "TTL": datasets.Value("int32"),
42
+ "label": datasets.Value("string"),
43
+ "ip_address": datasets.Sequence(datasets.Value("string")),
44
+ })
45
+ else: # without_dns
46
+ features = datasets.Features({
47
+ "url": datasets.Value("string"),
48
+ "first_seen": datasets.Value("string"),
49
+ "label": datasets.Value("string"),
50
+ })
51
+ return datasets.DatasetInfo(
52
+ description=_DESCRIPTION,
53
+ features=features,
54
+ homepage=_HOMEPAGE,
55
+ license=_LICENSE,
56
+ citation=_CITATION,
57
+ )
58
+
59
+ def _split_generators(self, dl_manager):
60
+ data_file = _URLS[self.config.name]
61
+ downloaded_file = dl_manager.download_and_extract(data_file)
62
+ return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_file})]
63
+
64
+ def _generate_examples(self, filepath):
65
+ import pandas as pd
66
+ df = pd.read_parquet(filepath)
67
+ for idx, row in df.iterrows():
68
+ yield idx, row.to_dict()