Function mindspore::dataset::CoNLL2000

Function Documentation

inline std::shared_ptr<CoNLL2000Dataset> mindspore::dataset::CoNLL2000(const std::string &dataset_dir, const std::string &usage = "all", int64_t num_samples = 0, ShuffleMode shuffle = ShuffleMode::kGlobal, int32_t num_shards = 1, int32_t shard_id = 0, const std::shared_ptr<DatasetCache> &cache = nullptr)

Function to create a CoNLL2000Dataset.

Note

The generated dataset has three column [‘word’, ‘pos_tag’, ‘chunk_tag’].

Parameters
  • dataset_dir[in] Path to the root directory that contains the dataset.

  • usage[in] Part of dataset of CoNLL2000, can be “train”, “test” or “all” (default=”all”).

  • num_samples[in] The number of samples to be included in the dataset (Default = 0, means all samples).

  • shuffle[in] The mode for shuffling data every epoch (Default=ShuffleMode.kGlobal). Can be any of: ShuffleMode::kFalse - No shuffling is performed. ShuffleMode::kFiles - Shuffle files only. ShuffleMode::kGlobal - Shuffle both the files and samples.

  • num_shards[in] Number of shards that the dataset should be divided into (Default = 1).

  • shard_id[in] The shard ID within num_shards. This argument should be specified only when num_shards is also specified (Default = 0).

  • cache[in] Tensor cache to use (default=nullptr, which means no cache is used).

Returns

Shared pointer to the CoNLL2000Dataset.

样例
/* Define dataset path and MindData object */
std::string folder_path = "/path/to/conll2000_dataset_directory";
std::shared_ptr<Dataset> ds = CoNLL2000(dataset_dir, "all", 0, ShuffleMode::kGlobal);

/* Create iterator to read dataset */
std::shared_ptr<Iterator> iter = ds->CreateIterator();
std::unordered_map<std::string, mindspore::MSTensor> row;
iter->GetNextRow(&row);

/* Note: In CoNLL2000 dataset, each dictionary has keys "word", "pos_tag", "chunk_tag" */
auto word = row["word"];