org.datavec.api.records.reader.impl.jackson.FieldSelection Java Examples
The following examples show how to use
org.datavec.api.records.reader.impl.jackson.FieldSelection.
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: JacksonLineRecordReaderTest.java From DataVec with Apache License 2.0 | 5 votes |
private static FieldSelection getFieldSelection() { return new FieldSelection.Builder().addField("value1"). addField("value2"). addField("value3"). addField("value4"). addField("value5"). addField("value6"). addField("value7"). addField("value8"). addField("value9"). addField("value10").build(); }
Example #2
Source File: TestSerialization.java From DataVec with Apache License 2.0 | 5 votes |
@Test public void testRR() throws Exception { List<RecordReader> rrs = new ArrayList<>(); rrs.add(new CSVNLinesSequenceRecordReader(10)); rrs.add(new CSVRecordReader(10, ',')); rrs.add(new CSVSequenceRecordReader(1, ",")); rrs.add(new CSVVariableSlidingWindowRecordReader(5)); rrs.add(new CSVRegexRecordReader(0, ",", null, new String[] {null, "(.+) (.+) (.+)"})); rrs.add(new JacksonRecordReader(new FieldSelection.Builder().addField("a").addField(new Text("MISSING_B"), "b") .addField(new Text("MISSING_CX"), "c", "x").build(), new ObjectMapper(new JsonFactory()))); rrs.add(new JacksonLineRecordReader(new FieldSelection.Builder().addField("value1") .addField("value2").build(), new ObjectMapper(new JsonFactory()))); rrs.add(new LibSvmRecordReader()); rrs.add(new SVMLightRecordReader()); rrs.add(new RegexLineRecordReader("(.+) (.+) (.+)", 0)); rrs.add(new RegexSequenceRecordReader("(.+) (.+) (.+)", 0)); rrs.add(new TransformProcessRecordReader(new CSVRecordReader(), getTp())); rrs.add(new TransformProcessSequenceRecordReader(new CSVSequenceRecordReader(), getTp())); rrs.add(new LineRecordReader()); for(RecordReader r : rrs){ System.out.println(r.getClass().getName()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(baos); os.writeObject(r); byte[] bytes = baos.toByteArray(); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes)); RecordReader r2 = (RecordReader) ois.readObject(); } }
Example #3
Source File: JacksonLineRecordReaderTest.java From deeplearning4j with Apache License 2.0 | 5 votes |
private static FieldSelection getFieldSelection() { return new FieldSelection.Builder().addField("value1"). addField("value2"). addField("value3"). addField("value4"). addField("value5"). addField("value6"). addField("value7"). addField("value8"). addField("value9"). addField("value10").build(); }
Example #4
Source File: JacksonLineRecordReaderTest.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Test public void testJacksonLineSequenceRecordReader() throws Exception { File dir = testDir.newFolder(); new ClassPathResource("datavec-api/JacksonLineSequenceRecordReaderTest/").copyDirectory(dir); FieldSelection f = new FieldSelection.Builder().addField("a").addField(new Text("MISSING_B"), "b") .addField(new Text("MISSING_CX"), "c", "x").build(); JacksonLineSequenceRecordReader rr = new JacksonLineSequenceRecordReader(f, new ObjectMapper(new JsonFactory())); File[] files = dir.listFiles(); Arrays.sort(files); URI[] u = new URI[files.length]; for( int i=0; i<files.length; i++ ){ u[i] = files[i].toURI(); } rr.initialize(new CollectionInputSplit(u)); List<List<Writable>> expSeq0 = new ArrayList<>(); expSeq0.add(Arrays.asList((Writable) new Text("aValue0"), new Text("bValue0"), new Text("cxValue0"))); expSeq0.add(Arrays.asList((Writable) new Text("aValue1"), new Text("MISSING_B"), new Text("cxValue1"))); expSeq0.add(Arrays.asList((Writable) new Text("aValue2"), new Text("bValue2"), new Text("MISSING_CX"))); List<List<Writable>> expSeq1 = new ArrayList<>(); expSeq1.add(Arrays.asList((Writable) new Text("aValue3"), new Text("bValue3"), new Text("cxValue3"))); int count = 0; while(rr.hasNext()){ List<List<Writable>> next = rr.sequenceRecord(); if(count++ == 0){ assertEquals(expSeq0, next); } else { assertEquals(expSeq1, next); } } assertEquals(2, count); }
Example #5
Source File: TestSerialization.java From deeplearning4j with Apache License 2.0 | 5 votes |
@Test public void testRR() throws Exception { List<RecordReader> rrs = new ArrayList<>(); rrs.add(new CSVNLinesSequenceRecordReader(10)); rrs.add(new CSVRecordReader(10, ',')); rrs.add(new CSVSequenceRecordReader(1, ",")); rrs.add(new CSVVariableSlidingWindowRecordReader(5)); rrs.add(new CSVRegexRecordReader(0, ",", null, new String[] {null, "(.+) (.+) (.+)"})); rrs.add(new JacksonRecordReader(new FieldSelection.Builder().addField("a").addField(new Text("MISSING_B"), "b") .addField(new Text("MISSING_CX"), "c", "x").build(), new ObjectMapper(new JsonFactory()))); rrs.add(new JacksonLineRecordReader(new FieldSelection.Builder().addField("value1") .addField("value2").build(), new ObjectMapper(new JsonFactory()))); rrs.add(new LibSvmRecordReader()); rrs.add(new SVMLightRecordReader()); rrs.add(new RegexLineRecordReader("(.+) (.+) (.+)", 0)); rrs.add(new RegexSequenceRecordReader("(.+) (.+) (.+)", 0)); rrs.add(new TransformProcessRecordReader(new CSVRecordReader(), getTp())); rrs.add(new TransformProcessSequenceRecordReader(new CSVSequenceRecordReader(), getTp())); rrs.add(new LineRecordReader()); for(RecordReader r : rrs){ System.out.println(r.getClass().getName()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(baos); os.writeObject(r); byte[] bytes = baos.toByteArray(); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes)); RecordReader r2 = (RecordReader) ois.readObject(); } }
Example #6
Source File: JacksonRecordReaderTest.java From DataVec with Apache License 2.0 | 4 votes |
private static FieldSelection getFieldSelection() { return new FieldSelection.Builder().addField("a").addField(new Text("MISSING_B"), "b") .addField(new Text("MISSING_CX"), "c", "x").build(); }
Example #7
Source File: JacksonRecordReaderTest.java From deeplearning4j with Apache License 2.0 | 4 votes |
private static FieldSelection getFieldSelection() { return new FieldSelection.Builder().addField("a").addField(new Text("MISSING_B"), "b") .addField(new Text("MISSING_CX"), "c", "x").build(); }