Java Code Examples for org.datavec.api.records.metadata.RecordMetaData#getURI()

The following examples show how to use org.datavec.api.records.metadata.RecordMetaData#getURI() . 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: JacksonRecordReader.java    From DataVec with Apache License 2.0 6 votes vote down vote up
@Override
public List<Record> loadFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException {

    List<Record> out = new ArrayList<>();
    for (RecordMetaData metaData : recordMetaDatas) {
        URI uri = metaData.getURI();

        String fileAsString;
        try {
            fileAsString = FileUtils.readFileToString(new File(uri.toURL().getFile()));
        } catch (IOException e) {
            throw new RuntimeException("Error reading URI file", e);
        }

        List<Writable> writables = readValues(uri, fileAsString);
        out.add(new org.datavec.api.records.impl.Record(writables, metaData));
    }

    return out;
}
 
Example 2
Source File: FileRecordReader.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
@Override
public List<Record> loadFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException {
    List<Record> out = new ArrayList<>();

    for (RecordMetaData meta : recordMetaDatas) {
        URI uri = meta.getURI();

        List<Writable> list;
        try(InputStream s = streamCreatorFn.apply(uri)) {
            list = loadFromStream(uri, s, Charset.forName(charset));
        } catch (IOException e){
            throw new RuntimeException("Error reading from stream for URI: " + uri);
        }

        out.add(new org.datavec.api.records.impl.Record(list, meta));
    }

    return out;
}
 
Example 3
Source File: JacksonRecordReader.java    From deeplearning4j with Apache License 2.0 6 votes vote down vote up
@Override
public List<Record> loadFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException {

    List<Record> out = new ArrayList<>();
    for (RecordMetaData metaData : recordMetaDatas) {
        URI uri = metaData.getURI();

        String fileAsString;
        try {
            fileAsString = FileUtils.readFileToString(new File(uri.toURL().getFile()));
        } catch (IOException e) {
            throw new RuntimeException("Error reading URI file", e);
        }

        List<Writable> writables = readValues(uri, fileAsString);
        out.add(new org.datavec.api.records.impl.Record(writables, metaData));
    }

    return out;
}
 
Example 4
Source File: BaseImageRecordReader.java    From DataVec with Apache License 2.0 5 votes vote down vote up
@Override
public List<Record> loadFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException {
    List<Record> out = new ArrayList<>();
    for (RecordMetaData meta : recordMetaDatas) {
        URI uri = meta.getURI();
        File f = new File(uri);

        List<Writable> next;
        try (DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(f)))) {
            next = record(uri, dis);
        }
        out.add(new org.datavec.api.records.impl.Record(next, meta));
    }
    return out;
}
 
Example 5
Source File: BaseCodecRecordReader.java    From DataVec with Apache License 2.0 5 votes vote down vote up
@Override
public List<SequenceRecord> loadSequenceFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException {
    List<SequenceRecord> out = new ArrayList<>();
    for (RecordMetaData meta : recordMetaDatas) {
        File f = new File(meta.getURI());

        List<List<Writable>> list = loadData(f, null);
        out.add(new org.datavec.api.records.impl.SequenceRecord(list, meta));
    }

    return out;
}
 
Example 6
Source File: FileRecordReader.java    From DataVec with Apache License 2.0 5 votes vote down vote up
@Override
public List<Record> loadFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException {
    List<Record> out = new ArrayList<>();

    for (RecordMetaData meta : recordMetaDatas) {
        URI uri = meta.getURI();

        File f = new File(uri);
        List<Writable> list = loadFromFile(f);
        out.add(new org.datavec.api.records.impl.Record(list, meta));
    }

    return out;
}
 
Example 7
Source File: RegexSequenceRecordReader.java    From DataVec with Apache License 2.0 5 votes vote down vote up
@Override
public List<SequenceRecord> loadSequenceFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException {
    List<SequenceRecord> out = new ArrayList<>();
    for (RecordMetaData meta : recordMetaDatas) {
        File next = new File(meta.getURI());
        URI uri = next.toURI();
        String fileContents = FileUtils.readFileToString(next, charset.name());
        List<List<Writable>> sequence = loadSequence(fileContents, uri);
        out.add(new org.datavec.api.records.impl.SequenceRecord(sequence, meta));
    }
    return out;
}
 
Example 8
Source File: CSVSequenceRecordReader.java    From DataVec with Apache License 2.0 5 votes vote down vote up
@Override
public List<SequenceRecord> loadSequenceFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException {
    List<SequenceRecord> out = new ArrayList<>();
    for (RecordMetaData meta : recordMetaDatas) {
        File next = new File(meta.getURI());
        List<List<Writable>> sequence = loadAndClose(new FileInputStream(next));
        out.add(new org.datavec.api.records.impl.SequenceRecord(sequence, meta));
    }
    return out;
}
 
Example 9
Source File: BaseImageRecordReader.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Override
public List<Record> loadFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException {
    List<Record> out = new ArrayList<>();
    for (RecordMetaData meta : recordMetaDatas) {
        URI uri = meta.getURI();
        File f = new File(uri);

        List<Writable> next;
        try (DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(f)))) {
            next = record(uri, dis);
        }
        out.add(new org.datavec.api.records.impl.Record(next, meta));
    }
    return out;
}
 
Example 10
Source File: RegexSequenceRecordReader.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Override
public List<SequenceRecord> loadSequenceFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException {
    List<SequenceRecord> out = new ArrayList<>();
    for (RecordMetaData meta : recordMetaDatas) {
        File next = new File(meta.getURI());
        URI uri = next.toURI();
        String fileContents = FileUtils.readFileToString(next, charset.name());
        List<List<Writable>> sequence = loadSequence(fileContents, uri);
        out.add(new org.datavec.api.records.impl.SequenceRecord(sequence, meta));
    }
    return out;
}
 
Example 11
Source File: CSVSequenceRecordReader.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Override
public List<SequenceRecord> loadSequenceFromMetaData(List<RecordMetaData> recordMetaDatas) throws IOException {
    List<SequenceRecord> out = new ArrayList<>();
    for (RecordMetaData meta : recordMetaDatas) {
        File next = new File(meta.getURI());
        List<List<Writable>> sequence = loadAndClose(new FileInputStream(next));
        out.add(new org.datavec.api.records.impl.SequenceRecord(sequence, meta));
    }
    return out;
}