correct comments in script
Browse files
twitter-sentiment-analysis.py
CHANGED
@@ -50,28 +50,15 @@ _URLS = {
|
|
50 |
"test": _URL + "test_62k.txt",
|
51 |
}
|
52 |
|
53 |
-
|
54 |
_HOMEPAGE = "https://raw.githubusercontent.com/cblancac/SentimentAnalysisBert/main"
|
55 |
|
56 |
|
57 |
-
# TODO: Add link to the official dataset URLs here
|
58 |
-
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
59 |
-
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
60 |
-
#_URLS = {
|
61 |
-
# "first_domain": "https://huggingface.co/great-new-dataset-first_domain.zip",
|
62 |
-
# "second_domain": "https://huggingface.co/great-new-dataset-second_domain.zip",
|
63 |
-
#}
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
def _define_columns(example):
|
68 |
text_splited = example["text"].split('\t')
|
69 |
return {"text": text_splited[1].strip(), "feeling": int(text_splited[0])}
|
70 |
|
71 |
|
72 |
-
# TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
|
73 |
class NewDataset(datasets.GeneratorBasedBuilder):
|
74 |
-
"""TODO: Short description of my dataset."""
|
75 |
|
76 |
VERSION = datasets.Version("1.0.0")
|
77 |
|
@@ -83,14 +70,10 @@ class NewDataset(datasets.GeneratorBasedBuilder):
|
|
83 |
}
|
84 |
)
|
85 |
return datasets.DatasetInfo(
|
86 |
-
# This is
|
87 |
description=_DESCRIPTION,
|
88 |
# This defines the different columns of the dataset and their types
|
89 |
-
features=features,
|
90 |
-
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
91 |
-
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
92 |
-
# supervised_keys=("sentence", "label"),
|
93 |
-
# Homepage of the dataset for documentation
|
94 |
homepage=_HOMEPAGE,
|
95 |
# Citation for the dataset
|
96 |
citation=_CITATION,
|
@@ -98,10 +81,8 @@ class NewDataset(datasets.GeneratorBasedBuilder):
|
|
98 |
|
99 |
def _split_generators(self, dl_manager):
|
100 |
|
101 |
-
|
102 |
data_dir_files = dl_manager.download_and_extract(_URLS)
|
103 |
data_dir = '/'.join(data_dir_files["train"].split('/')[:-1])
|
104 |
-
print("AAAAAAAAAAAAA: ", data_dir)
|
105 |
|
106 |
data = load_dataset("text", data_files=data_dir_files)
|
107 |
data = data.map(_define_columns)
|
@@ -122,7 +103,7 @@ class NewDataset(datasets.GeneratorBasedBuilder):
|
|
122 |
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": os.path.join(data_dir, "twitter-sentiment-analysis-test.jsonl")}),
|
123 |
]
|
124 |
|
125 |
-
|
126 |
def _generate_examples(self, filepath):
|
127 |
"""This function returns the examples in the raw (text) form."""
|
128 |
logger.info("generating examples from = %s", filepath)
|
|
|
50 |
"test": _URL + "test_62k.txt",
|
51 |
}
|
52 |
|
|
|
53 |
_HOMEPAGE = "https://raw.githubusercontent.com/cblancac/SentimentAnalysisBert/main"
|
54 |
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
def _define_columns(example):
|
57 |
text_splited = example["text"].split('\t')
|
58 |
return {"text": text_splited[1].strip(), "feeling": int(text_splited[0])}
|
59 |
|
60 |
|
|
|
61 |
class NewDataset(datasets.GeneratorBasedBuilder):
|
|
|
62 |
|
63 |
VERSION = datasets.Version("1.0.0")
|
64 |
|
|
|
70 |
}
|
71 |
)
|
72 |
return datasets.DatasetInfo(
|
73 |
+
# This is description will appear on the datasets page.
|
74 |
description=_DESCRIPTION,
|
75 |
# This defines the different columns of the dataset and their types
|
76 |
+
features=features,
|
|
|
|
|
|
|
|
|
77 |
homepage=_HOMEPAGE,
|
78 |
# Citation for the dataset
|
79 |
citation=_CITATION,
|
|
|
81 |
|
82 |
def _split_generators(self, dl_manager):
|
83 |
|
|
|
84 |
data_dir_files = dl_manager.download_and_extract(_URLS)
|
85 |
data_dir = '/'.join(data_dir_files["train"].split('/')[:-1])
|
|
|
86 |
|
87 |
data = load_dataset("text", data_files=data_dir_files)
|
88 |
data = data.map(_define_columns)
|
|
|
103 |
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": os.path.join(data_dir, "twitter-sentiment-analysis-test.jsonl")}),
|
104 |
]
|
105 |
|
106 |
+
|
107 |
def _generate_examples(self, filepath):
|
108 |
"""This function returns the examples in the raw (text) form."""
|
109 |
logger.info("generating examples from = %s", filepath)
|