org.datavec.api.records.reader.impl.jackson.JacksonLineRecordReader Java Examples
The following examples show how to use
org.datavec.api.records.reader.impl.jackson.JacksonLineRecordReader.
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 |
@Test public void testReadJSON() throws Exception { RecordReader rr = new JacksonLineRecordReader(getFieldSelection(), new ObjectMapper(new JsonFactory())); rr.initialize(new FileSplit(new ClassPathResource("json/json_test_3.txt").getFile())); testJacksonRecordReader(rr); }
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 |
@Test public void testReadJSON() throws Exception { RecordReader rr = new JacksonLineRecordReader(getFieldSelection(), new ObjectMapper(new JsonFactory())); rr.initialize(new FileSplit(new ClassPathResource("datavec-api/json/json_test_3.txt").getFile())); testJacksonRecordReader(rr); }
Example #4
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(); } }