本文整理汇总了Java中edu.stanford.nlp.util.MutableDouble类的典型用法代码示例。如果您正苦于以下问题:Java MutableDouble类的具体用法?Java MutableDouble怎么用?Java MutableDouble使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MutableDouble类属于edu.stanford.nlp.util包,在下文中一共展示了MutableDouble类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: iterate
import edu.stanford.nlp.util.MutableDouble; //导入依赖的package包/类
/**
* Iteration for lambda[index].
* Returns true if this lambda hasn't converged. A lambda is deemed
* converged if the change found for it is smaller then the parameter eps.
*/
boolean iterate(int index, double err, MutableDouble ret) {
double deltaL = 0.0;
deltaL = newton(deltaL, index, err);
//System.out.println("delta is "+deltaL+" feature "+index+" expectation "+ftildeArr[index]);
if (Math.abs(deltaL + lambda[index]) > 200) {
if ((deltaL + lambda[index]) > 200) {
deltaL = 200 - lambda[index];
} else {
deltaL = -lambda[index] - 200;
}
System.err.println("set delta to smth " + deltaL);
}
lambda[index] = lambda[index] + deltaL;
if (Double.isNaN(deltaL)) {
System.err.println(" NaN " + index + ' ' + deltaL);
}
ret.set(deltaL);
return (Math.abs(deltaL) >= eps);
}
示例2: iterate
import edu.stanford.nlp.util.MutableDouble; //导入依赖的package包/类
/**
* Iteration for lambda[index].
* Returns true if this lambda hasn't converged. A lambda is deemed
* converged if the change found for it is smaller then the parameter eps.
*/
boolean iterate(int index, double err, MutableDouble ret) {
double deltaL = 0.0;
deltaL = newton(deltaL, index, err);
//System.err.println("delta is "+deltaL+" feature "+index+" expectation "+ftildeArr[index]);
if (Math.abs(deltaL + lambda[index]) > 200) {
if ((deltaL + lambda[index]) > 200) {
deltaL = 200 - lambda[index];
} else {
deltaL = -lambda[index] - 200;
}
System.err.println("set delta to smth " + deltaL);
}
lambda[index] = lambda[index] + deltaL;
if (Double.isNaN(deltaL)) {
System.err.println(" NaN " + index + ' ' + deltaL);
}
ret.set(deltaL);
return (Math.abs(deltaL) >= eps);
}
示例3: remove
import edu.stanford.nlp.util.MutableDouble; //导入依赖的package包/类
/** {@inheritDoc} */
public double remove(E key) {
MutableDouble d = mutableRemove(key); // this also updates totalCount
if(d != null) {
return d.doubleValue();
}
return Double.NaN;
}
示例4: values
import edu.stanford.nlp.util.MutableDouble; //导入依赖的package包/类
/** {@inheritDoc} */
public Collection<Double> values() {
return new AbstractCollection<Double>() {
@Override
public Iterator<Double> iterator() {
return new Iterator<Double>() {
Iterator<MutableDouble> inner = map.values().iterator();
public boolean hasNext() {
return inner.hasNext();
}
public Double next() {
// copy so as to give safety to mutable internal representation
return Double.valueOf(inner.next().doubleValue());
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
@Override
public int size() {
return map.size();
}
@Override
public boolean contains(Object v) {
return v instanceof Double && map.values().contains(new MutableDouble((Double) v));
}
};
}
示例5: mutableRemove
import edu.stanford.nlp.util.MutableDouble; //导入依赖的package包/类
/** This is used internally to the class for getting back a
* MutableDouble in a remove operation. Not for public use.
*
* @param key The key to remove
* @return Its value as a MutableDouble
*/
private MutableDouble mutableRemove(E key) {
MutableDouble md = map.remove(key);
if (md != null) {
totalCount -= md.doubleValue();
}
return md;
}
示例6: TwoDimensionalCounter
import edu.stanford.nlp.util.MutableDouble; //导入依赖的package包/类
public TwoDimensionalCounter(MapFactory<K1, ClassicCounter<K2>> outerFactory,
MapFactory<K2, MutableDouble> innerFactory) {
innerMF = innerFactory;
outerMF = outerFactory;
map = outerFactory.newMap();
total = 0.0;
}
示例7: remove
import edu.stanford.nlp.util.MutableDouble; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public double remove(E key) {
MutableDouble d = mutableRemove(key); // this also updates totalCount
if(d != null) {
return d.doubleValue();
}
return defaultValue;
}
示例8: values
import edu.stanford.nlp.util.MutableDouble; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public Collection<Double> values() {
return new AbstractCollection<Double>() {
@Override
public Iterator<Double> iterator() {
return new Iterator<Double>() {
Iterator<MutableDouble> inner = map.values().iterator();
@Override
public boolean hasNext() {
return inner.hasNext();
}
@Override
public Double next() {
// copy so as to give safety to mutable internal representation
return Double.valueOf(inner.next().doubleValue());
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
@Override
public int size() {
return map.size();
}
@Override
public boolean contains(Object v) {
return v instanceof Double && map.values().contains(new MutableDouble((Double) v));
}
};
}
示例9: improvedIterative
import edu.stanford.nlp.util.MutableDouble; //导入依赖的package包/类
/**
* Iterate until convergence. I usually use the other method that
* does a fixed number of iterations.
*/
public void improvedIterative() {
boolean flag;
int iterations = 0;
int numNConverged = p.fSize;
do {
if (VERBOSE) {
System.err.println(iterations);
}
flag = false;
iterations++;
for (int i = 0; i < lambda.length; i++) {
if (lambda_converged[i]) {
continue;
}
MutableDouble deltaI = new MutableDouble();
boolean fl = iterate(i, eps, deltaI);
if (fl) {
flag = true;
updateConds(i, deltaI.doubleValue());
// checkCorrectness();
} else {
//lambda_converged[i]=true;
numNConverged--;
}
}
} while ((flag) && (iterations < 1000));
}
示例10: iterate
import edu.stanford.nlp.util.MutableDouble; //导入依赖的package包/类
/**
* Iteration for lambda[index].
*
* @return true if this lambda hasn't converged.
*/
@SuppressWarnings({"UnusedDeclaration"})
boolean iterate(int index, double err, MutableDouble ret) {
double deltaL = 0.0;
deltaL = newton(deltaL, index, err);
lambda[index] = lambda[index] + deltaL;
if (!(deltaL == deltaL)) {
System.err.println(" NaN " + index + ' ' + deltaL);
}
ret.set(deltaL);
return (Math.abs(deltaL) >= eps);
}
示例11: improvedIterative
import edu.stanford.nlp.util.MutableDouble; //导入依赖的package包/类
/**
* Iterate until convergence. I usually use the other method that
* does a fixed number of iterations.
*/
public void improvedIterative() {
boolean flag;
int iterations = 0;
lambda_converged = new boolean[p.fSize];
int numNConverged = p.fSize;
do {
if (VERBOSE) {
System.err.println(iterations);
}
flag = false;
iterations++;
for (int i = 0; i < lambda.length; i++) {
if (lambda_converged[i]) {
continue;
}
MutableDouble deltaI = new MutableDouble();
boolean fl = iterate(i, eps, deltaI);
if (fl) {
flag = true;
updateConds(i, deltaI.doubleValue());
// checkCorrectness();
} else {
//lambda_converged[i]=true;
numNConverged--;
}
}
} while ((flag) && (iterations < 1000));
}
示例12: getInnerMapFactory
import edu.stanford.nlp.util.MutableDouble; //导入依赖的package包/类
public MapFactory<K2,MutableDouble> getInnerMapFactory() {
return innerMF;
}
示例13: TwoDimensionalCounter
import edu.stanford.nlp.util.MutableDouble; //导入依赖的package包/类
public TwoDimensionalCounter() {
this(MapFactory.<K1,ClassicCounter<K2>>hashMapFactory(), MapFactory.<K2,MutableDouble>hashMapFactory());
}
示例14: ClassicCounter
import edu.stanford.nlp.util.MutableDouble; //导入依赖的package包/类
/**
* Constructs a new (empty) Counter backed by a HashMap.
*/
public ClassicCounter() {
this(MapFactory.<E,MutableDouble>hashMapFactory());
}
示例15: ClassicCounterFactory
import edu.stanford.nlp.util.MutableDouble; //导入依赖的package包/类
private ClassicCounterFactory(MapFactory<E,MutableDouble> mf) {
this.mf = mf;
}