Package de.lmu.ifi.dbs.elki.data

Examples of de.lmu.ifi.dbs.elki.data.LabelList


            if(eid != null) {
              lblmap.put(eid.toString(), id);
            }
          }
          if(olq != null) {
            LabelList label = olq.get(id);
            if(label != null) {
              for(String lbl : label) {
                lblmap.put(lbl, id);
              }
            }
View Full Code Here


      List<LabelList> lblcol = new ArrayList<LabelList>(objects.dataLength());

      // Split the column
      for(Object obj : objects.getColumn(i)) {
        if(obj != null) {
          LabelList ll = (LabelList) obj;
          try {
            ClassLabel lbl = classLabelFactory.makeFromString(ll.remove(classLabelIndex));
            clscol.add(lbl);
          }
          catch(Exception e) {
            throw new AbortException("Cannot initialize class labels: "+e.getMessage(), e);
          }
          lblcol.add(ll);
          if(ll.size() > 0) {
            keeplabelcol = true;
          }
        }
        else {
          clscol.add(null);
View Full Code Here

             * for (int i = 0; i < data.length; i++) { data[i] = new
             * ArrayList<Double>(); }
             */
            labels = ClassGenericsUtil.newArrayOfNull(dimensionality, LabelList.class);
            for(int i = 0; i < labels.length; i++) {
              labels[i] = new LabelList();
            }
          }

          for(int i = 0; i < entries.size(); i++) {
            try {
View Full Code Here

      List<LabelList> lblcol = new ArrayList<LabelList>(objects.dataLength());

      // Split the column
      for(Object obj : objects.getColumn(i)) {
        if(obj != null) {
          LabelList ll = (LabelList) obj;
          eidcol.add(new ExternalID(ll.remove(externalIdIndex)));
          lblcol.add(ll);
          if(ll.size() > 0) {
            keeplabelcol = true;
          }
        }
        else {
          eidcol.add(null);
View Full Code Here

  @Override
  public Pair<SparseFloatVector, LabelList> parseLineInternal(String line) {
    List<String> entries = tokenize(line);

    Map<Integer, Float> values = new TreeMap<Integer, Float>();
    LabelList labels = new LabelList();

    String curterm = null;
    for(int i = 0; i < entries.size(); i++) {
      if(curterm == null) {
        curterm = entries.get(i);
      }
      else {
        try {
          Float attribute = Float.valueOf(entries.get(i));
          Integer curdim = keymap.get(curterm);
          if(curdim == null) {
            curdim = maxdim + 1;
            keymap.put(curterm, curdim);
            maxdim += 1;
          }
          values.put(curdim, attribute);
          curterm = null;
        }
        catch(NumberFormatException e) {
          if(curterm != null) {
            labels.add(curterm);
          }
          curterm = entries.get(i);
        }
      }
    }
    if(curterm != null) {
      labels.add(curterm);
    }

    return new Pair<SparseFloatVector, LabelList>(new SparseFloatVector(values, maxdim), labels);
  }
View Full Code Here

      List<LabelList> lblcol = new ArrayList<LabelList>(objects.dataLength());

      // Split the column
      for(Object obj : objects.getColumn(i)) {
        if(obj != null) {
          LabelList ll = (LabelList) obj;
          try {
            ClassLabel lbl = classLabelFactory.makeFromString(ll.remove(classLabelIndex));
            clscol.add(lbl);
          }
          catch(Exception e) {
            throw new AbortException("Cannot initialize class labels: "+e.getMessage(), e);
          }
          lblcol.add(ll);
          if(ll.size() > 0) {
            keeplabelcol = true;
          }
        }
        else {
          clscol.add(null);
View Full Code Here

      List<LabelList> lblcol = new ArrayList<LabelList>(objects.dataLength());

      // Split the column
      for(Object obj : objects.getColumn(i)) {
        if(obj != null) {
          LabelList ll = (LabelList) obj;
          eidcol.add(new ExternalID(ll.remove(externalIdIndex)));
          lblcol.add(ll);
          if(ll.size() > 0) {
            keeplabelcol = true;
          }
        }
        else {
          eidcol.add(null);
View Full Code Here

      for(String line; (line = reader.readLine()) != null; lineNumber++) {
        if(!line.startsWith(COMMENT) && line.length() > 0) {
          List<String> entries = tokenize(line);
          // TODO: use more efficient storage right away?
          List<Bit> attributes = new ArrayList<Bit>();
          LabelList ll = new LabelList();
          for(String entry : entries) {
            try {
              Bit attribute = Bit.valueOf(entry);
              attributes.add(attribute);
            }
            catch(NumberFormatException e) {
              ll.add(entry);
            }
          }

          if(dimensionality < 0) {
            dimensionality = attributes.size();
View Full Code Here

      List<LabelList> allLabels = new ArrayList<LabelList>();
      for(String line; (line = reader.readLine()) != null; lineNumber++) {
        if(!line.startsWith(COMMENT) && line.length() > 0) {
          List<String> entries = tokenize(line);
          BitSet bitSet = new BitSet();
          LabelList labels = new LabelList();

          for(String entry : entries) {
            try {
              Integer index = Integer.valueOf(entry);
              bitSet.set(index);
              dimensionality = Math.max(dimensionality, index);
            }
            catch(NumberFormatException e) {
              labels.add(entry);
            }
          }

          bitSets.add(bitSet);
          allLabels.add(labels);
        }
      }

      dimensionality++;
      for(int i = 0; i < bitSets.size(); i++) {
        BitSet bitSet = bitSets.get(i);
        LabelList labels = allLabels.get(i);
        vectors.add(new BitVector(bitSet, dimensionality));
        lblc.add(labels);
      }
    }
    catch(IOException e) {
View Full Code Here

   */
  private Object[] parseLine(String line) {
    List<String> entries = tokenize(line);
    Iterator<String> iter = entries.iterator();

    LabelList labels = new LabelList();
    List<Polygon> polys = new java.util.Vector<Polygon>(1);

    List<Vector> coords = new ArrayList<Vector>();
    while(iter.hasNext()) {
      String cur = iter.next();
      Matcher m = COORD.matcher(cur);
      if(m.find()) {
        try {
          double c1 = Double.valueOf(m.group(1));
          double c2 = Double.valueOf(m.group(2));
          if(m.group(3) != null) {
            double c3 = Double.valueOf(m.group(3));
            coords.add(new Vector(new double[] { c1, c2, c3 }));
          }
          else {
            coords.add(new Vector(new double[] { c1, c2 }));
          }
          continue;
        }
        catch(NumberFormatException e) {
          logger.warning("Looked like a coordinate pair but didn't parse: " + cur);
        }
      }
      // Polygon separator.
      if(cur.equals(POLYGON_SEPARATOR)) {
        if(coords.size() > 0) {
          polys.add(new Polygon(coords));
          coords = new ArrayList<Vector>();
        }
        continue;
      }
      // Label
      labels.add(cur);
    }
    // Complete polygon
    if(coords.size() > 0) {
      polys.add(new Polygon(coords));
    }
    // Use first label as eternal ID
    ExternalID eid = labels.size() > 0 ? new ExternalID(labels.remove(0)) : null;
    return new Object[] { new PolygonsObject(polys), labels, eid };
  }
View Full Code Here

TOP

Related Classes of de.lmu.ifi.dbs.elki.data.LabelList

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.