You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@joshua.apache.org by mj...@apache.org on 2016/08/22 21:47:42 UTC
[16/27] incubator-joshua git commit: moved comparator into Candidate
moved comparator into Candidate
Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/36cde50b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/36cde50b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/36cde50b
Branch: refs/heads/master
Commit: 36cde50ba37df9c9b2ead6b063ac5935e3dd253d
Parents: 16d5647
Author: Matt Post <po...@cs.jhu.edu>
Authored: Sat Aug 20 08:30:42 2016 -0500
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Sat Aug 20 08:30:42 2016 -0500
----------------------------------------------------------------------
.../apache/joshua/decoder/phrase/Candidate.java | 5 ++++
.../decoder/phrase/CandidateComparator.java | 28 --------------------
.../org/apache/joshua/decoder/phrase/Stack.java | 2 +-
3 files changed, 6 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/36cde50b/src/main/java/org/apache/joshua/decoder/phrase/Candidate.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/phrase/Candidate.java b/src/main/java/org/apache/joshua/decoder/phrase/Candidate.java
index 9c7b3d1..1342ea5 100644
--- a/src/main/java/org/apache/joshua/decoder/phrase/Candidate.java
+++ b/src/main/java/org/apache/joshua/decoder/phrase/Candidate.java
@@ -320,4 +320,9 @@ public class Candidate {
public int getPhraseEnd() {
return phrases.j;
}
+
+ @Override
+ public int compareTo(Candidate other) {
+ return Float.compare(other.score(), score());
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/36cde50b/src/main/java/org/apache/joshua/decoder/phrase/CandidateComparator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/phrase/CandidateComparator.java b/src/main/java/org/apache/joshua/decoder/phrase/CandidateComparator.java
deleted file mode 100644
index 322f47a..0000000
--- a/src/main/java/org/apache/joshua/decoder/phrase/CandidateComparator.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.joshua.decoder.phrase;
-
-import java.util.Comparator;
-
-public class CandidateComparator implements Comparator<Candidate> {
- @Override
- public int compare(Candidate one, Candidate another) {
- return Float.compare(another.score(), one.score());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/36cde50b/src/main/java/org/apache/joshua/decoder/phrase/Stack.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/phrase/Stack.java b/src/main/java/org/apache/joshua/decoder/phrase/Stack.java
index 3b8a976..67f62b6 100644
--- a/src/main/java/org/apache/joshua/decoder/phrase/Stack.java
+++ b/src/main/java/org/apache/joshua/decoder/phrase/Stack.java
@@ -65,7 +65,7 @@ public class Stack extends ArrayList<Hypothesis> {
this.sentence = sentence;
this.config = config;
- this.candidates = new PriorityQueue<Candidate>(1, new CandidateComparator());
+ this.candidates = new PriorityQueue<Candidate>(1);
this.coverages = new HashMap<Coverage, ArrayList<Hypothesis>>();
this.visitedStates = new HashSet<Candidate>();
this.deduper = new HashMap<Hypothesis,Hypothesis>();