|
|
from __future__ import absolute_import, division, print_function |
|
|
|
|
|
import datasets |
|
|
import os |
|
|
import pandas as pd |
|
|
from ast import literal_eval |
|
|
|
|
|
_DESCRIPTION = "bias lexicon" |
|
|
_URL = "lexicon.csv" |
|
|
_HOMEPAGE = "" |
|
|
_LICENSE = "" |
|
|
|
|
|
class LEXI(datasets.GeneratorBasedBuilder): |
|
|
|
|
|
def _info(self): |
|
|
return datasets.DatasetInfo( |
|
|
description=_DESCRIPTION, |
|
|
features=datasets.Features( |
|
|
{"biased_words":datasets.Value("string")} |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
def _split_generators(self, dl_manager): |
|
|
path = dl_manager.download_and_extract(_URL) |
|
|
|
|
|
|
|
|
return [ |
|
|
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"file_path": path}), |
|
|
] |
|
|
|
|
|
def _generate_examples(self, file_path): |
|
|
df = pd.read_csv(file_path,names=['biased_words']) |
|
|
|
|
|
for i, row in df.iterrows(): |
|
|
yield i, {"text":row['biased_words']} |