Package org.apache.commons.lang.mutable

Examples of org.apache.commons.lang.mutable.MutableDouble


        wordList.put(word, wordList.get(word) + 1);
      } else {
        wordList.put(word, 1);
      }
    }
    final MutableDouble result = new MutableDouble(0.0);
   
    wordList.forEachPair(new ObjectIntProcedure<String>() {
     
      @Override
      public boolean apply(String word, int frequency) {
        try {
          result.add(frequency * featureWeight(datastore, label, word));
        } catch (InvalidDatastoreException e) {
          throw new IllegalStateException(e);
        }
        return true;
      }
    });
    return result.doubleValue();
  }
View Full Code Here


        } else {
          wordList.put(term, 1);
        }
      }
    }
    final MutableDouble lengthNormalisationMut = new MutableDouble(0.0);
    wordList.forEachPair(new ObjectIntProcedure<String>() {
      @Override
      public boolean apply(String word, int dKJ) {
        lengthNormalisationMut.add(dKJ * dKJ);
        return true;
      }
    });
   
    final double lengthNormalisation = Math.sqrt(lengthNormalisationMut.doubleValue());
   
    // Output Length Normalized + TF Transformed Frequency per Word per Class
    // Log(1 + D_ij)/SQRT( SIGMA(k, D_kj) )
    wordList.forEachPair(new ObjectIntProcedure<String>() {
      @Override
View Full Code Here

   */
  public void accumulateStoreMetric(final Map<String, MutableDouble> tmpMap,
      StoreMetricType storeMetricType, double val) {
    final String key = getStoreMetricName(storeMetricType);
    if (tmpMap.get(key) == null) {
      tmpMap.put(key, new MutableDouble(val));
    } else {
      tmpMap.get(key).add(val);
    }

    if (this == ALL_SCHEMA_METRICS) {
      // also compute the max value across all Stores on this server
      final String maxKey = getStoreMetricNameMax(storeMetricType);
      MutableDouble cur = tmpMap.get(maxKey);
      if (cur == null) {
        tmpMap.put(maxKey, new MutableDouble(val));
      } else if (cur.doubleValue() < val) {
        cur.setValue(val);
      }
    } else {
      ALL_SCHEMA_METRICS.accumulateStoreMetric(tmpMap, storeMetricType, val);
    }
  }
View Full Code Here

        } else {
          wordList.put(term, 1);
        }
      }
    }
    final MutableDouble lengthNormalisationMut = new MutableDouble(0.0);
    wordList.forEachPair(new ObjectIntProcedure<String>() {
      @Override
      public boolean apply(String word, int dKJ) {
        lengthNormalisationMut.add(dKJ * dKJ);
        return true;
      }
    });
   
    final double lengthNormalisation = Math.sqrt(lengthNormalisationMut.doubleValue());
   
    // Output Length Normalized + TF Transformed Frequency per Word per Class
    // Log(1 + D_ij)/SQRT( SIGMA(k, D_kj) )
    wordList.forEachPair(new ObjectIntProcedure<String>() {
      @Override
View Full Code Here

        wordList.put(word, wordList.get(word) + 1);
      } else {
        wordList.put(word, 1);
      }
    }
    final MutableDouble result = new MutableDouble(0.0);
   
    wordList.forEachPair(new ObjectIntProcedure<String>() {
     
      @Override
      public boolean apply(String word, int frequency) {
        try {
          result.add(frequency * featureWeight(datastore, label, word));
        } catch (InvalidDatastoreException e) {
          throw new IllegalStateException(e);
        }
        return true;
      }
    });
    return result.doubleValue();
  }
View Full Code Here

        wordList.put(word, wordList.get(word) + 1);
      } else {
        wordList.put(word, 1);
      }
    }
    final MutableDouble result = new MutableDouble(0.0);
   
    wordList.forEachPair(new ObjectIntProcedure<String>() {
     
      @Override
      public boolean apply(String word, int frequency) {
        try {
          result.add(frequency * featureWeight(datastore, label, word));
        } catch (InvalidDatastoreException e) {
          throw new IllegalStateException(e);
        }
        return true;
      }
    });
    return result.doubleValue();
  }
