File size: 1,316 Bytes
08c8ee9 c1b2b40 08c8ee9 f481b1b a5e0fdc c1b2b40 a5e0fdc c1b2b40 f481b1b c1b2b40 137e920 a5e0fdc 137e920 a5e0fdc |
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 |
import pandas as pd
from datasets import DatasetInfo, Features, GeneratorBasedBuilder, Sequence, Split, SplitGenerator, Value
class PodcastConversationsWithMetadataAndEmbedding(GeneratorBasedBuilder):
def _info(self):
return DatasetInfo(
features=Features(
{
"c_guid": Value("string"),
"participants": Sequence(Value("string")),
"transcript": Sequence({"chunk": Value("string"), "speaker": Value("string"), "text": Value("string")}),
}
)
)
def _split_generators(self, dl_manager):
data_files = self.config.data_files
return [
SplitGenerator(
name=Split.TRAIN,
gen_kwargs={"filepath": data_files["train"][0]},
),
]
def _generate_examples(self, filepath):
df = pd.read_parquet(filepath)
for idx, row in df.iterrows():
record = row.to_dict()
# Normalize vector field if it exists
if "vector" in record:
if isinstance(record["vector"], (list, tuple)):
record["vector"] = list(map(float, record["vector"]))
else:
record["vector"] = []
yield idx, record
|