Package org.encog.app.analyst.csv.balance

Examples of org.encog.app.analyst.csv.balance.BalanceCSV


    out.close();
  }

  public void testBalanceCSVHeaders() throws IOException {
    generateTestFile(true);
    BalanceCSV norm = new BalanceCSV();
    norm.analyze(INPUT_NAME, true, CSVFormat.ENGLISH);
    norm.process(OUTPUT_NAME, 1, 2);

    BufferedReader tr = new BufferedReader(new FileReader(OUTPUT_NAME));

    Assert.assertEquals("\"a\",\"b\"", tr.readLine());
    Assert.assertEquals("one,1", tr.readLine());
    Assert.assertEquals("two,1", tr.readLine());
    Assert.assertEquals("four,2", tr.readLine());
    Assert.assertEquals("five,2", tr.readLine());
    Assert.assertEquals("six,3", tr.readLine());
    Assert.assertEquals(2, norm.getCounts().get("1").intValue());
    Assert.assertEquals(2, norm.getCounts().get("2").intValue());
    Assert.assertEquals(1, norm.getCounts().get("3").intValue());
    tr.close();

    INPUT_NAME.delete();
    OUTPUT_NAME.delete();
View Full Code Here


  }

  public void TestBalanceCSVNoHeaders() throws IOException {
    generateTestFile(false);
    BalanceCSV norm = new BalanceCSV();
    norm.analyze(INPUT_NAME, false, CSVFormat.ENGLISH);
    norm.process(OUTPUT_NAME, 1, 2);

    BufferedReader tr = new BufferedReader(new FileReader(OUTPUT_NAME));

    Assert.assertEquals("one,1", tr.readLine());
    Assert.assertEquals("two,1", tr.readLine());
    Assert.assertEquals("four,2", tr.readLine());
    Assert.assertEquals("five,2", tr.readLine());
    Assert.assertEquals("six,3", tr.readLine());
    Assert.assertEquals(2, norm.getCounts().get("1").intValue());
    Assert.assertEquals(2, norm.getCounts().get("2").intValue());
    Assert.assertEquals(1, norm.getCounts().get("3").intValue());
    tr.close();

    INPUT_NAME.delete();
    OUTPUT_NAME.delete();
  }
View Full Code Here

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

    // prepare to normalize
    final BalanceCSV balance = new BalanceCSV();
    balance.setScript(getScript());
    getAnalyst().setCurrentQuantTask(balance);
    balance.setReport(new AnalystReportBridge(getAnalyst()));

    final boolean headers = getScript().expectInputHeaders(sourceID);
    balance.analyze(sourceFile, headers, inputFormat);
    balance.setOutputFormat(outputFormat);
    balance.setProduceOutputHeaders(true);
    balance.process(targetFile, targetFieldIndex, countPer);
    getAnalyst().setCurrentQuantTask(null);
    return balance.shouldStop();
  }
View Full Code Here

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

    // prepare to normalize
    final BalanceCSV balance = new BalanceCSV();
    balance.setScript(getScript());
    getAnalyst().setCurrentQuantTask(balance);
    balance.setReport(new AnalystReportBridge(getAnalyst()));

    final boolean headers = getScript().expectInputHeaders(sourceID);
    balance.analyze(sourceFile, headers, format);
    balance.setProduceOutputHeaders(true);
    balance.process(targetFile, targetFieldIndex, countPer);
    getAnalyst().setCurrentQuantTask(null);
    return balance.shouldStop();
  }
View Full Code Here

    out.close();
  }

  public void testBalanceCSVHeaders() throws IOException {
    generateTestFile(true);
    BalanceCSV norm = new BalanceCSV();
    norm.analyze(INPUT_NAME, true, CSVFormat.ENGLISH);
    norm.process(OUTPUT_NAME, 1, 2);

    BufferedReader tr = new BufferedReader(new FileReader(OUTPUT_NAME));

    Assert.assertEquals("\"a\",\"b\"", tr.readLine());
    Assert.assertEquals("one,1", tr.readLine());
    Assert.assertEquals("two,1", tr.readLine());
    Assert.assertEquals("four,2", tr.readLine());
    Assert.assertEquals("five,2", tr.readLine());
    Assert.assertEquals("six,3", tr.readLine());
    Assert.assertEquals(2, norm.getCounts().get("1").intValue());
    Assert.assertEquals(2, norm.getCounts().get("2").intValue());
    Assert.assertEquals(1, norm.getCounts().get("3").intValue());
    tr.close();

    INPUT_NAME.delete();
    OUTPUT_NAME.delete();
View Full Code Here

  }

  public void TestBalanceCSVNoHeaders() throws IOException {
    generateTestFile(false);
    BalanceCSV norm = new BalanceCSV();
    norm.analyze(INPUT_NAME, false, CSVFormat.ENGLISH);
    norm.process(OUTPUT_NAME, 1, 2);

    BufferedReader tr = new BufferedReader(new FileReader(OUTPUT_NAME));

    Assert.assertEquals("one,1", tr.readLine());
    Assert.assertEquals("two,1", tr.readLine());
    Assert.assertEquals("four,2", tr.readLine());
    Assert.assertEquals("five,2", tr.readLine());
    Assert.assertEquals("six,3", tr.readLine());
    Assert.assertEquals(2, norm.getCounts().get("1").intValue());
    Assert.assertEquals(2, norm.getCounts().get("2").intValue());
    Assert.assertEquals(1, norm.getCounts().get("3").intValue());
    tr.close();

    INPUT_NAME.delete();
    OUTPUT_NAME.delete();
  }
View Full Code Here

TOP

Related Classes of org.encog.app.analyst.csv.balance.BalanceCSV

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.