STSBDataSet
收藏数据集概述
数据集名称
- SAF-Datasets
数据集功能
- 提供自然语言处理(NLP)数据集的便捷访问。
- 支持文档、句子和词级别的标注。
- 允许修改现有数据集的标注。
- 提供标准化的API。
- 支持复杂和多级别的标注。
数据集依赖
- 基于Simple Annotation Framework (SAF) 库。
数据集安装
- 使用pip安装:
pip install saf-datasets
数据集使用示例
加载数据集
python from saf_datasets import STSBDataSet
dataset = STSBDataSet() print(len(dataset)) # 数据集大小 print(dataset[0].surface) # 数据集中的第一个句子 print([token.surface for token in dataset[0].tokens]) # 第一个句子的词(SpaCy) print(dataset[0].annotations) # 第一个句子的标注
标注数据集
python from saf_datasets import STSBDataSet from saf_datasets.annotators import SpacyAnnotator
dataset = STSBDataSet() annotator = SpacyAnnotator() annotator.annotate(dataset)
for tok in dataset[0].tokens: print(tok.surface, tok.annotations)
与其他库结合使用
python from saf_datasets import CPAEDataSet from saf_datasets.wrappers.torch import TokenizedDataSet from transformers import AutoTokenizer
dataset = CPAEDataSet() tokenizer = AutoTokenizer.from_pretrained("gpt2") tok_ds = TokenizedDataSet(dataset, tokenizer, max_len=128, one_hot=False) print(tok_ds[:10]) print(tok_ds[:10].shape)
可用数据集列表
- AllNLI
- CODWOE
- CPAE
- EntailmentBank
- STSB
- Wiktionary
- WordNet (Filtered)




