Package org.encog.app.analyst.csv.segregate

Examples of org.encog.app.analyst.csv.segregate.SegregateCSV


    }

    public void testFilterCSVHeaders() throws IOException
    {
        generateTestFileHeadings(true);
        SegregateCSV norm = new SegregateCSV();
        norm.getTargets().add(new SegregateTargetPercent(OUTPUT1_NAME, 75));
        norm.getTargets().add(new SegregateTargetPercent(OUTPUT2_NAME, 25));
        norm.analyze(INPUT_NAME, true, CSVFormat.ENGLISH);           
        norm.process();

        BufferedReader tr = new BufferedReader(new FileReader(OUTPUT1_NAME));
        Assert.assertEquals("\"a\",\"b\"",tr.readLine());
        Assert.assertEquals("one,1",tr.readLine());
        Assert.assertEquals("two,2",tr.readLine());
View Full Code Here


    }

    public void testFilterCSVNoHeaders() throws IOException
    {
        generateTestFileHeadings(false);
        SegregateCSV norm = new SegregateCSV();
        norm.getTargets().add(new SegregateTargetPercent(OUTPUT1_NAME, 75));
        norm.getTargets().add(new SegregateTargetPercent(OUTPUT2_NAME, 25));
        norm.analyze(INPUT_NAME, false, CSVFormat.ENGLISH);
        norm.setProduceOutputHeaders(false);
        norm.process();

        BufferedReader tr = new BufferedReader(new FileReader(OUTPUT1_NAME));
        Assert.assertEquals("one,1", tr.readLine());
        Assert.assertEquals("two,2", tr.readLine());
        Assert.assertEquals("three,3", tr.readLine());
View Full Code Here

        .determineInputFormat(sourceID);
    final CSVFormat outputFormat = getScript().determineOutputFormat();

    // prepare to segregate
    final boolean headers = getScript().expectInputHeaders(sourceID);
    final SegregateCSV seg = new SegregateCSV();
    seg.setScript(getScript());
    getAnalyst().setCurrentQuantTask(seg);
    for (final AnalystSegregateTarget target : getScript().getSegregate()
        .getSegregateTargets()) {
      final File filename = getScript().resolveFilename(target.getFile());
      seg.getTargets().add(
          new SegregateTargetPercent(filename, target.getPercent()));
      // mark generated
      getScript().markGenerated(target.getFile());
      EncogLogging.log(EncogLogging.LEVEL_DEBUG, "target file:"
          + target.getFile() + ", Percent: "
          + Format.formatPercent(target.getPercent()));

    }

    seg.setReport(new AnalystReportBridge(getAnalyst()));
    seg.analyze(sourceFile, headers, inputFormat);
    seg.setOutputFormat(outputFormat);

    seg.process();
    getAnalyst().setCurrentQuantTask(null);
    return seg.shouldStop();
  }
View Full Code Here

    // get formats
    final CSVFormat format = getScript().determineFormat();

    // prepare to segregate
    final boolean headers = getScript().expectInputHeaders(sourceID);
    final SegregateCSV seg = new SegregateCSV();
    seg.setScript(getScript());
    getAnalyst().setCurrentQuantTask(seg);
    for (final AnalystSegregateTarget target : getScript().getSegregate()
        .getSegregateTargets()) {
      final File filename = getScript().resolveFilename(target.getFile());
      seg.getTargets().add(
          new SegregateTargetPercent(filename, target.getPercent()));
      // mark generated
      getScript().markGenerated(target.getFile());
      EncogLogging.log(EncogLogging.LEVEL_DEBUG, "target file:"
          + target.getFile() + ", Percent: "
          + Format.formatPercent(target.getPercent()));

    }

    seg.setReport(new AnalystReportBridge(getAnalyst()));
    seg.analyze(sourceFile, headers, format);

    seg.process();
    getAnalyst().setCurrentQuantTask(null);
    return seg.shouldStop();
  }
View Full Code Here

    }

    public void testFilterCSVHeaders() throws IOException
    {
        generateTestFileHeadings(true);
        SegregateCSV norm = new SegregateCSV();
        norm.getTargets().add(new SegregateTargetPercent(OUTPUT1_NAME, 75));
        norm.getTargets().add(new SegregateTargetPercent(OUTPUT2_NAME, 25));
        norm.analyze(INPUT_NAME, true, CSVFormat.ENGLISH);           
        norm.process();

        BufferedReader tr = new BufferedReader(new FileReader(OUTPUT1_NAME));
        Assert.assertEquals("\"a\",\"b\"",tr.readLine());
        Assert.assertEquals("one,1",tr.readLine());
        Assert.assertEquals("two,2",tr.readLine());
View Full Code Here

    }

    public void testFilterCSVNoHeaders() throws IOException
    {
        generateTestFileHeadings(false);
        SegregateCSV norm = new SegregateCSV();
        norm.getTargets().add(new SegregateTargetPercent(OUTPUT1_NAME, 75));
        norm.getTargets().add(new SegregateTargetPercent(OUTPUT2_NAME, 25));
        norm.analyze(INPUT_NAME, false, CSVFormat.ENGLISH);
        norm.setProduceOutputHeaders(false);
        norm.process();

        BufferedReader tr = new BufferedReader(new FileReader(OUTPUT1_NAME));
        Assert.assertEquals("one,1", tr.readLine());
        Assert.assertEquals("two,2", tr.readLine());
        Assert.assertEquals("three,3", tr.readLine());
View Full Code Here

TOP

Related Classes of org.encog.app.analyst.csv.segregate.SegregateCSV

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.