Skip to content

Commit

Permalink
deprecated Double and Integer constructors to valueOf
Browse files Browse the repository at this point in the history
  • Loading branch information
mimno committed Jun 28, 2023
1 parent 39d1f92 commit 86ceaaf
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/cc/mallet/classify/MostFrequentClassifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void addTargetLabel(Label label) {
String labelEntry = (String) label.getEntry();

if(! this.labels.containsKey(labelEntry) ) {
this.sortedLabelMap.put(labelEntry, new Integer(1));
this.sortedLabelMap.put(labelEntry, Integer.valueOf(1));
this.labels.put(labelEntry, label);
}
else {
Expand Down
18 changes: 9 additions & 9 deletions src/cc/mallet/classify/evaluate/Graph.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ public void setBounds(int x, int y, int width, int height)
yLabelWidth = fm.stringWidth(yLabel);
xLabelHeight = fm.getHeight();

labelWidth = Math.max(fm.stringWidth(new Integer(min).toString()),
fm.stringWidth(new Integer(max).toString())) + 2;
labelWidth = Math.max(fm.stringWidth(Integer.valueOf(min).toString()),
fm.stringWidth(Integer.valueOf(max).toString())) + 2;
top = padding + titleHeight;
bottom = getSize().height - padding - xLabelHeight - fm.getHeight();
left = padding + yLabelWidth;
Expand All @@ -122,15 +122,15 @@ public void paint(Graphics g)
g.drawString(yLabel, 0, getSize().height/2);
g.drawString(xLabel, (getSize().width - fm.stringWidth(xLabel))/2 ,bottom + fm.getHeight());
// draw the max and min values
g.drawString(new Integer(min).toString(),
left - padding - fm.stringWidth(new Integer(min).toString()),
g.drawString(Integer.valueOf(min).toString(),
left - padding - fm.stringWidth(Integer.valueOf(min).toString()),
bottom);
g.drawString(new Integer(max).toString(),
left - padding - fm.stringWidth(new Integer(max).toString()),
g.drawString(Integer.valueOf(max).toString(),
left - padding - fm.stringWidth(Integer.valueOf(max).toString()),
top + titleHeight);
g.drawString(new Integer(xmin).toString(), left, bottom + fm.getHeight());
g.drawString(new Integer(xmax).toString(),
right - fm.stringWidth(new Integer(xmax).toString()),
g.drawString(Integer.valueOf(xmin).toString(), left, bottom + fm.getHeight());
g.drawString(Integer.valueOf(xmax).toString(),
right - fm.stringWidth(Integer.valueOf(xmax).toString()),
bottom + fm.getHeight());
// draw the vertical and horizontal lines
g.drawLine(left, top, left, bottom);
Expand Down
4 changes: 2 additions & 2 deletions src/cc/mallet/classify/tui/Vectors2Vectors.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ else if (firstInstance.getData() instanceof FeatureVector) {
ArrayList seq = new ArrayList();
for (int loc = 0; loc < fv.numLocations(); loc++)
for (int count = 0; count < fv.valueAtLocation(loc); count++)
seq.add (new Integer(fv.indexAtLocation(loc)));
seq.add (Integer.valueOf(fv.indexAtLocation(loc)));
Collections.shuffle(seq);
int[] indices = new int[seq.size()];
for (int i = 0; i < indices.length; i++)
Expand Down Expand Up @@ -303,7 +303,7 @@ else if (vectorToSequence.value) {
ArrayList seq = new ArrayList();
for (int loc = 0; loc < fv.numLocations(); loc++)
for (int count = 0; count < fv.valueAtLocation(loc); count++)
seq.add (new Integer(fv.indexAtLocation(loc)));
seq.add (Integer.valueOf(fv.indexAtLocation(loc)));
Collections.shuffle(seq);
int[] indices = new int[seq.size()];
for (int i = 0; i < indices.length; i++)
Expand Down
2 changes: 1 addition & 1 deletion src/cc/mallet/cluster/evaluate/MUCEvaluator.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public double[] getEvaluationScores(Clustering truth, Clustering predicted) {
int[] si = truth.getIndicesWithLabel(i);
HashSet<Integer> pOfsi = new HashSet<Integer>();
for (int j = 0; j < si.length; j++)
pOfsi.add(new Integer(predicted.getLabel(si[j])));
pOfsi.add(Integer.valueOf(predicted.getLabel(si[j])));
numerator += si.length - pOfsi.size();
denominator += si.length - 1;
}
Expand Down
4 changes: 2 additions & 2 deletions src/cc/mallet/cluster/iterator/ClusterSampleIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected int[] sampleFromArray (int[] a, Randoms random, int minSize) {
int size = Math.max(random.nextInt(a.length) + 1, minSize);
ArrayList toInclude = new ArrayList();
for (int i = 0; i < a.length; i++)
toInclude.add(new Integer(i));
toInclude.add(Integer.valueOf(i));
while (toInclude.size() > size && (size != a.length))
toInclude.remove(random.nextInt(toInclude.size()));

Expand All @@ -101,7 +101,7 @@ protected int[][] sampleSplitFromArray (int[] a, Randoms random, int minSize) {
int size = Math.max(random.nextInt(a.length) + 1, minSize);
ArrayList toInclude = new ArrayList();
for (int i = 0; i < a.length; i++)
toInclude.add(new Integer(i));
toInclude.add(Integer.valueOf(i));
while (toInclude.size() > size && (size != a.length))
toInclude.remove(random.nextInt(toInclude.size()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,20 @@ public double evaluate (Neighbor neighbor) {
for (int j = 0; j < cluster2.length; j++) {
AgglomerativeNeighbor pwneighbor =
new AgglomerativeNeighbor(original, original, cluster1[i], cluster2[j]);
scores.add(new Double(getScore(pwneighbor)));
scores.add(Double.valueOf(getScore(pwneighbor)));
}
if (mergeFirst) { // Also add w/in cluster scores.
for (int i = 0; i < cluster1.length; i++)
for (int j = i + 1; j < cluster1.length; j++) {
AgglomerativeNeighbor pwneighbor =
new AgglomerativeNeighbor(original, original, cluster1[i], cluster1[j]);
scores.add(new Double(getScore(pwneighbor)));
scores.add(Double.valueOf(getScore(pwneighbor)));
}
for (int i = 0; i < cluster2.length; i++)
for (int j = i + 1; j < cluster2.length; j++) {
AgglomerativeNeighbor pwneighbor =
new AgglomerativeNeighbor(original, original, cluster2[i], cluster2[j]);
scores.add(new Double(getScore(pwneighbor)));
scores.add(Double.valueOf(getScore(pwneighbor)));
}
}

Expand All @@ -112,7 +112,7 @@ public double evaluate (Neighbor neighbor) {
// AgglomerativeNeighbor pwneighbor =
// new AgglomerativeNeighbor(original, original,
// mergedIndices[i], mergedIndices[j]);
// scores.add(new Double(getScore(pwneighbor)));
// scores.add(Double.valueOf(getScore(pwneighbor)));
// }
// }
// }
Expand Down
6 changes: 3 additions & 3 deletions src/cc/mallet/cluster/tui/Clusterings2Clusterings.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static void main (String[] args) {
int label = clustering.getLabel(j);
Instance instance = oldInstances.get(j);
if (clustering.size(label) >= minClusterSize.value)
newInstances.add(noop.pipe(new Instance(instance.getData(), lalph.lookupLabel(new Integer(label)), instance.getName(), instance.getSource())));
newInstances.add(noop.pipe(new Instance(instance.getData(), lalph.lookupLabel(Integer.valueOf(label)), instance.getName(), instance.getSource())));
}
clusterings.set(i, createSmallerClustering(newInstances));
}
Expand Down Expand Up @@ -97,7 +97,7 @@ public static void main (String[] args) {
InstanceList instances = clustering.getCluster(cluster);
for (int i = 0; i < instances.size(); i++) {
Instance inst = instances.get(i);
trainingInstances.add(new Instance(inst.getData(), lalph.lookupLabel(new Integer(cluster)), inst.getName(), inst.getSource()));
trainingInstances.add(new Instance(inst.getData(), lalph.lookupLabel(Integer.valueOf(cluster)), inst.getName(), inst.getSource()));
}
}
}
Expand All @@ -110,7 +110,7 @@ public static void main (String[] args) {
InstanceList instances = clustering.getCluster(i);
for (int j = 0; j < instances.size(); j++) {
Instance inst = instances.get(j);
testingInstances.add(new Instance(inst.getData(), lalph.lookupLabel(new Integer(i)), inst.getName(), inst.getSource()));
testingInstances.add(new Instance(inst.getData(), lalph.lookupLabel(Integer.valueOf(i)), inst.getName(), inst.getSource()));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cc/mallet/cluster/tui/Text2Clusterings.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static void main (String[] args) throws IOException {
File record = records.get(k);
labels.add(label);
instances.add(new Instance(new Record(fieldAlph, valueAlph, parseFile(record)),
new Integer(label), record.toString(),
Integer.valueOf(label), record.toString(),
record.toString()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ protected Span createSpan(Tokenization input, int startTokenIdx,
int endTokenIdx) {
StringSpan span = (StringSpan) input
.subspan(startTokenIdx, endTokenIdx);
span.setProperty("StartTokenIdx", new Integer(startTokenIdx));
span.setProperty("EndTokenIdx", new Integer(endTokenIdx-1));
span.setProperty("StartTokenIdx", Integer.valueOf(startTokenIdx));
span.setProperty("EndTokenIdx", Integer.valueOf(endTokenIdx-1));
return span;
}

Expand Down
2 changes: 1 addition & 1 deletion src/cc/mallet/fst/HMM.java
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ public TransitionIterator(State source, FeatureSequence inputSeq,
this.source = source;
this.hmm = hmm;
this.inputSequence = inputSeq;
this.inputFeature = new Integer(inputSequence
this.inputFeature = Integer.valueOf(inputSequence
.getIndexAtPosition(inputPosition));
this.inputPos = inputPosition;
this.weights = new double[source.destinations.length];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public GammaAverageConfidenceEstimator (Transducer model) {
string2stateIndex = new HashMap();
// store state indices
for (int i=0; i < model.numStates(); i++) {
string2stateIndex.put (model.getState(i).getName(), new Integer (i));
string2stateIndex.put (model.getState(i).getName(), Integer.valueOf (i));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public GammaProductConfidenceEstimator (Transducer model) {
string2stateIndex = new HashMap();
// store state indices
for (int i=0; i < model.numStates(); i++) {
string2stateIndex.put (model.getState(i).getName(), new Integer (i));
string2stateIndex.put (model.getState(i).getName(), Integer.valueOf (i));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ private double avgVoteEntropy (Sequence[] predictions) {
String label = predictions[j].get(i).toString();
Integer count = (Integer)label2Count.get(label);
if (count == null)
count = new Integer(0);
label2Count.put(label, new Integer(count.intValue() + 1));
count = Integer.valueOf(0);
label2Count.put(label, Integer.valueOf(count.intValue() + 1));
}
sum += voteEntropy(label2Count);
}
Expand Down
4 changes: 2 additions & 2 deletions src/cc/mallet/optimize/LimitedMemoryBFGS.java
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,10 @@ private void push(LinkedList l, double toadd) {
assert(l.size() <= m);
if (l.size() == m) { //pop old double and add new
l.removeFirst();
l.addLast(new Double(toadd));
l.addLast(Double.valueOf(toadd));
}
else {
l.addLast(new Double(toadd));
l.addLast(Double.valueOf(toadd));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/cc/mallet/pipe/Array2FeatureVector.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public Instance pipe( Instance carrier )

if ( dataLength > dataAlphabet.size() )
for (int k=dataAlphabet.size() ; k<dataLength ; k++ )
dataAlphabet.lookupIndex( new Integer(k) , true ); // 'add'
dataAlphabet.lookupIndex( Integer.valueOf(k) , true ); // 'add'

FeatureVector fv = new FeatureVector( dataAlphabet,
(double[])carrier.getData() );
Expand Down
2 changes: 1 addition & 1 deletion src/cc/mallet/pipe/Target2Double.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public Instance pipe (Instance carrier) {
if (! (carrier.getTarget() instanceof String)) {
throw new IllegalArgumentException ("Target must be a string for conversion to Double");
}
carrier.setTarget( new Double((String) carrier.getTarget()) );
carrier.setTarget( Double.valueOf((String) carrier.getTarget()) );
}
return carrier;
}
Expand Down
2 changes: 1 addition & 1 deletion src/cc/mallet/pipe/Target2Integer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public Instance pipe (Instance carrier) {
if (! (carrier.getTarget() instanceof String)) {
throw new IllegalArgumentException ("Target must be a String for conversion to Integer");
}
carrier.setTarget( new Integer((String) carrier.getTarget()) );
carrier.setTarget( Integer.valueOf((String) carrier.getTarget()) );
}
return carrier;
}
Expand Down
12 changes: 6 additions & 6 deletions src/cc/mallet/types/NormalizedDotProductMetric.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ public double distance (SparseVector a, SparseVector b) {

public double distance( SparseVector a, int hashCodeA,
SparseVector b, int hashCodeB) {
Double cachedA = (Double) hash.get (new Integer (hashCodeA));
Double cachedB = (Double) hash.get (new Integer (hashCodeB));
Double cachedA = (Double) hash.get (Integer.valueOf (hashCodeA));
Double cachedB = (Double) hash.get (Integer.valueOf (hashCodeB));
if (a == null || b == null)
return 1.0;
if (cachedA == null) {
cachedA = new Double (a.dotProduct (a));
hash.put (new Integer (hashCodeA), cachedA);
cachedA = Double.valueOf (a.dotProduct (a));
hash.put (Integer.valueOf (hashCodeA), cachedA);
}
if (cachedB == null) {
cachedB = new Double (b.dotProduct (b));
hash.put (new Integer (hashCodeB), cachedB);
cachedB = Double.valueOf (b.dotProduct (b));
hash.put (Integer.valueOf (hashCodeB), cachedB);
}
double ab = a.dotProduct (b);

Expand Down
6 changes: 3 additions & 3 deletions src/cc/mallet/util/PropertyList.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Object lookupObject (String key)
if (this instanceof ObjectProperty)
return ((ObjectProperty)this).value;
else if (this instanceof NumericProperty)
return new Double(((NumericProperty)this).value);
return Double.valueOf(((NumericProperty)this).value);
else
throw new IllegalStateException ("Unrecognitized PropertyList entry.");
} else if (this.next == null) {
Expand Down Expand Up @@ -134,9 +134,9 @@ public static PropertyList sumDuplicateKeyValues (PropertyList pl, boolean ignor
double val = iter.getNumericValue();
Double storedValue = (Double)key2value.get (key);
if (storedValue == null)
key2value.put (key, new Double (val));
key2value.put (key, Double.valueOf (val));
else // sum stored value with current value
key2value.put (key, new Double (storedValue.doubleValue() + val));
key2value.put (key, Double.valueOf (storedValue.doubleValue() + val));
}
@Var
PropertyList ret = null;
Expand Down

0 comments on commit 86ceaaf

Please sign in to comment.