View Full Code Here

   */
  public void accumulateStoreMetric(final Map<String, MutableDouble> tmpMap,
      StoreMetricType storeMetricType, double val) {
    final String key = getStoreMetricName(storeMetricType);
    if (tmpMap.get(key) == null) {
      tmpMap.put(key, new MutableDouble(val));
    } else {
      tmpMap.get(key).add(val);
    }

    if (this == ALL_SCHEMA_METRICS) {
      // also compute the max value across all Stores on this server
      final String maxKey = getStoreMetricNameMax(storeMetricType);
      MutableDouble cur = tmpMap.get(maxKey);
      if (cur == null) {
        tmpMap.put(maxKey, new MutableDouble(val));
      } else if (cur.doubleValue() < val) {
        cur.setValue(val);
      }
    } else {
      ALL_SCHEMA_METRICS.accumulateStoreMetric(tmpMap, storeMetricType, val);
    }
  }
View Full Code Here

   */
  public void accumulateStoreMetric(final Map<String, MutableDouble> tmpMap,
      StoreMetricType storeMetricType, double val) {
    final String key = getStoreMetricName(storeMetricType);
    if (tmpMap.get(key) == null) {
      tmpMap.put(key, new MutableDouble(val));
    } else {
      tmpMap.get(key).add(val);
    }

    if (this == ALL_SCHEMA_METRICS) {
      // also compute the max value across all Stores on this server
      final String maxKey = getStoreMetricNameMax(storeMetricType);
      MutableDouble cur = tmpMap.get(maxKey);
      if (cur == null) {
        tmpMap.put(maxKey, new MutableDouble(val));
      } else if (cur.doubleValue() < val) {
        cur.setValue(val);
      }
    } else {
      ALL_SCHEMA_METRICS.accumulateStoreMetric(tmpMap, storeMetricType, val);
    }
  }
View Full Code Here

   */
  public void accumulateStoreMetric(final Map<String, MutableDouble> tmpMap,
      StoreMetricType storeMetricType, double val) {
    final String key = getStoreMetricName(storeMetricType);
    if (tmpMap.get(key) == null) {
      tmpMap.put(key, new MutableDouble(val));
    } else {
      tmpMap.get(key).add(val);
    }

    if (this == ALL_SCHEMA_METRICS) {
      // also compute the max value across all Stores on this server
      final String maxKey = getStoreMetricNameMax(storeMetricType);
      MutableDouble cur = tmpMap.get(maxKey);
      if (cur == null) {
        tmpMap.put(maxKey, new MutableDouble(val));
      } else if (cur.doubleValue() < val) {
        cur.setValue(val);
      }
    } else {
      ALL_SCHEMA_METRICS.accumulateStoreMetric(tmpMap, storeMetricType, val);
    }
  }
View Full Code Here

    jdbcTemplate = new JdbcTemplate(dataSource);
  }

  public List<TagDTO> getTags(int tagcount) {
    String sql = "select value,counter from tags_values where counter>=10 order by counter desc limit ?";
    final MutableDouble maxc = new MutableDouble(1);
    final MutableDouble minc = new MutableDouble(-1);
    List<TagDTO> result = jdbcTemplate.query(sql, new RowMapper<TagDTO>() {
      @Override
      public TagDTO mapRow(ResultSet rs, int rowNum) throws SQLException {
        TagDTO result = new TagDTO();
        result.setValue(rs.getString("value"));
        double counter = Math.log(rs.getInt("counter"));
        result.setCounter(counter);

        if (maxc.doubleValue() < counter){
          maxc.setValue(counter);
        }

        if (minc.doubleValue() < 0 || counter < minc.doubleValue()){
          minc.setValue(counter);
        }

        return result;
      }
    }, tagcount);

    if (minc.doubleValue() < 0){
      minc.setValue(0);
    }

    CollectionUtils.forAllDo(result, new Closure() {
      @Override
      public void execute(Object o) {
        TagDTO tag = (TagDTO) o;
        tag.setWeight((int) Math.round(10*(tag.getCounter() - minc.doubleValue())
          / (maxc.doubleValue() - minc.doubleValue())));
      }
    });

    Collections.sort(result);

View Full Code Here

TOP

Related Classes of org.apache.commons.lang.mutable.MutableDouble

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.