Package org.apache.mahout.common

Examples of org.apache.mahout.common.FileLineIterator


    StringBuilder content = new StringBuilder();
    content.append(header);
    int filenumber = 0;
    NumberFormat decimalFormatter = new DecimalFormat("0000");
    FileLineIterator it = new FileLineIterator(new File(dumpFilePath));
    while (it.hasNext()) {
      String thisLine = it.next();
      if(thisLine.trim().startsWith("<page>")){
        boolean end = false;
        while(thisLine.trim().startsWith("</page>") == false){
          content.append(thisLine).append('\n');
          if (it.hasNext()) {
            thisLine = it.next();
          } else {
            end = true;
            break;
          }
        }
View Full Code Here


  }

  @Override
  protected DataModel buildModel() throws IOException {
    FastByIDMap<Collection<Preference>> data = new FastByIDMap<Collection<Preference>>();
    FileLineIterator iterator = new FileLineIterator(getDataFile(), false);
    processFile(iterator, data, ',');
    return new GenericDataModel(GenericDataModel.toDataMap(data, true));
  }
View Full Code Here

   * @param path data path
   * @return
   */
  public static int[] extractLabels(Dataset dataset, FileSystem fs, Path path) throws IOException {
    FSDataInputStream input = fs.open(path);
    FileLineIterator iterator = new FileLineIterator(input);

    int[] labels = new int[dataset.nbInstances()];
    DataConverter converter = new DataConverter(dataset);
   
    int index = 0;
   
    while (iterator.hasNext()) {
      labels[index++] = converter.convert(0, iterator.next()).label;
    }
   
    iterator.close();
   
    return labels;
  }
View Full Code Here

    }
  }

  // Reads dictionary in created by the vector Driver in util
  private static List<String> readDictionary(File path) throws IOException {
    FileLineIterator it = new FileLineIterator(path);

    List<String> result = new ArrayList<String>();

    // skip 2 lines
    it.next();
    it.next();
    while (it.hasNext()) {
      String line = it.next();
      String[] parts = TAB_PATTERN.split(line);
      String word = parts[0];
      int index = Integer.parseInt(parts[2]);
      if (index != result.size()) {
        throw new IllegalArgumentException();
View Full Code Here

TOP

Related Classes of org.apache.mahout.common.FileLineIterator

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.