Class: TorchText::Datasets::TextClassificationDataset

Inherits:
Torch::Utils::Data::Dataset
  • Object
show all
Defined in:
lib/torchtext/datasets/text_classification_dataset.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vocab, data, labels) ⇒ TextClassificationDataset

Returns a new instance of TextClassificationDataset.



6
7
8
9
10
11
# File 'lib/torchtext/datasets/text_classification_dataset.rb', line 6

def initialize(vocab, data, labels)
  super()
  @data = data
  @labels = labels
  @vocab = vocab
end

Instance Attribute Details

#labelsObject (readonly)

Returns the value of attribute labels.



4
5
6
# File 'lib/torchtext/datasets/text_classification_dataset.rb', line 4

def labels
  @labels
end

#vocabObject (readonly)

Returns the value of attribute vocab.



4
5
6
# File 'lib/torchtext/datasets/text_classification_dataset.rb', line 4

def vocab
  @vocab
end

Instance Method Details

#[](i) ⇒ Object



13
14
15
# File 'lib/torchtext/datasets/text_classification_dataset.rb', line 13

def [](i)
  @data[i]
end

#eachObject



22
23
24
25
26
# File 'lib/torchtext/datasets/text_classification_dataset.rb', line 22

def each
  @data.each do |x|
    yield x
  end
end

#lengthObject Also known as: size



17
18
19
# File 'lib/torchtext/datasets/text_classification_dataset.rb', line 17

def length
  @data.length
end