Java Code Examples for org.datavec.api.conf.Configuration#getStringCollection()

The following examples show how to use org.datavec.api.conf.Configuration#getStringCollection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseImageRecordReader.java    From DataVec with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(Configuration conf, InputSplit split) throws IOException, InterruptedException {
    this.appendLabel = conf.getBoolean(APPEND_LABEL, appendLabel);
    this.labels = new ArrayList<>(conf.getStringCollection(LABELS));
    this.height = conf.getInt(HEIGHT, height);
    this.width = conf.getInt(WIDTH, width);
    this.channels = conf.getInt(CHANNELS, channels);
    this.cropImage = conf.getBoolean(CROP_IMAGE, cropImage);
    if ("imageio".equals(conf.get(IMAGE_LOADER))) {
        this.imageLoader = new ImageLoader(height, width, channels, cropImage);
    } else {
        this.imageLoader = new NativeImageLoader(height, width, channels, imageTransform);
    }
    this.conf = conf;
    initialize(split);
}
 
Example 2
Source File: TextVectorizer.java    From DataVec with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(Configuration conf) {
    tokenizerFactory = createTokenizerFactory(conf);
    minWordFrequency = conf.getInt(MIN_WORD_FREQUENCY, 5);
    stopWords = conf.getStringCollection(STOP_WORDS);
    if (stopWords == null || stopWords.isEmpty())
        stopWords = StopWords.getStopWords();

    String clazz = conf.get(VOCAB_CACHE, DefaultVocabCache.class.getName());
    try {
        Class<? extends VocabCache> tokenizerFactoryClazz = (Class<? extends VocabCache>) Class.forName(clazz);
        cache = tokenizerFactoryClazz.newInstance();
        cache.initialize(conf);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 3
Source File: BaseImageRecordReader.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(Configuration conf, InputSplit split) throws IOException, InterruptedException {
    this.appendLabel = conf.getBoolean(APPEND_LABEL, appendLabel);
    this.labels = new ArrayList<>(conf.getStringCollection(LABELS));
    this.height = conf.getLong(HEIGHT, height);
    this.width = conf.getLong(WIDTH, width);
    this.channels = conf.getLong(CHANNELS, channels);
    this.cropImage = conf.getBoolean(CROP_IMAGE, cropImage);
    if ("imageio".equals(conf.get(IMAGE_LOADER))) {
        this.imageLoader = new ImageLoader(height, width, channels, cropImage);
    } else {
        this.imageLoader = new NativeImageLoader(height, width, channels, imageTransform);
    }
    this.conf = conf;
    initialize(split);
}
 
Example 4
Source File: TextVectorizer.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(Configuration conf) {
    tokenizerFactory = createTokenizerFactory(conf);
    minWordFrequency = conf.getInt(MIN_WORD_FREQUENCY, 5);
    if(conf.get(STOP_WORDS) != null)
        stopWords = conf.getStringCollection(STOP_WORDS);
    if (stopWords == null)
        stopWords = StopWords.getStopWords();

    String clazz = conf.get(VOCAB_CACHE, DefaultVocabCache.class.getName());
    try {
        Class<? extends VocabCache> tokenizerFactoryClazz = (Class<? extends VocabCache>) Class.forName(clazz);
        cache = tokenizerFactoryClazz.newInstance();
        cache.initialize(conf);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 5
Source File: VasttextTextVectorizer.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void initialize(Configuration conf) {

	tokenizerFactory = new DefaultTokenizerFactory();
       minWordFrequency = conf.getInt(MIN_WORD_FREQUENCY, 5);
       maxNgrams = conf.getInt(NGRAMS, 1);
       maxSkipBigrams = conf.getInt(SKIP_NGRAMS, 0);

       if(conf.getBoolean(DELETE_STOP_WORDS, false))
       {
       	System.err.println("StopWord Removal: Yes");
        stopWords = conf.getStringCollection(STOP_WORDS);
        if (stopWords == null || stopWords.isEmpty())
            stopWords = StopWords.getStopWords();
       }
       else
       	System.err.println("StopWord Removal: No");
       System.err.println("Freq min:"+minWordFrequency);
       
       System.err.println("N-grams:"+maxNgrams);
       
       System.err.println("Skip bigrams:"+maxSkipBigrams);
       
	cache = new VasttextDictionary();
       cache.initialize(conf);
	cache.setMaxNgrams(maxNgrams);
	cache.setMaxSkipBigrams(maxSkipBigrams);
}
 
Example 6
Source File: BaseAudioRecordReader.java    From DataVec with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(Configuration conf, InputSplit split) throws IOException, InterruptedException {
    this.conf = conf;
    this.appendLabel = conf.getBoolean(APPEND_LABEL, false);
    this.labels = new ArrayList<>(conf.getStringCollection(LABELS));
    initialize(split);
}
 
Example 7
Source File: BaseAudioRecordReader.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Override
public void initialize(Configuration conf, InputSplit split) throws IOException, InterruptedException {
    this.conf = conf;
    this.appendLabel = conf.getBoolean(APPEND_LABEL, false);
    this.labels = new ArrayList<>(conf.getStringCollection(LABELS));
    initialize(split);
}