Package gnu.trove.map.hash

Examples of gnu.trove.map.hash.TIntFloatHashMap$TValueView


    return TypeUtil.SPARSE_FLOAT_FIELD;
  }

  @Override
  protected SimpleTypeInformation<? super SparseFloatVector> convertedType(SimpleTypeInformation<SparseFloatVector> in) {
    final TIntFloatHashMap emptyMap = new TIntFloatHashMap();
    return new VectorFieldTypeInformation<SparseFloatVector>(SparseFloatVector.class, getDimensionality(), new SparseFloatVector(emptyMap, getDimensionality()));
  }
View Full Code Here


  @Override
  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();
          iter.setValue((float) (iter.value() / len));
        }
      }
    }
View Full Code Here

  @Override
  protected void parseLineInternal(String line) {
    List<String> entries = tokenize(line);
    int cardinality = Integer.parseInt(entries.get(0));

    TIntFloatHashMap values = new TIntFloatHashMap(cardinality, 1);
    LabelList labels = null;

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

          break;
        }
      }
      assert (s >= 0);
      if(elkitypes[out] == TypeUtil.NUMBER_VECTOR_FIELD) {
        TIntFloatHashMap f = new TIntFloatHashMap(dimsize[out]);
        for(TIntObjectIterator<Object> iter = map.iterator(); iter.hasNext();) {
          iter.advance();
          int i = iter.key();
          if(i < s) {
            continue;
          }
          if(i >= s + dimsize[out]) {
            break;
          }
          double v = (Double) iter.value();
          f.put(i - s + 1, (float) v);
        }
        data[out] = new SparseFloatVector(f, dimsize[out]);
      }
      else if(elkitypes[out] == TypeUtil.LABELLIST) {
        // Build a label list out of successive labels
View Full Code Here

TOP

Related Classes of gnu.trove.map.hash.TIntFloatHashMap$TValueView

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.