code: protected Dataset<Instance> getDataset(Resource data, String format, CorpusType corpusType, boolean undersample, boolean oversample) {
          Corpus corpus = Corpus.builder()
                  .format(format)
                  .source(data)
                  .corpusType(corpusType)
                  .build();
          AnnotatableType[] required = required();
          if (required != null && required.length > 0) {
              corpus = corpus.annotate(required);
          }
  
  
          Corpus filtered = corpus;
          SerializablePredicate<HString> predicate = getTextFilter();
          if (predicate != null) {
              filtered = corpus.filter(getTextFilter());
          }
          Dataset<Instance> dataset = Dataset
                  .classification()
                  .featureEncoder(getFeatureEncoder())
                  .type(corpus.getDataSetType())
                  .source(filtered
                          .asLabeledStream(getOracle())
                          .map(getFeaturizer()::extractInstance));
  
  
          if (undersample) {
              dataset = dataset.undersample();
          }
          if (oversample) {
              dataset = dataset.oversample();
          }
  
          return dataset.shuffle(new Random(34));
      }
docs: Gets dataset.
  
  @param data       the data
  @param format     the format
  @param corpusType the corpus type
  @return the dataset