Package org.apache.mahout.utils.vectors.io

Examples of org.apache.mahout.utils.vectors.io.TextualVectorWriter


  @Test
  public void testCount() throws Exception {

    StringWriter sWriter = new StringWriter();
    TextualVectorWriter writer = new TextualVectorWriter(sWriter) {
      @Override
      public void write(Vector vector) throws IOException {
        String vecStr = VectorHelper.vectorToCSVString(vector, false);
        getWriter().write(vecStr);
      }
    };
    try {
      Iterable<Vector> iter = new RandomVectorIterable(50);
      writer.write(iter);
    } finally {
      Closeables.close(writer, false);
    }
    Iterator<Vector> csvIter = new CSVVectorIterator(new StringReader(sWriter.getBuffer().toString()));
    int count = 0;
View Full Code Here


  @Test
  public void testCount() throws Exception {

    StringWriter sWriter = new StringWriter();
    TextualVectorWriter jwvw = new TextualVectorWriter(sWriter) {
      @Override
      public void write(Vector vector) throws IOException {
        String vecStr = VectorHelper.vectorToCSVString(vector, false);
        getWriter().write(vecStr);
      }
    };
    Iterable<Vector> iter = new RandomVectorIterable(50);
    jwvw.write(iter);
    jwvw.close();
    Iterator<Vector> csvIter = new CSVVectorIterator(new StringReader(sWriter.getBuffer().toString()));
    int count = 0;
    while (csvIter.hasNext()) {
      csvIter.next();
      count++;
View Full Code Here

  @Test
  public void testCount() throws Exception {

    StringWriter sWriter = new StringWriter();
    TextualVectorWriter writer = new TextualVectorWriter(sWriter) {
      @Override
      public void write(Vector vector) throws IOException {
        String vecStr = VectorHelper.vectorToCSVString(vector, false);
        getWriter().write(vecStr);
      }
    };
    try {
      Iterable<Vector> iter = new RandomVectorIterable(50);
      writer.write(iter);
    } finally {
      Closeables.close(writer, false);
    }
    Iterator<Vector> csvIter = new CSVVectorIterator(new StringReader(sWriter.getBuffer().toString()));
    int count = 0;
View Full Code Here

  @Test
  public void testCount() throws Exception {

    StringWriter sWriter = new StringWriter();
    TextualVectorWriter writer = new TextualVectorWriter(sWriter) {
      @Override
      public void write(Vector vector) throws IOException {
        String vecStr = VectorHelper.vectorToCSVString(vector, false);
        getWriter().write(vecStr);
      }
    };
    try {
      Iterable<Vector> iter = new RandomVectorIterable(50);
      writer.write(iter);
    } finally {
      Closeables.closeQuietly(writer);
    }
    Iterator<Vector> csvIter = new CSVVectorIterator(new StringReader(sWriter.getBuffer().toString()));
    int count = 0;
View Full Code Here

TOP

Related Classes of org.apache.mahout.utils.vectors.io.TextualVectorWriter

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.