Examples of LabelList


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

      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

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

      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

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

   */
  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

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

  public Pair<SparseFloatVector, LabelList> parseLineInternal(String line) {
    List<String> entries = tokenize(line);
    int cardinality = Integer.parseInt(entries.get(0));

    Map<Integer, Float> values = new HashMap<Integer, Float>(cardinality, 1);
    LabelList labels = new LabelList();

    for(int i = 1; i < entries.size() - 1; i++) {
      if(!labelIndices.get(i)) {
        Integer index;
        Float attribute;
        try {
          index = Integer.valueOf(entries.get(i));
          if(index > dimensionality) {
            dimensionality = index;
          }
          i++;
        }
        catch(NumberFormatException e) {
          labels.add(entries.get(i));
          continue;
        }
        attribute = Float.valueOf(entries.get(i));
        values.put(index, attribute);
      }
      else {
        labels.add(entries.get(i));
      }
    }
    return new Pair<SparseFloatVector, LabelList>(new SparseFloatVector(values, dimensionality), labels);
  }
View Full Code Here

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

        }
        data[out] = new SparseFloatVector(f, dimsize[out]);
      }
      else if(elkitypes[out] == TypeUtil.LABELLIST) {
        // Build a label list out of successive labels
        LabelList ll = new LabelList();
        for(Entry<Integer, Object> key : map.entrySet()) {
          int i = key.getKey();
          if(i < s) {
            continue;
          }
          if(i >= s + dimsize[out]) {
            break;
          }
          String v = (String) key.getValue();
          if(ll.size() < i - s) {
            logger.warning("Sparse consecutive labels are currently not correctly supported.");
          }
          ll.add(v);
        }
        data[out] = ll;
      }
      else if(elkitypes[out] == TypeUtil.EXTERNALID) {
        String val = (String) map.get(s);
View Full Code Here

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

        }
        data[out] = new DoubleVector(cur);
      }
      else if(etyp[out] == TypeUtil.LABELLIST) {
        // Build a label list out of successive labels
        LabelList ll = new LabelList();
        for(int k = 0; k < dimsize[out]; k++) {
          if(tokenizer.ttype != StreamTokenizer.TT_WORD) {
            throw new AbortException("Expected word token, got: " + tokenizer.toString());
          }
          ll.add(tokenizer.sval);
          nextToken(tokenizer);
        }
        data[out] = ll;
      }
      else if(etyp[out] == TypeUtil.EXTERNALID) {
View Full Code Here

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

    try {
      for(String line; (line = reader.readLine()) != null; lineNumber++) {
        if(!line.startsWith(COMMENT) && line.length() > 0) {
          List<String> entries = tokenize(line);
          List<Double> attributes = new ArrayList<Double>(entries.size());
          LabelList labellist = new LabelList();
          for(String entry : entries) {
            try {
              Double attribute = Double.valueOf(entry);
              attributes.add(attribute);
            }
            catch(NumberFormatException e) {
              labellist.add(entry);
            }
          }

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

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

  protected Pair<V, LabelList> parseLineInternal(String line) {
    List<String> entries = tokenize(line);

    // Split into numerical attributes and labels
    List<Double> attributes = new ArrayList<Double>(entries.size());
    LabelList labels = new LabelList();

    Iterator<String> itr = entries.iterator();
    for(int i = 0; itr.hasNext(); i++) {
      String ent = itr.next();
      if(!labelIndices.get(i)) {
        try {
          Double attribute = Double.valueOf(ent);
          attributes.add(attribute);
        }
        catch(NumberFormatException e) {
          labels.add(ent);
        }
      }
      else {
        labels.add(ent);
      }
    }

    Pair<V, LabelList> objectAndLabels;
    V vec = createDBObject(attributes);
View Full Code Here

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

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

    ExternalID eid = null;
    LabelList labels = null;
    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.parseDouble(m.group(1));
          double c2 = Double.parseDouble(m.group(2));
          if(m.group(3) != null) {
            double c3 = Double.parseDouble(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;
      }
      // First label will become the External ID
      if(eid == null) {
        eid = new ExternalID(cur);
      }
      else {
        // Label
        if(labels == null) {
          labels = new LabelList(1);
        }
        labels.add(cur);
      }
    }
    // Complete polygon
    if(coords.size() > 0) {
      polys.add(new Polygon(coords));
View Full Code Here

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

  protected void parseLineInternal(String line) {
    List<String> entries = tokenize(line);

    double len = 0;
    TIntFloatHashMap values = new TIntFloatHashMap();
    LabelList labels = null;

    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);
          len += attribute;
          curterm = null;
        }
        catch(NumberFormatException e) {
          if(curterm != null) {
            if(labels == null) {
              labels = new LabelList(1);
            }
            labels.add(curterm);
          }
          curterm = entries.get(i);
        }
      }
    }
    if(curterm != null) {
      if(labels == null) {
        labels = new LabelList(1);
      }
      labels.add(curterm);
    }
    if(normalize) {
      if(Math.abs(len - 1.0) > 1E-10 && len > 1E-10) {
        for(TIntFloatIterator iter = values.iterator(); iter.hasNext();) {
          iter.advance();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.