You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@joshua.apache.org by le...@apache.org on 2016/05/18 05:31:48 UTC
[1/3] incubator-joshua git commit: JOSHUA-252 Make it possible to use
Maven to build Joshua
Repository: incubator-joshua
Updated Branches:
refs/heads/JOSHUA-252 ae47ca151 -> 1fc0590e9
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/segment_file/ConstraintRule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/segment_file/ConstraintRule.java b/src/main/java/org/apache/joshua/decoder/segment_file/ConstraintRule.java
index ecb274b..7f8a765 100644
--- a/src/main/java/org/apache/joshua/decoder/segment_file/ConstraintRule.java
+++ b/src/main/java/org/apache/joshua/decoder/segment_file/ConstraintRule.java
@@ -26,33 +26,33 @@ import javax.swing.text.Segment;
* <p>
* The {@link Segment}, {@link ConstraintSpan}, and {@link ConstraintRule} interfaces are for
* defining an interchange format between a SegmentFileParser and the Chart class. These interfaces
- * <emph>should not</emph> be used internally by the Chart. The objects returned by a
+ * <b>should not</b> be used internally by the Chart. The objects returned by a
* SegmentFileParser will not be optimal for use during decoding. The Chart should convert each of
* these objects into its own internal representation during construction. That is the contract
* described by these interfaces.
*
- * @see Type
+ * @see org.apache.joshua.decoder.segment_file.ConstraintRule.Type
*
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate: 2009-03-26 15:06:57 -0400 (Thu, 26 Mar 2009) $
*/
public interface ConstraintRule {
/**
- * There are three types of ConstraintRule. The RULE type returns non-null values for all methods.
+ * <p>There are three types of ConstraintRule. The RULE type returns non-null values for all methods.
* The LHS type provides a (non-null) value for the lhs method, but returns null for everything
* else. And the RHS type provides a (non-null) value for nativeRhs and foreignRhs but returns
- * null for the lhs and features.
+ * null for the lhs and features.</p>
* <p>
* The interpretation of a RULE is that it adds a new rule to the grammar which only applies to
* the associated span. If the associated span is hard, then the set of rules for that span will
- * override the regular grammar.
+ * override the regular grammar.</p>
* <p>
* The intepretation of a LHS is that it provides a hard constraint that the associated span be
- * treated as the nonterminal for that span, thus filtering the regular grammar.
+ * treated as the nonterminal for that span, thus filtering the regular grammar.</p>
* <p>
* The interpretation of a RHS is that it provides a hard constraint to filter the regular grammar
- * such that only rules generating the desired translation can be used.
+ * such that only rules generating the desired translation can be used.</p>
*/
public enum Type {
RULE, LHS, RHS
@@ -87,7 +87,7 @@ public interface ConstraintRule {
/**
* Return the grammar feature values for the RULE. The length of this array must be the same as
* for the regular grammar. We cannot enforce this requirement, but the
- * {@link joshua.decoder.chart_parser.Chart} must throw an error if there is a mismatch.
+ * {@link org.apache.joshua.decoder.chart_parser.Chart} must throw an error if there is a mismatch.
*/
float[] features();
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/segment_file/ConstraintSpan.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/segment_file/ConstraintSpan.java b/src/main/java/org/apache/joshua/decoder/segment_file/ConstraintSpan.java
index 9d758f0..7ae2ec3 100644
--- a/src/main/java/org/apache/joshua/decoder/segment_file/ConstraintSpan.java
+++ b/src/main/java/org/apache/joshua/decoder/segment_file/ConstraintSpan.java
@@ -38,12 +38,12 @@ import javax.swing.text.Segment;
* <p>
* The {@link Segment}, {@link ConstraintSpan}, and {@link ConstraintRule} interfaces are for
* defining an interchange format between a SegmentFileParser and the Chart class. These interfaces
- * <emph>should not</emph> be used internally by the Chart. The objects returned by a
+ * <b>should not</b> be used internally by the Chart. The objects returned by a
* SegmentFileParser will not be optimal for use during decoding. The Chart should convert each of
* these objects into its own internal representation during construction. That is the contract
* described by these interfaces.
*
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
*/
public interface ConstraintSpan {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/segment_file/Sentence.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/segment_file/Sentence.java b/src/main/java/org/apache/joshua/decoder/segment_file/Sentence.java
index 0266db1..e094fec 100644
--- a/src/main/java/org/apache/joshua/decoder/segment_file/Sentence.java
+++ b/src/main/java/org/apache/joshua/decoder/segment_file/Sentence.java
@@ -43,9 +43,11 @@ import org.apache.joshua.util.Regex;
* This class represents lattice input. The lattice is contained on a single line and is represented
* in PLF (Python Lattice Format), e.g.,
*
+ * <pre>
* ((('ein',0.1,1),('dieses',0.2,1),('haus',0.4,2),),(('haus',0.8,1),),)
+ * </pre>
*
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*/
public class Sentence {
@@ -134,7 +136,7 @@ public class Sentence {
/**
* Returns the length of the sentence. For lattices, the length is the shortest path through the
- * lattice. The length includes the <s> and </s> sentence markers.
+ * lattice. The length includes the <s> and </s> sentence markers.
*
* @return number of input tokens + 2 (for start and end of sentence markers)
*/
@@ -254,7 +256,7 @@ public class Sentence {
}
/**
- * If the input sentence is too long (not counting the <s> and </s> tokens), it is truncated to
+ * If the input sentence is too long (not counting the <s> and </s> tokens), it is truncated to
* the maximum length, specified with the "maxlen" parameter.
*
* Note that this code assumes the underlying representation is a sentence, and not a lattice. Its
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/segment_file/Token.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/segment_file/Token.java b/src/main/java/org/apache/joshua/decoder/segment_file/Token.java
index 04c1da4..a06568c 100644
--- a/src/main/java/org/apache/joshua/decoder/segment_file/Token.java
+++ b/src/main/java/org/apache/joshua/decoder/segment_file/Token.java
@@ -44,22 +44,27 @@ public class Token {
private JoshuaConfiguration joshuaConfiguration;
/**
- * Constructor : Creates a Token object from a raw word
+ * <p>Constructor : Creates a Token object from a raw word
* Extracts and assigns an annotation when available.
* Any word can be marked with annotations, which are arbitrary semicolon-delimited
- * key[=value] pairs (the value is optional) listed in brackets after a word, e.g.,
+ * key[=value] pairs (the value is optional) listed in brackets after a word, e.g.,</p>
+ * <pre>
+ * Je[ref=Samuel;PRO] voudrais[FUT;COND]
+ * </pre>
*
- * Je[ref=Samuel;PRO] voudrais[FUT;COND] ...
+ * <p>This will create a dictionary annotation on the word of the following form for "Je"</p>
*
- * This will create a dictionary annotation on the word of the following form for "Je"
+ * <pre>
+ * ref -> Samuel
+ * PRO -> PRO
+ * </pre>
*
- * ref -> Samuel
- * PRO -> PRO
- *
- * and the following for "voudrais":
+ * <p>and the following for "voudrais":<p>
*
- * FUT -> FUT
- * COND -> COND
+ * <pre>
+ * FUT -> FUT
+ * COND -> COND
+ * </pre>
*
* @param rawWord A word with annotation information (possibly)
*
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/lattice/Lattice.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/lattice/Lattice.java b/src/main/java/org/apache/joshua/lattice/Lattice.java
index 1adefa8..a4ab800 100644
--- a/src/main/java/org/apache/joshua/lattice/Lattice.java
+++ b/src/main/java/org/apache/joshua/lattice/Lattice.java
@@ -39,10 +39,9 @@ import org.apache.joshua.util.ChartSpan;
* A lattice representation of a directed graph.
*
* @author Lane Schwartz
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
* @since 2008-07-08
*
- * @param Label Type of label associated with an arc.
*/
public class Lattice<Value> implements Iterable<Node<Value>> {
@@ -126,9 +125,7 @@ public class Lattice<Value> implements Iterable<Node<Value>> {
* Computes the shortest distance between two nodes, which is used (perhaps among other places) in
* computing which rules can apply over which spans of the input
*
- * @param tail
- * @param head
- * @return the distance, a positive number, or -1 if there is no path between the nodes
+ * @param arc
*/
public int distance(Arc<Value> arc) {
return this.getShortestPath(arc.getTail().getNumber(), arc.getHead().getNumber());
@@ -141,7 +138,8 @@ public class Lattice<Value> implements Iterable<Node<Value>> {
/**
* Convenience method to get a lattice from a linear sequence of {@link Token} objects.
*
- * @param linearChain
+ * @param source
+ * @param config
* @return Lattice representation of the linear chain.
*/
public static Lattice<Token> createTokenLatticeFromString(String source, JoshuaConfiguration config) {
@@ -446,7 +444,7 @@ public class Lattice<Value> implements Iterable<Node<Value>> {
*
* @param i
* @param j
- * @param lattice
+ * @param newNodes
*/
public void insert(int i, int j, List<Node<Value>> newNodes) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/oracle/OracleExtractionHG.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/oracle/OracleExtractionHG.java b/src/main/java/org/apache/joshua/oracle/OracleExtractionHG.java
index 184a14a..0ed8a95 100644
--- a/src/main/java/org/apache/joshua/oracle/OracleExtractionHG.java
+++ b/src/main/java/org/apache/joshua/oracle/OracleExtractionHG.java
@@ -42,7 +42,7 @@ import org.apache.joshua.util.io.LineReader;
* maintain different states for different hyp length (3) brief penalty is calculated based on the
* avg ref length (4) using sentence-level BLEU, instead of doc-level BLEU
*
- * @author Zhifei Li, <zh...@gmail.com> (Johns Hopkins University)
+ * @author Zhifei Li, zhifei.work@gmail.com (Johns Hopkins University)
*/
public class OracleExtractionHG extends SplitHg {
static String BACKOFF_LEFT_LM_STATE_SYM = "<lzfbo>";
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/oracle/SplitHg.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/oracle/SplitHg.java b/src/main/java/org/apache/joshua/oracle/SplitHg.java
index 054e9b7..9fcdd35 100644
--- a/src/main/java/org/apache/joshua/oracle/SplitHg.java
+++ b/src/main/java/org/apache/joshua/oracle/SplitHg.java
@@ -30,7 +30,7 @@ import org.apache.joshua.decoder.hypergraph.HyperGraph;
* This class implements general ways of splitting the hypergraph based on coarse-to-fine idea input
* is a hypergraph output is another hypergraph that has changed state structures.
*
- * @author Zhifei Li, <zh...@gmail.com> (Johns Hopkins University)
+ * @author Zhifei Li, zhifei.work@gmail.com (Johns Hopkins University)
*/
public abstract class SplitHg {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/server/TcpServer.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/server/TcpServer.java b/src/main/java/org/apache/joshua/server/TcpServer.java
index 137794d..317fb47 100644
--- a/src/main/java/org/apache/joshua/server/TcpServer.java
+++ b/src/main/java/org/apache/joshua/server/TcpServer.java
@@ -41,9 +41,6 @@ public class TcpServer {
/**
* Listens on a port for new socket connections. Concurrently handles multiple socket connections.
- *
- * @param args configuration options
- * @throws IOException
*/
public void start() {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/subsample/AlignedSubsampler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/subsample/AlignedSubsampler.java b/src/main/java/org/apache/joshua/subsample/AlignedSubsampler.java
index 88a0960..e8f403c 100644
--- a/src/main/java/org/apache/joshua/subsample/AlignedSubsampler.java
+++ b/src/main/java/org/apache/joshua/subsample/AlignedSubsampler.java
@@ -32,8 +32,8 @@ import org.apache.commons.cli.Options;
* A subsampler which takes in word-alignments as well as the F and E files. To remove redundant
* code, this class uses callback techniques in order to "override" the superclass methods.
*
- * @see joshua.subsample.Subsampler
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @see org.apache.joshua.subsample.Subsampler
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate$
*/
public class AlignedSubsampler extends Subsampler {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/subsample/Alignment.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/subsample/Alignment.java b/src/main/java/org/apache/joshua/subsample/Alignment.java
index 2372bdd..6a11a5e 100644
--- a/src/main/java/org/apache/joshua/subsample/Alignment.java
+++ b/src/main/java/org/apache/joshua/subsample/Alignment.java
@@ -12,10 +12,8 @@ package org.apache.joshua.subsample;
* two-dimensional bit vector, though for our purposes we could just keep the original string around
* (which would save lots of time parsing and reconstructing the string).
*
- * @see joshua.corpus.alignment.Alignments
- *
* @author UMD (Jimmy Lin, Chris Dyer, et al.)
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate$
*/
public class Alignment {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/subsample/BiCorpus.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/subsample/BiCorpus.java b/src/main/java/org/apache/joshua/subsample/BiCorpus.java
index c2959fa..36bcab5 100644
--- a/src/main/java/org/apache/joshua/subsample/BiCorpus.java
+++ b/src/main/java/org/apache/joshua/subsample/BiCorpus.java
@@ -25,7 +25,7 @@ import org.apache.joshua.corpus.Phrase;
* <code>subsample(String, float, PhraseWriter, BiCorpusFactory)</code> method.
*
* @author UMD (Jimmy Lin, Chris Dyer, et al.)
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate$
*/
public class BiCorpus implements Iterable<PhrasePair> {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/subsample/BiCorpusFactory.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/subsample/BiCorpusFactory.java b/src/main/java/org/apache/joshua/subsample/BiCorpusFactory.java
index 226090d..3dfaffd 100644
--- a/src/main/java/org/apache/joshua/subsample/BiCorpusFactory.java
+++ b/src/main/java/org/apache/joshua/subsample/BiCorpusFactory.java
@@ -26,7 +26,7 @@ import java.io.IOException;
* {@link AlignedSubsampler} in order to "override" methods of {@link Subsampler}, minimizing code
* duplication.
*
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate$
*/
public class BiCorpusFactory {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/subsample/PhrasePair.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/subsample/PhrasePair.java b/src/main/java/org/apache/joshua/subsample/PhrasePair.java
index 125cac2..b958540 100644
--- a/src/main/java/org/apache/joshua/subsample/PhrasePair.java
+++ b/src/main/java/org/apache/joshua/subsample/PhrasePair.java
@@ -15,7 +15,7 @@ import org.apache.joshua.corpus.Phrase;
* word-alignments. This is primarily for maintaining sentence-alignment.
*
* @author UMD (Jimmy Lin, Chris Dyer, et al.)
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate$
*/
public class PhrasePair {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/subsample/PhraseReader.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/subsample/PhraseReader.java b/src/main/java/org/apache/joshua/subsample/PhraseReader.java
index f35288c..61136ba 100644
--- a/src/main/java/org/apache/joshua/subsample/PhraseReader.java
+++ b/src/main/java/org/apache/joshua/subsample/PhraseReader.java
@@ -17,7 +17,7 @@ import org.apache.joshua.corpus.BasicPhrase;
* Wrapper class to read in each line as a BasicPhrase.
*
* @author UMD (Jimmy Lin, Chris Dyer, et al.)
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate$
*/
public class PhraseReader extends BufferedReader {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/subsample/PhraseWriter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/subsample/PhraseWriter.java b/src/main/java/org/apache/joshua/subsample/PhraseWriter.java
index cda99e6..11bbf08 100644
--- a/src/main/java/org/apache/joshua/subsample/PhraseWriter.java
+++ b/src/main/java/org/apache/joshua/subsample/PhraseWriter.java
@@ -27,7 +27,7 @@ import java.io.IOException;
* of this, to have zero-overhead while not duplicating code. Alas, Java's not that cool. The
* "final" could help on JIT at least.
*
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate$
*/
final public class PhraseWriter {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/subsample/Subsampler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/subsample/Subsampler.java b/src/main/java/org/apache/joshua/subsample/Subsampler.java
index d56c529..dac8054 100644
--- a/src/main/java/org/apache/joshua/subsample/Subsampler.java
+++ b/src/main/java/org/apache/joshua/subsample/Subsampler.java
@@ -27,7 +27,7 @@ import org.apache.joshua.corpus.Phrase;
* Papineni.
*
* @author UMD (Jimmy Lin, Chris Dyer, et al.)
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate$
*/
public class Subsampler {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/subsample/SubsamplerCLI.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/subsample/SubsamplerCLI.java b/src/main/java/org/apache/joshua/subsample/SubsamplerCLI.java
index 8303617..6772057 100644
--- a/src/main/java/org/apache/joshua/subsample/SubsamplerCLI.java
+++ b/src/main/java/org/apache/joshua/subsample/SubsamplerCLI.java
@@ -28,7 +28,7 @@ import org.apache.commons.cli.ParseException;
* one-use nature of subclasses of <code>SubsampleCLI</code>, they generally should be implemented
* as anonymous local classes.
*
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate$
*/
@SuppressWarnings("static-access")
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/ui/tree_visualizer/browser/Browser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/ui/tree_visualizer/browser/Browser.java b/src/main/java/org/apache/joshua/ui/tree_visualizer/browser/Browser.java
index 10913f6..1e54920 100644
--- a/src/main/java/org/apache/joshua/ui/tree_visualizer/browser/Browser.java
+++ b/src/main/java/org/apache/joshua/ui/tree_visualizer/browser/Browser.java
@@ -74,7 +74,7 @@ public class Browser {
static final Color[] dataSetColors = { Color.red, Color.orange, Color.blue, Color.green };
/**
- * @param args the paths to the source, reference, and n-best files
+ * @param argv the paths to the source, reference, and n-best files
*/
public static void main(String[] argv) throws IOException {
String sourcePath = argv.length > 0 ? argv[0] : null;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/ui/tree_visualizer/tree/Tree.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/ui/tree_visualizer/tree/Tree.java b/src/main/java/org/apache/joshua/ui/tree_visualizer/tree/Tree.java
index 9eb586e..48f4c74 100644
--- a/src/main/java/org/apache/joshua/ui/tree_visualizer/tree/Tree.java
+++ b/src/main/java/org/apache/joshua/ui/tree_visualizer/tree/Tree.java
@@ -48,7 +48,7 @@ import java.util.Comparator;
* Using a Tree the source sentence it was aligned to, we can create
* a DerivationTree object suitable for display.
*
- * @author Jonny Weese <jo...@cs.jhu.edu>
+ * @author Jonny Weese jonny@cs.jhu.edu
*/
public class Tree {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/util/ChartSpan.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/ChartSpan.java b/src/main/java/org/apache/joshua/util/ChartSpan.java
index 42fe04d..3e9a1c9 100644
--- a/src/main/java/org/apache/joshua/util/ChartSpan.java
+++ b/src/main/java/org/apache/joshua/util/ChartSpan.java
@@ -20,13 +20,13 @@ package org.apache.joshua.util;
/**
* CKY-based decoding makes extensive use of charts, which maintain information about spans (i, j)
- * over the length-n input sentence, 0 <= i <= j <= n. These charts are used for many things; for
+ * over the length-n input sentence, 0 <= i <= j <= n. These charts are used for many things; for
* example, lattices use a chart to denote whether there is a path between nodes i and j, and what
- * their costs is, and the decoder uses charts to record the partial application of rules (
- * {@link DotChart}) and the existence of proved items ({@link PhraseChart}).
+ * their costs is, and the decoder uses charts to record the partial application of rules (DotChart})
+ * and the existence of proved items ({@link org.apache.joshua.decoder.phrase.PhraseChart}).
*
* The dummy way to implement a chart is to initialize a two-dimensional array; however, this wastes
- * a lot of space, because the constraint (i <= j) means that only half of this space can ever be
+ * a lot of space, because the constraint (i <= j) means that only half of this space can ever be
* used. This is especially a problem for lattices, where the sentence length (n) is the number of
* nodes in the lattice!
*
@@ -34,7 +34,7 @@ package org.apache.joshua.util;
* spans under a given maximum length. This class implements that in a generic way, introducing
* large savings in both space and time.
*
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*/
public class ChartSpan<Type> {
Object[] chart;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/util/ExtractTopCand.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/ExtractTopCand.java b/src/main/java/org/apache/joshua/util/ExtractTopCand.java
index de1d247..91186ce 100644
--- a/src/main/java/org/apache/joshua/util/ExtractTopCand.java
+++ b/src/main/java/org/apache/joshua/util/ExtractTopCand.java
@@ -29,9 +29,9 @@ import org.apache.joshua.util.io.LineReader;
/**
* This program extracts the 1-best output translations from the n-best output translations
- * generated by {@link joshua.decoder.Decoder}.
+ * generated by {@link org.apache.joshua.decoder.Decoder}.
*
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate: 2009-03-26 15:06:57 -0400 (Thu, 26 Mar 2009) $
*/
/*
@@ -48,7 +48,7 @@ public class ExtractTopCand {
* If the input file name is "-" then input is read from <code>System.in</code>. If the output
* file name is "-" then output is directed to <code>System.out</code>. If a file already exists
* with the output file name, it is truncated before writing. The bulk of this program is
- * implemented by {@link #extractOneBest(IndexedReader,BufferedWriter)}.
+ * implemented by {@link org.apache.joshua.util.ExtractTopCand#extractOneBest(IndexedReader, BufferedWriter, int)}.
*/
public static void main(String[] args) {
String inFile = "-";
@@ -109,7 +109,7 @@ public class ExtractTopCand {
* first occurance of the segment ID. Any information about the segment other than the translation
* (including segment ID) is not printed to the writer.
*
- * <h4>Developer Notes</h4> This implementation assumes:
+ * <b>Developer Notes</b> This implementation assumes:
* <ol>
* <li>all translations for a segment are contiguous</li>
* <li>the 1-best translation is the first one encountered.</li>
@@ -117,7 +117,7 @@ public class ExtractTopCand {
* We will need to alter the implementation if these assumptions no longer hold for the output of
* JoshuaDecoder (or any sensible n-best format passed to this method).
* <p>
- * We should switch to using an n-best {@link joshua.decoder.segment_file.SegmentFileParser} to
+ * TODO We should switch to using an n-best SegmentFileParser to
* ensure future compatibility with being able to configure the output format of the decoder. The
* MERT code needs such a SegmentFileParser anyways, so that will reduce the code duplication
* between these two classes.
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/util/FileUtility.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/FileUtility.java b/src/main/java/org/apache/joshua/util/FileUtility.java
index db6e9d9..19b26ab 100644
--- a/src/main/java/org/apache/joshua/util/FileUtility.java
+++ b/src/main/java/org/apache/joshua/util/FileUtility.java
@@ -39,8 +39,8 @@ import java.util.Scanner;
/**
* utility functions for file operations
*
- * @author Zhifei Li, <zh...@gmail.com>
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author Zhifei Li, zhifei.work@gmail.com
+ * @author wren ng thornton wren@users.sourceforge.net
* @since 28 February 2009
*/
public class FileUtility {
@@ -182,7 +182,7 @@ public class FileUtility {
}
/**
- * Returns the base directory of the file. For example, dirname('/usr/local/bin/emacs') ->
+ * Returns the base directory of the file. For example, dirname('/usr/local/bin/emacs') ->
* '/usr/local/bin'
*/
static public String dirname(String fileName) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/util/FormatUtils.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/FormatUtils.java b/src/main/java/org/apache/joshua/util/FormatUtils.java
index b7cc5e2..f4854c5 100644
--- a/src/main/java/org/apache/joshua/util/FormatUtils.java
+++ b/src/main/java/org/apache/joshua/util/FormatUtils.java
@@ -49,8 +49,8 @@ public class FormatUtils {
* Nonterminals are stored in the vocabulary in square brackets. This removes them when you
* just want the raw nonterminal word.
* Supports indexed and non-indexed nonTerminals:
- * [GOAL] -> GOAL
- * [X,1] -> [X]
+ * [GOAL] -> GOAL
+ * [X,1] -> [X]
*
* @param nt the nonterminal, e.g., "[GOAL]"
* @return the cleaned nonterminal, e.g., "GOAL"
@@ -72,7 +72,7 @@ public class FormatUtils {
}
/**
- * Removes the index from a nonTerminal: [X,1] -> [X].
+ * Removes the index from a nonTerminal: [X,1] -> [X].
*/
public static String stripNonTerminalIndex(String nt) {
return markup(cleanNonTerminal(nt));
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/util/NullIterator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/NullIterator.java b/src/main/java/org/apache/joshua/util/NullIterator.java
index 0c1c8a3..c6e4b46 100644
--- a/src/main/java/org/apache/joshua/util/NullIterator.java
+++ b/src/main/java/org/apache/joshua/util/NullIterator.java
@@ -25,7 +25,7 @@ import java.util.NoSuchElementException;
/**
* This class provides a null-object Iterator. That is, an iterator over an empty collection.
*
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate: 2009-03-26 15:06:57 -0400 (Thu, 26 Mar 2009) $
*/
public class NullIterator<E> implements Iterable<E>, Iterator<E> {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/util/Regex.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/Regex.java b/src/main/java/org/apache/joshua/util/Regex.java
index 2defe80..5c54589 100644
--- a/src/main/java/org/apache/joshua/util/Regex.java
+++ b/src/main/java/org/apache/joshua/util/Regex.java
@@ -27,7 +27,7 @@ import java.util.regex.PatternSyntaxException;
* the convenience functions on String. The convenience methods on String are deprecated except for
* one-shot patterns (which, by definition, are not in loops).
*
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate: 2009-03-28 07:40:25 -0400 (Sat, 28 Mar 2009) $
*/
public class Regex {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/util/SocketUtility.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/SocketUtility.java b/src/main/java/org/apache/joshua/util/SocketUtility.java
index 965a606..90b94bb 100644
--- a/src/main/java/org/apache/joshua/util/SocketUtility.java
+++ b/src/main/java/org/apache/joshua/util/SocketUtility.java
@@ -33,7 +33,7 @@ import java.net.UnknownHostException;
/**
*
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Zhifei Li, zhifei.work@gmail.com
* @version $LastChangedDate$
*/
public class SocketUtility {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/util/io/IndexedReader.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/io/IndexedReader.java b/src/main/java/org/apache/joshua/util/io/IndexedReader.java
index eca9d78..b477333 100644
--- a/src/main/java/org/apache/joshua/util/io/IndexedReader.java
+++ b/src/main/java/org/apache/joshua/util/io/IndexedReader.java
@@ -26,7 +26,7 @@ import java.util.NoSuchElementException;
/**
* Wraps a reader with "line" index information.
*
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate: 2009-03-26 15:06:57 -0400 (Thu, 26 Mar 2009) $
*/
public class IndexedReader<E> implements Reader<E> {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/util/io/LineReader.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/io/LineReader.java b/src/main/java/org/apache/joshua/util/io/LineReader.java
index 11813b8..659ec63 100644
--- a/src/main/java/org/apache/joshua/util/io/LineReader.java
+++ b/src/main/java/org/apache/joshua/util/io/LineReader.java
@@ -37,8 +37,8 @@ import org.apache.joshua.decoder.Decoder;
* This class provides an Iterator interface to a BufferedReader. This covers the most common
* use-cases for reading from files without ugly code to check whether we got a line or not.
*
- * @author wren ng thornton <wr...@users.sourceforge.net>
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author wren ng thornton wren@users.sourceforge.net
+ * @author Matt Post post@cs.jhu.edu
*/
public class LineReader implements Reader<String> {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/util/io/NullReader.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/io/NullReader.java b/src/main/java/org/apache/joshua/util/io/NullReader.java
index 7700f72..f833f00 100644
--- a/src/main/java/org/apache/joshua/util/io/NullReader.java
+++ b/src/main/java/org/apache/joshua/util/io/NullReader.java
@@ -28,7 +28,7 @@ import org.apache.joshua.util.NullIterator;
* have a {@link Reader}, and you don't want to check for null all the time. All operations are
* no-ops.
*
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate: 2009-03-26 15:06:57 -0400 (Thu, 26 Mar 2009) $
*/
public class NullReader<E> extends NullIterator<E> implements Reader<E> {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/util/io/ProgressInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/io/ProgressInputStream.java b/src/main/java/org/apache/joshua/util/io/ProgressInputStream.java
index 86ce844..075c0b3 100644
--- a/src/main/java/org/apache/joshua/util/io/ProgressInputStream.java
+++ b/src/main/java/org/apache/joshua/util/io/ProgressInputStream.java
@@ -26,7 +26,7 @@ import java.io.InputStream;
* Generic progress meter for reading files (compressed or not). Pass it the raw input file stream
* and it will keep track for you.
*
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*/
public class ProgressInputStream extends FilterInputStream {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/util/io/Reader.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/util/io/Reader.java b/src/main/java/org/apache/joshua/util/io/Reader.java
index fcee161..6e9cc34 100644
--- a/src/main/java/org/apache/joshua/util/io/Reader.java
+++ b/src/main/java/org/apache/joshua/util/io/Reader.java
@@ -24,7 +24,7 @@ import java.util.Iterator;
/**
* Common interface for Reader type objects.
*
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate: 2009-03-26 15:06:57 -0400 (Thu, 26 Mar 2009) $
*/
public interface Reader<E> extends Iterable<E>, Iterator<E> {
[3/3] incubator-joshua git commit: JOSHUA-252 Make it possible to use
Maven to build Joshua
Posted by le...@apache.org.
JOSHUA-252 Make it possible to use Maven to build Joshua
Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/1fc0590e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/1fc0590e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/1fc0590e
Branch: refs/heads/JOSHUA-252
Commit: 1fc0590e9f6c77c2ff0efbe6453ddd39364141ad
Parents: ae47ca1
Author: Lewis John McGibbney <le...@gmail.com>
Authored: Tue May 17 22:36:57 2016 -0700
Committer: Lewis John McGibbney <le...@gmail.com>
Committed: Tue May 17 22:36:57 2016 -0700
----------------------------------------------------------------------
.../org/apache/joshua/corpus/BasicPhrase.java | 2 +-
.../java/org/apache/joshua/corpus/Phrase.java | 3 +
.../org/apache/joshua/corpus/SymbolTable.java | 3 +-
.../org/apache/joshua/corpus/Vocabulary.java | 2 +-
.../java/org/apache/joshua/decoder/BLEU.java | 35 ++++---
.../java/org/apache/joshua/decoder/Decoder.java | 9 +-
.../apache/joshua/decoder/DecoderThread.java | 4 +-
.../joshua/decoder/JoshuaConfiguration.java | 13 ++-
.../apache/joshua/decoder/JoshuaDecoder.java | 6 +-
.../joshua/decoder/NbestMinRiskReranker.java | 7 +-
.../joshua/decoder/StructuredTranslation.java | 5 +-
.../java/org/apache/joshua/decoder/Support.java | 2 +-
.../org/apache/joshua/decoder/Translation.java | 74 ++++++-------
.../org/apache/joshua/decoder/Translations.java | 6 +-
.../joshua/decoder/chart_parser/Chart.java | 6 +-
.../decoder/chart_parser/ComputeNodeResult.java | 18 +++-
.../chart_parser/ManualConstraintsHandler.java | 13 ++-
.../joshua/decoder/chart_parser/SourcePath.java | 2 +-
.../decoder/chart_parser/StateConstraint.java | 4 +-
.../joshua/decoder/ff/ArityPhrasePenalty.java | 4 +-
.../joshua/decoder/ff/FeatureFunction.java | 103 ++++++++++---------
.../apache/joshua/decoder/ff/FeatureVector.java | 32 ++++--
.../apache/joshua/decoder/ff/OOVPenalty.java | 2 +-
.../apache/joshua/decoder/ff/PhraseModel.java | 4 +-
.../apache/joshua/decoder/ff/SourcePathFF.java | 4 +-
.../apache/joshua/decoder/ff/StatefulFF.java | 4 +-
.../apache/joshua/decoder/ff/StatelessFF.java | 4 +-
.../apache/joshua/decoder/ff/TargetBigram.java | 2 +-
.../apache/joshua/decoder/ff/WordPenalty.java | 4 +-
.../decoder/ff/fragmentlm/FragmentLMFF.java | 49 +++++----
.../joshua/decoder/ff/fragmentlm/Tree.java | 54 +++++-----
.../joshua/decoder/ff/fragmentlm/Trees.java | 3 +
.../apache/joshua/decoder/ff/lm/AbstractLM.java | 15 +--
.../ff/lm/DefaultNGramLanguageModel.java | 10 +-
.../org/apache/joshua/decoder/ff/lm/KenLM.java | 16 +--
.../joshua/decoder/ff/lm/LanguageModelFF.java | 21 ++--
.../decoder/ff/lm/NGramLanguageModel.java | 20 ++--
.../ff/lm/StateMinimizingLanguageModel.java | 12 +--
.../BloomFilterLanguageModel.java | 1 +
.../joshua/decoder/ff/lm/buildin_lm/TrieLM.java | 6 +-
.../decoder/ff/state_maintenance/DPState.java | 4 +-
.../ff/state_maintenance/KenLMState.java | 4 +-
.../ff/state_maintenance/NgramDPState.java | 4 +-
.../joshua/decoder/ff/tm/AbstractGrammar.java | 16 +--
.../joshua/decoder/ff/tm/BilingualRule.java | 8 +-
.../apache/joshua/decoder/ff/tm/Grammar.java | 25 +++--
.../joshua/decoder/ff/tm/GrammarReader.java | 6 +-
.../joshua/decoder/ff/tm/MonolingualRule.java | 8 +-
.../apache/joshua/decoder/ff/tm/PhraseRule.java | 10 +-
.../org/apache/joshua/decoder/ff/tm/Rule.java | 48 ++++++---
.../joshua/decoder/ff/tm/RuleCollection.java | 10 +-
.../decoder/ff/tm/SentenceFilteredGrammar.java | 17 +--
.../org/apache/joshua/decoder/ff/tm/Trie.java | 18 ++--
.../decoder/ff/tm/format/HieroFormatReader.java | 3 +-
.../ff/tm/format/PhraseFormatReader.java | 12 +--
.../tm/hash_based/MemoryBasedBatchGrammar.java | 10 +-
.../ff/tm/hash_based/MemoryBasedRuleBin.java | 2 +-
.../ff/tm/hash_based/MemoryBasedTrie.java | 2 +-
.../decoder/ff/tm/packed/PackedGrammar.java | 9 +-
.../ff/tm/packed/SliceAggregatingTrie.java | 25 ++---
.../decoder/hypergraph/AlignedSourceTokens.java | 10 +-
.../decoder/hypergraph/AllSpansWalker.java | 7 +-
.../hypergraph/DefaultInsideOutside.java | 2 +-
.../joshua/decoder/hypergraph/HGNode.java | 9 +-
.../joshua/decoder/hypergraph/HyperEdge.java | 4 +-
.../joshua/decoder/hypergraph/HyperGraph.java | 5 +-
.../decoder/hypergraph/HyperGraphPruning.java | 2 +-
.../decoder/hypergraph/KBestExtractor.java | 88 +++++++++-------
.../hypergraph/TrivialInsideOutside.java | 2 +-
.../decoder/hypergraph/ViterbiExtractor.java | 48 ++++++---
.../decoder/hypergraph/WalkerFunction.java | 3 +
.../hypergraph/WordAlignmentExtractor.java | 1 +
.../decoder/hypergraph/WordAlignmentState.java | 3 +
.../apache/joshua/decoder/io/DeNormalize.java | 6 +-
.../decoder/io/TranslationRequestStream.java | 6 +-
.../apache/joshua/decoder/phrase/Candidate.java | 10 +-
.../apache/joshua/decoder/phrase/Coverage.java | 15 +--
.../joshua/decoder/phrase/Hypothesis.java | 6 +-
.../org/apache/joshua/decoder/phrase/Stack.java | 5 +-
.../decoder/segment_file/ConstraintRule.java | 18 ++--
.../decoder/segment_file/ConstraintSpan.java | 4 +-
.../joshua/decoder/segment_file/Sentence.java | 8 +-
.../joshua/decoder/segment_file/Token.java | 25 +++--
.../java/org/apache/joshua/lattice/Lattice.java | 12 +--
.../joshua/oracle/OracleExtractionHG.java | 2 +-
.../java/org/apache/joshua/oracle/SplitHg.java | 2 +-
.../org/apache/joshua/server/TcpServer.java | 3 -
.../joshua/subsample/AlignedSubsampler.java | 4 +-
.../org/apache/joshua/subsample/Alignment.java | 4 +-
.../org/apache/joshua/subsample/BiCorpus.java | 2 +-
.../joshua/subsample/BiCorpusFactory.java | 2 +-
.../org/apache/joshua/subsample/PhrasePair.java | 2 +-
.../apache/joshua/subsample/PhraseReader.java | 2 +-
.../apache/joshua/subsample/PhraseWriter.java | 2 +-
.../org/apache/joshua/subsample/Subsampler.java | 2 +-
.../apache/joshua/subsample/SubsamplerCLI.java | 2 +-
.../ui/tree_visualizer/browser/Browser.java | 2 +-
.../joshua/ui/tree_visualizer/tree/Tree.java | 2 +-
.../java/org/apache/joshua/util/ChartSpan.java | 10 +-
.../org/apache/joshua/util/ExtractTopCand.java | 10 +-
.../org/apache/joshua/util/FileUtility.java | 6 +-
.../org/apache/joshua/util/FormatUtils.java | 6 +-
.../org/apache/joshua/util/NullIterator.java | 2 +-
src/main/java/org/apache/joshua/util/Regex.java | 2 +-
.../org/apache/joshua/util/SocketUtility.java | 2 +-
.../apache/joshua/util/io/IndexedReader.java | 2 +-
.../org/apache/joshua/util/io/LineReader.java | 4 +-
.../org/apache/joshua/util/io/NullReader.java | 2 +-
.../joshua/util/io/ProgressInputStream.java | 2 +-
.../java/org/apache/joshua/util/io/Reader.java | 2 +-
110 files changed, 675 insertions(+), 532 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/corpus/BasicPhrase.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/corpus/BasicPhrase.java b/src/main/java/org/apache/joshua/corpus/BasicPhrase.java
index f65f26f..f7f6be2 100644
--- a/src/main/java/org/apache/joshua/corpus/BasicPhrase.java
+++ b/src/main/java/org/apache/joshua/corpus/BasicPhrase.java
@@ -12,7 +12,7 @@ import java.util.ArrayList;
/**
* The simplest concrete implementation of Phrase.
*
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author wren ng thornton wren@users.sourceforge.net
* @version $LastChangedDate$
*/
public class BasicPhrase extends AbstractPhrase {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/corpus/Phrase.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/corpus/Phrase.java b/src/main/java/org/apache/joshua/corpus/Phrase.java
index f22c8a5..5a06a8b 100644
--- a/src/main/java/org/apache/joshua/corpus/Phrase.java
+++ b/src/main/java/org/apache/joshua/corpus/Phrase.java
@@ -93,6 +93,9 @@ public interface Phrase extends Comparable<Phrase> {
* complete Phrase List.
*
* @see ArrayList#subList(int, int)
+ * @param start start position to begin new phrase
+ * @param end end position to end new phrase
+ * @return a new {@link org.apache.joshua.corpus.Phrase} object from the indexes provided.
*/
Phrase subPhrase(int start, int end);
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/corpus/SymbolTable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/corpus/SymbolTable.java b/src/main/java/org/apache/joshua/corpus/SymbolTable.java
index d8b1694..b108477 100644
--- a/src/main/java/org/apache/joshua/corpus/SymbolTable.java
+++ b/src/main/java/org/apache/joshua/corpus/SymbolTable.java
@@ -164,8 +164,9 @@ public interface SymbolTable {
*
* @see #getUnknownWordID
* @return the unique integer identifier for wordString,
- * or the result of <code>getUnknownWordID<code>
+ * or the result of <code>getUnknownWordID</code>
* if wordString is not in the vocabulary
+ * @param wordString the word to retrieve the integer identifier
*/
int getID(String wordString);
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/corpus/Vocabulary.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/corpus/Vocabulary.java b/src/main/java/org/apache/joshua/corpus/Vocabulary.java
index bd91b31..f89a198 100644
--- a/src/main/java/org/apache/joshua/corpus/Vocabulary.java
+++ b/src/main/java/org/apache/joshua/corpus/Vocabulary.java
@@ -128,7 +128,7 @@ public class Vocabulary implements Externalizable {
* Get the id of the token if it already exists, new id is created otherwise.
*
* TODO: currently locks for every call. Separate constant (frozen) ids from
- * changing (e.g. OOV) ids. Constant ids could be immutable -> no locking.
+ * changing (e.g. OOV) ids. Constant ids could be immutable -> no locking.
* Alternatively: could we use ConcurrentHashMap to not have to lock if
* actually contains it and only lock for modifications?
*/
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/BLEU.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/BLEU.java b/src/main/java/org/apache/joshua/decoder/BLEU.java
index 43082a8..ec68f13 100644
--- a/src/main/java/org/apache/joshua/decoder/BLEU.java
+++ b/src/main/java/org/apache/joshua/decoder/BLEU.java
@@ -20,7 +20,6 @@ package org.apache.joshua.decoder;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -35,7 +34,7 @@ import org.apache.joshua.util.Regex;
/**
* this class implements: (1) sentence-level bleu, with smoothing
*
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Zhifei Li, zhifei.work@gmail.com
*/
public class BLEU {
// do_ngram_clip: consider global n-gram clip
@@ -47,11 +46,12 @@ public class BLEU {
// ====================multiple references
/**
*
- * @param refSents
- * @param hypSent
+ * @param refSents todo
+ * @param hypSent todo
* @param doNgramClip Should usually be true
* @param bleuOrder Should usually be 4
* @param useShortestRef Probably use false
+ * @return todo
*/
public static float computeSentenceBleu(String[] refSents, String hypSent, boolean doNgramClip,
int bleuOrder, boolean useShortestRef) {
@@ -92,6 +92,9 @@ public class BLEU {
/**
* words in the ngrams are using integer symbol ID
+ * @param refSents todo
+ * @param bleuOrder todo
+ * @return todo
* */
public static HashMap<String, Integer> constructMaxRefCountTable(String[] refSents, int bleuOrder) {
@@ -111,6 +114,8 @@ public class BLEU {
/**
* compute max_ref_count for each ngram in the reference sentences
+ * @param listRefNgramTbl todo
+ * @return todo
* */
public static HashMap<String, Integer> computeMaxRefCountTbl(
List<HashMap<String, Integer>> listRefNgramTbl) {
@@ -195,10 +200,7 @@ public class BLEU {
numNgramMatch[Regex.spaces.split(ngram).length - 1] += Support.findMin(
refNgramTbl.get(ngram), entry.getValue()); // ngram clip
} else {
- numNgramMatch[Regex.spaces.split(ngram).length - 1] += entry.getValue();// without
- // ngram
- // count
- // clipping
+ numNgramMatch[Regex.spaces.split(ngram).length - 1] += entry.getValue();// without ngram count clipping
}
}
}
@@ -257,6 +259,11 @@ public class BLEU {
/**
* speed consideration: assume hypNgramTable has a smaller size than referenceNgramTable does
+ * @param linearCorpusGainThetas todo
+ * @param hypLength todo
+ * @param hypNgramTable todo
+ * @param referenceNgramTable todo
+ * @return todo
*/
public static float computeLinearCorpusGain(float[] linearCorpusGainThetas, int hypLength,
Map<String, Integer> hypNgramTable, Map<String, Integer> referenceNgramTable) {
@@ -332,8 +339,10 @@ public class BLEU {
return res;
}
+ public static final int maxOrder = 4;
+
/**
- * Computes BLEU statistics incurred by a rule. This is (a) all ngram (n <= 4) for terminal rules
+ * Computes BLEU statistics incurred by a rule. This is (a) all ngram (n <= 4) for terminal rules
* and (b) all ngrams overlying boundary points between terminals in the rule and ngram state from
* tail nodes.
*
@@ -347,13 +356,11 @@ public class BLEU {
*
* Of these, all but the first have a boundary point to consider.
*
- * @param rule the rule being applied
- * @param spanWidth the width of the span in the input sentence
+ * @param edge todo
+ * @param spanPct todo
* @param references the reference to compute statistics against
- * @return
+ * @return todo
*/
- public static final int maxOrder = 4;
-
public static Stats compute(HyperEdge edge, float spanPct, References references) {
Stats stats = new Stats();
// TODO: this should not be the span width, but the real ref scaled to the span percentage
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/Decoder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/Decoder.java b/src/main/java/org/apache/joshua/decoder/Decoder.java
index 43f845c..29ccce6 100644
--- a/src/main/java/org/apache/joshua/decoder/Decoder.java
+++ b/src/main/java/org/apache/joshua/decoder/Decoder.java
@@ -28,7 +28,6 @@ import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -80,10 +79,10 @@ import org.apache.joshua.util.io.LineReader;
* Translations object). Translations itself is an iterator whose next() call blocks until the next
* translation is available.
*
- * @author Matt Post <po...@cs.jhu.edu>
- * @author Zhifei Li, <zh...@gmail.com>
- * @author wren ng thornton <wr...@users.sourceforge.net>
- * @author Lane Schwartz <do...@users.sourceforge.net>
+ * @author Matt Post post@cs.jhu.edu
+ * @author Zhifei Li, zhifei.work@gmail.com
+ * @author wren ng thornton wren@users.sourceforge.net
+ * @author Lane Schwartz dowobeha@users.sourceforge.net
*/
public class Decoder {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/DecoderThread.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/DecoderThread.java b/src/main/java/org/apache/joshua/decoder/DecoderThread.java
index 4390a59..c5835fd 100644
--- a/src/main/java/org/apache/joshua/decoder/DecoderThread.java
+++ b/src/main/java/org/apache/joshua/decoder/DecoderThread.java
@@ -44,8 +44,8 @@ import org.apache.joshua.corpus.Vocabulary;
*
* The DecoderFactory class is responsible for launching the threads.
*
- * @author Matt Post <po...@cs.jhu.edu>
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Matt Post post@cs.jhu.edu
+ * @author Zhifei Li, zhifei.work@gmail.com
*/
public class DecoderThread extends Thread {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/JoshuaConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/JoshuaConfiguration.java b/src/main/java/org/apache/joshua/decoder/JoshuaConfiguration.java
index bf8cfb3..f498a56 100644
--- a/src/main/java/org/apache/joshua/decoder/JoshuaConfiguration.java
+++ b/src/main/java/org/apache/joshua/decoder/JoshuaConfiguration.java
@@ -43,8 +43,8 @@ import org.apache.joshua.util.io.LineReader;
* When adding new features to Joshua, any new configurable parameters should be added to this
* class.
*
- * @author Zhifei Li, <zh...@gmail.com>
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Zhifei Li, zhifei.work@gmail.com
+ * @author Matt Post post@cs.jhu.edu
*/
public class JoshuaConfiguration {
@@ -325,6 +325,8 @@ public class JoshuaConfiguration {
* To process command-line options, we write them to a file that looks like the config file, and
* then call readConfigFile() on it. It would be more general to define a class that sits on a
* stream and knows how to chop it up, but this was quicker to implement.
+ *
+ * @param options string array of command line options
*/
public void processCommandLineOptions(String[] options) {
try {
@@ -701,8 +703,13 @@ public class JoshuaConfiguration {
* equivalence classes on external use of parameter names, permitting arbitrary_under_scores and
* camelCasing in paramter names without forcing the user to memorize them all. Here are some
* examples of equivalent ways to refer to parameter names:
- *
+ * <pre>
* {pop-limit, poplimit, PopLimit, popLimit, pop_lim_it} {lmfile, lm-file, LM-FILE, lm_file}
+ * </pre>
+ *
+ * @param text the string to be normalized
+ * @return normalized key
+ *
*/
public static String normalize_key(String text) {
return text.replaceAll("[-_]", "").toLowerCase();
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/JoshuaDecoder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/JoshuaDecoder.java b/src/main/java/org/apache/joshua/decoder/JoshuaDecoder.java
index 8c0b10b..42b17d7 100644
--- a/src/main/java/org/apache/joshua/decoder/JoshuaDecoder.java
+++ b/src/main/java/org/apache/joshua/decoder/JoshuaDecoder.java
@@ -39,9 +39,9 @@ import org.apache.joshua.server.ServerThread;
* Implements decoder initialization, including interaction with <code>JoshuaConfiguration</code>
* and <code>DecoderThread</code>.
*
- * @author Zhifei Li, <zh...@gmail.com>
- * @author wren ng thornton <wr...@users.sourceforge.net>
- * @author Lane Schwartz <do...@users.sourceforge.net>
+ * @author Zhifei Li, zhifei.work@gmail.com
+ * @author wren ng thornton wren@users.sourceforge.net
+ * @author Lane Schwartz dowobeha@users.sourceforge.net
*/
public class JoshuaDecoder {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/NbestMinRiskReranker.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/NbestMinRiskReranker.java b/src/main/java/org/apache/joshua/decoder/NbestMinRiskReranker.java
index b2126cb..e2061b0 100644
--- a/src/main/java/org/apache/joshua/decoder/NbestMinRiskReranker.java
+++ b/src/main/java/org/apache/joshua/decoder/NbestMinRiskReranker.java
@@ -42,7 +42,7 @@ import org.apache.joshua.util.Regex;
* uses a Viterbi approximation: the probability of a string is its best derivation probability So,
* if one want to deal with spurious ambiguity, he/she should do that before calling this class
*
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Zhifei Li, zhifei.work@gmail.com
*/
public class NbestMinRiskReranker {
@@ -182,7 +182,10 @@ public class NbestMinRiskReranker {
/**
* based on a list of log-probabilities in nbestLogProbs, obtain a normalized distribution, and
* put the normalized probability (real value in [0,1]) into nbestLogProbs
- * */
+ *
+ * @param nbestLogProbs a {@link java.util.List} of {@link java.lang.Double} representing nbestLogProbs
+ * @param scalingFactor double value representing scaling factor
+ */
// get a normalized distributeion and put it back to nbestLogProbs
static public void computeNormalizedProbs(List<Double> nbestLogProbs, double scalingFactor) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/StructuredTranslation.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/StructuredTranslation.java b/src/main/java/org/apache/joshua/decoder/StructuredTranslation.java
index 75e6ab4..bdfde54 100644
--- a/src/main/java/org/apache/joshua/decoder/StructuredTranslation.java
+++ b/src/main/java/org/apache/joshua/decoder/StructuredTranslation.java
@@ -33,10 +33,9 @@ import org.apache.joshua.decoder.hypergraph.HyperGraph;
import org.apache.joshua.decoder.segment_file.Sentence;
/**
- * structuredTranslation provides a more structured access to translation
+ * <p>structuredTranslation provides a more structured access to translation
* results than the Translation class.
- * Members of instances of this class can be used upstream.
- * <br/>
+ * Members of instances of this class can be used upstream.</p>
* TODO:
* Enable K-Best extraction.
*
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/Support.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/Support.java b/src/main/java/org/apache/joshua/decoder/Support.java
index 7c4a0b2..22bfe89 100644
--- a/src/main/java/org/apache/joshua/decoder/Support.java
+++ b/src/main/java/org/apache/joshua/decoder/Support.java
@@ -21,7 +21,7 @@ package org.apache.joshua.decoder;
import java.util.List;
/**
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Zhifei Li, zhifei.work@gmail.com
*/
public class Support {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/Translation.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/Translation.java b/src/main/java/org/apache/joshua/decoder/Translation.java
index 10852e5..0b632ba 100644
--- a/src/main/java/org/apache/joshua/decoder/Translation.java
+++ b/src/main/java/org/apache/joshua/decoder/Translation.java
@@ -41,7 +41,7 @@ import org.apache.joshua.decoder.segment_file.Sentence;
* sentence and id and contains the decoded hypergraph. Translation objects are returned by
* DecoderThread instances to the InputHandler, where they are assembled in order for output.
*
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*/
public class Translation {
@@ -54,17 +54,17 @@ public class Translation {
private String output = null;
private StructuredTranslation structuredTranslation = null;
-
+
public Translation(Sentence source, HyperGraph hypergraph,
List<FeatureFunction> featureFunctions, JoshuaConfiguration joshuaConfiguration) {
this.source = source;
-
+
if (joshuaConfiguration.use_structured_output) {
-
+
structuredTranslation = new StructuredTranslation(
source, hypergraph, featureFunctions);
this.output = structuredTranslation.getTranslationString();
-
+
} else {
StringWriter sw = new StringWriter();
@@ -81,15 +81,15 @@ public class Translation {
// We must put this weight as zero, otherwise we get an error when we try to retrieve it
// without checking
Decoder.weights.increment("BLEU", 0);
-
+
if (joshuaConfiguration.topN == 0) {
-
+
/* construct Viterbi output */
final String best = getViterbiString(hypergraph);
-
+
Decoder.LOG(1, String.format("Translation %d: %.3f %s", source.id(), hypergraph.goalNode.getScore(),
best));
-
+
/*
* Setting topN to 0 turns off k-best extraction, in which case we need to parse through
* the output-string, with the understanding that we can only substitute variables for the
@@ -100,21 +100,21 @@ public class Translation {
.replace("%S", DeNormalize.processSingleLine(best))
.replace("%c", String.format("%.3f", hypergraph.goalNode.getScore()))
.replace("%i", String.format("%d", source.id()));
-
+
if (joshuaConfiguration.outputFormat.contains("%a")) {
translation = translation.replace("%a", getViterbiWordAlignments(hypergraph));
}
-
+
if (joshuaConfiguration.outputFormat.contains("%f")) {
final FeatureVector features = getViterbiFeatures(hypergraph, featureFunctions, source);
translation = translation.replace("%f", joshuaConfiguration.moses ? features.mosesString() : features.toString());
}
-
+
out.write(translation);
out.newLine();
-
+
} else {
-
+
final KBestExtractor kBestExtractor = new KBestExtractor(
source, featureFunctions, Decoder.weights, false, joshuaConfiguration);
kBestExtractor.lazyKBestExtractOnHG(hypergraph, joshuaConfiguration.topN, out);
@@ -132,32 +132,32 @@ public class Translation {
Decoder.LOG(1, String.format("Input %d: %d-best extraction took %.3f seconds", id(),
joshuaConfiguration.topN, seconds));
- } else {
-
- // Failed translations and blank lines get empty formatted outputs
- // @formatter:off
- String outputString = joshuaConfiguration.outputFormat
- .replace("%s", source.source())
- .replace("%e", "")
- .replace("%S", "")
- .replace("%t", "()")
- .replace("%i", Integer.toString(source.id()))
- .replace("%f", "")
- .replace("%c", "0.000");
- // @formatter:on
-
- out.write(outputString);
- out.newLine();
- }
+ } else {
+
+ // Failed translations and blank lines get empty formatted outputs
+ // @formatter:off
+ String outputString = joshuaConfiguration.outputFormat
+ .replace("%s", source.source())
+ .replace("%e", "")
+ .replace("%S", "")
+ .replace("%t", "()")
+ .replace("%i", Integer.toString(source.id()))
+ .replace("%f", "")
+ .replace("%c", "0.000");
+ // @formatter:on
+
+ out.write(outputString);
+ out.newLine();
+ }
out.flush();
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}
-
+
this.output = sw.toString();
-
+
}
/*
@@ -170,7 +170,7 @@ public class Translation {
break;
}
}
-
+
}
public Sentence getSourceSentence() {
@@ -185,12 +185,12 @@ public class Translation {
public String toString() {
return output;
}
-
+
/**
* Returns the StructuredTranslation object
* if JoshuaConfiguration.construct_structured_output == True.
* @throws RuntimeException if StructuredTranslation object not set.
- * @return
+ * @return {@link org.apache.joshua.decoder.StructuredTranslation} object
*/
public StructuredTranslation getStructuredTranslation() {
if (structuredTranslation == null) {
@@ -198,5 +198,5 @@ public class Translation {
}
return structuredTranslation;
}
-
+
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/Translations.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/Translations.java b/src/main/java/org/apache/joshua/decoder/Translations.java
index 7dd9086..0b91ff9 100644
--- a/src/main/java/org/apache/joshua/decoder/Translations.java
+++ b/src/main/java/org/apache/joshua/decoder/Translations.java
@@ -30,7 +30,7 @@ import org.apache.joshua.decoder.io.TranslationRequestStream;
* Translation in the right place. When the next translation in a sequence is available, next() is
* notified.
*
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*/
public class Translations {
@@ -73,7 +73,7 @@ public class Translations {
* the ID of the translation is the same as the one being waited for (currentID). If so, the
* thread waiting for it is notified.
*
- * @param translation
+ * @param translation a translated input object
*/
public void record(Translation translation) {
synchronized (this) {
@@ -98,6 +98,8 @@ public class Translations {
/**
* Returns the next Translation, blocking if necessary until it's available, since the next
* Translation might not have been produced yet.
+ *
+ * @return first element from the list of {@link org.apache.joshua.decoder.Translation}'s
*/
public Translation next() {
synchronized (this) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/chart_parser/Chart.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/chart_parser/Chart.java b/src/main/java/org/apache/joshua/decoder/chart_parser/Chart.java
index 0825ccb..0bc2f9f 100644
--- a/src/main/java/org/apache/joshua/decoder/chart_parser/Chart.java
+++ b/src/main/java/org/apache/joshua/decoder/chart_parser/Chart.java
@@ -60,8 +60,8 @@ import org.apache.joshua.util.ChartSpan;
* index of sentences: start from zero index of cell: cell (i,j) represent span
* of words indexed [i,j-1] where i is in [0,n-1] and j is in [1,n]
*
- * @author Zhifei Li, <zh...@gmail.com>
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Zhifei Li, zhifei.work@gmail.com
+ * @author Matt Post post@cs.jhu.edu
*/
public class Chart {
@@ -728,7 +728,7 @@ public class Chart {
}
/***
- * Add a terminal production (X -> english phrase) to the hypergraph.
+ * Add a terminal production (X -> english phrase) to the hypergraph.
*
* @param i the start index
* @param j stop index
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/chart_parser/ComputeNodeResult.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/chart_parser/ComputeNodeResult.java b/src/main/java/org/apache/joshua/decoder/chart_parser/ComputeNodeResult.java
index eeb6366..ce0b190 100644
--- a/src/main/java/org/apache/joshua/decoder/chart_parser/ComputeNodeResult.java
+++ b/src/main/java/org/apache/joshua/decoder/chart_parser/ComputeNodeResult.java
@@ -35,8 +35,8 @@ import org.apache.joshua.decoder.segment_file.Sentence;
/**
* This class computes the cost of applying a rule.
*
- * @author Matt Post <po...@cs.jhu.edu>
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Matt Post post@cs.jhu.edu
+ * @author Zhifei Li, zhifei.work@gmail.com
*/
public class ComputeNodeResult {
@@ -130,7 +130,8 @@ public class ComputeNodeResult {
}
/**
- * This is called from Cell.java when making the final transition to the goal state.
+ * This is called from {@link org.apache.joshua.decoder.chart_parser.Cell}
+ * when making the final transition to the goal state.
* This is done to allow feature functions to correct for partial estimates, since
* they now have the knowledge that the whole sentence is complete. Basically, this
* is only used by LanguageModelFF, which does not score partial n-grams, and therefore
@@ -140,6 +141,14 @@ public class ComputeNodeResult {
* too: it makes search better (more accurate at the beginning, for example), and would
* also do away with the need for the computeFinal* class of functions (and hooks in
* the feature function interface).
+ *
+ * @param featureFunctions {@link java.util.List} of {@link org.apache.joshua.decoder.ff.FeatureFunction}'s
+ * @param tailNodes {@link java.util.List} of {@link org.apache.joshua.decoder.hypergraph.HGNode}'s
+ * @param i todo
+ * @param j todo
+ * @param sourcePath information about a path taken through the source lattice
+ * @param sentence the lattice input
+ * @return the final cost for the Node
*/
public static float computeFinalCost(List<FeatureFunction> featureFunctions,
List<HGNode> tailNodes, int i, int j, SourcePath sourcePath, Sentence sentence) {
@@ -176,6 +185,7 @@ public class ComputeNodeResult {
/**
* The complete cost of the Viterbi derivation at this point
+ * @return float representing cost
*/
public float getViterbiCost() {
return this.viterbiCost;
@@ -188,7 +198,7 @@ public class ComputeNodeResult {
/**
* The cost incurred by this edge alone
*
- * @return
+ * @return float representing cost
*/
public float getTransitionCost() {
return this.transitionCost;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/chart_parser/ManualConstraintsHandler.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/chart_parser/ManualConstraintsHandler.java b/src/main/java/org/apache/joshua/decoder/chart_parser/ManualConstraintsHandler.java
index 38e9f4a..06a14ee 100644
--- a/src/main/java/org/apache/joshua/decoder/chart_parser/ManualConstraintsHandler.java
+++ b/src/main/java/org/apache/joshua/decoder/chart_parser/ManualConstraintsHandler.java
@@ -31,7 +31,7 @@ import org.apache.joshua.decoder.segment_file.ConstraintRule;
import org.apache.joshua.decoder.segment_file.ConstraintSpan;
/**
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Zhifei Li, zhifei.work@gmail.com
*/
public class ManualConstraintsHandler {
@@ -141,6 +141,11 @@ public class ManualConstraintsHandler {
/**
* if there are any LHS or RHS constraints for a span, then all the applicable grammar rules in
* that span will have to pass the filter.
+ *
+ * @param i LHS of span, used for genrating the span signature
+ * @param j RHS of span, used for genrating the span signature
+ * @param rulesIn {@link java.util.List} of {@link org.apache.joshua.decoder.ff.tm.Rule}'s
+ * @return filtered {@link java.util.List} of {@link org.apache.joshua.decoder.ff.tm.Rule}'s
*/
public List<Rule> filterRules(int i, int j, List<Rule> rulesIn) {
if (null == this.constraintSpansForFiltering) return rulesIn;
@@ -165,6 +170,9 @@ public class ManualConstraintsHandler {
/**
* should we filter out the gRule based on the manually provided constraint cRule
+ * @param cRule constraint rule
+ * @param gRule rule which may be filtered
+ * @return true if this gRule should survive
*/
public boolean shouldSurvive(ConstraintRule cRule, Rule gRule) {
@@ -189,6 +197,9 @@ public class ManualConstraintsHandler {
/**
* if a span is *within* the coverage of a *hard* rule constraint, then this span will be only
* allowed to use the mannual rules
+ * @param startSpan beginning node (int) for span
+ * @param endSpan end node (int) for span
+ * @return true if this span containers a rule constraint
*/
public boolean containHardRuleConstraint(int startSpan, int endSpan) {
if (null != this.spansWithHardRuleConstraint) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/chart_parser/SourcePath.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/chart_parser/SourcePath.java b/src/main/java/org/apache/joshua/decoder/chart_parser/SourcePath.java
index 3fba257..1d96149 100644
--- a/src/main/java/org/apache/joshua/decoder/chart_parser/SourcePath.java
+++ b/src/main/java/org/apache/joshua/decoder/chart_parser/SourcePath.java
@@ -24,7 +24,7 @@ import org.apache.joshua.lattice.Arc;
/**
* This class represents information about a path taken through the source lattice.
*
- * @note This implementation only tracks the source path cost which is assumed to be a scalar value.
+ * <p>This implementation only tracks the source path cost which is assumed to be a scalar value.
* If you need multiple values, or want to recover more detailed path statistics, you'll need
* to update this code.
*/
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/chart_parser/StateConstraint.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/chart_parser/StateConstraint.java b/src/main/java/org/apache/joshua/decoder/chart_parser/StateConstraint.java
index 7cd263d..d21ceca 100644
--- a/src/main/java/org/apache/joshua/decoder/chart_parser/StateConstraint.java
+++ b/src/main/java/org/apache/joshua/decoder/chart_parser/StateConstraint.java
@@ -29,7 +29,7 @@ import org.apache.joshua.decoder.ff.state_maintenance.NgramDPState;
* original motivation was to be used as a means of doing forced decoding, which is accomplished by
* forcing all n-gram states that are created to match the target string.
*
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*
*/
public class StateConstraint {
@@ -43,7 +43,7 @@ public class StateConstraint {
* Determines if all of the states passed in are legal in light of the input that was passed
* earlier. Currently only defined for n-gram states.
*
- * @param dpStates
+ * @param dpStates {@link java.util.Collection} of {@link org.apache.joshua.decoder.ff.state_maintenance.DPState}'s
* @return whether the states are legal in light of the target side sentence
*/
public boolean isLegal(Collection<DPState> dpStates) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/ArityPhrasePenalty.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/ArityPhrasePenalty.java b/src/main/java/org/apache/joshua/decoder/ff/ArityPhrasePenalty.java
index 25f363d..d4f9534 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/ArityPhrasePenalty.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/ArityPhrasePenalty.java
@@ -33,8 +33,8 @@ import org.apache.joshua.corpus.Vocabulary;
* arity within a specific range. It expects three parameters upon initialization: the owner, the
* minimum arity, and the maximum arity.
*
- * @author Matt Post <post@cs.jhu.edu
- * @author Zhifei Li <zh...@gmail.com>
+ * @author Matt Post post@cs.jhu.edu
+ * @author Zhifei Li zhifei.work@gmail.com
*/
public class ArityPhrasePenalty extends StatelessFF {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/FeatureFunction.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/FeatureFunction.java b/src/main/java/org/apache/joshua/decoder/ff/FeatureFunction.java
index c6112e5..e5f0baa 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/FeatureFunction.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/FeatureFunction.java
@@ -32,26 +32,27 @@ import org.apache.joshua.decoder.hypergraph.HGNode;
import org.apache.joshua.decoder.segment_file.Sentence;
/**
- * This class defines Joshua's feature function interface, for both sparse and
+ * <p>This class defines Joshua's feature function interface, for both sparse and
* dense features. It is immediately inherited by StatelessFF and StatefulFF,
* which provide functionality common to stateless and stateful features,
* respectively. Any feature implementation should extend those classes, and not
* this one. The distinction between stateless and stateful features is somewhat
* narrow: all features have the opportunity to return an instance of a
- * {@link DPState} object, and stateless ones just return null.
+ * {@link DPState} object, and stateless ones just return null.</p>
*
- * Features in Joshua work like templates. Each feature function defines any
+ * <p>Features in Joshua work like templates. Each feature function defines any
* number of actual features, which are associated with weights. The task of the
* feature function is to compute the features that are fired in different
* circumstances and then return the inner product of those features with the
* weight vector. Feature functions can also produce estimates of their future
- * cost (via {@link estimateCost()}); these values are not used in computing the
+ * cost (via {@link org.apache.joshua.decoder.ff.FeatureFunction#estimateCost(Rule, Sentence)});
+ * these values are not used in computing the
* score, but are only used for sorting rules during cube pruning. The
* individual features produced by each template should have globally unique
* names; a good convention is to prefix each feature with the name of the
- * template that produced it.
+ * template that produced it.</p>
*
- * Joshua does not retain individual feature values while decoding, since this
+ * <p>Joshua does not retain individual feature values while decoding, since this
* requires keeping a sparse feature vector along every hyperedge, which can be
* expensive. Instead, it computes only the weighted cost of each edge. If the
* individual feature values are requested, the feature functions are replayed
@@ -59,10 +60,10 @@ import org.apache.joshua.decoder.segment_file.Sentence;
* a generic way by passing an {@link Accumulator} object to the compute()
* function. During decoding, the accumulator simply sums weighted features in a
* scalar. During k-best extraction, when individual feature values are needed,
- * a {@link FeatureAccumulator} is used to retain the individual values.
+ * a {@link FeatureAccumulator} is used to retain the individual values.</p>
*
- * @author Matt Post <po...@cs.jhu.edu>
- * @author Juri Ganitkevich <ju...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
+ * @author Juri Ganitkevich juri@cs.jhu.edu
*/
public abstract class FeatureFunction {
@@ -135,22 +136,23 @@ public abstract class FeatureFunction {
/**
* This is the main function for defining feature values. The implementor
- * should compute all the features along the hyperedge, calling acc.put(name,
- * value) for each feature. It then returns the newly-computed dynamic
+ * should compute all the features along the hyperedge, calling
+ * {@link org.apache.joshua.decoder.ff.FeatureFunction.Accumulator#add(String, float)}
+ * for each feature. It then returns the newly-computed dynamic
* programming state for this feature (for example, for the
- * {@link LanguageModelFF} feature, this returns the new language model
+ * {@link org.apache.joshua.decoder.ff.lm.LanguageModelFF} feature, this returns the new language model
* context). For stateless features, this value is null.
*
* Note that the accumulator accumulates *unweighted* feature values. The
* feature vector is multiplied times the weight vector later on.
*
- * @param rule
- * @param tailNodes
- * @param i
- * @param j
- * @param sourcePath
- * @param sentID
- * @param acc
+ * @param rule {@link org.apache.joshua.decoder.ff.tm.Rule} to be utilized within computation
+ * @param tailNodes {@link java.util.List} of {@link org.apache.joshua.decoder.hypergraph.HGNode} tail nodes
+ * @param i todo
+ * @param j todo
+ * @param sourcePath information about a path taken through the source {@link org.apache.joshua.lattice.Lattice}
+ * @param sentence {@link org.apache.joshua.lattice.Lattice} input
+ * @param acc {@link org.apache.joshua.decoder.ff.FeatureFunction.Accumulator} object permitting generalization of feature computation
* @return the new dynamic programming state (null for stateless features)
*/
public abstract DPState compute(Rule rule, List<HGNode> tailNodes, int i, int j,
@@ -160,12 +162,12 @@ public abstract class FeatureFunction {
* Feature functions must overrided this. StatefulFF and StatelessFF provide
* reasonable defaults since most features do not fire on the goal node.
*
- * @param tailNode
- * @param i
- * @param j
- * @param sourcePath
- * @param sentID
- * @param acc
+ * @param tailNode single {@link org.apache.joshua.decoder.hypergraph.HGNode} representing tail node
+ * @param i todo
+ * @param j todo
+ * @param sourcePath information about a path taken through the source {@link org.apache.joshua.lattice.Lattice}
+ * @param sentence {@link org.apache.joshua.lattice.Lattice} input
+ * @param acc {@link org.apache.joshua.decoder.ff.FeatureFunction.Accumulator} object permitting generalization of feature computation
* @return the DPState (null if none)
*/
public abstract DPState computeFinal(HGNode tailNode, int i, int j, SourcePath sourcePath,
@@ -181,12 +183,12 @@ public abstract class FeatureFunction {
* incorporate the feature weights. This function is used in the kbest
* extraction code but could also be used in computing the cost.
*
- * @param rule
- * @param tailNodes
- * @param i
- * @param j
- * @param sourcePath
- * @param sentID
+ * @param rule {@link org.apache.joshua.decoder.ff.tm.Rule} to be utilized within computation
+ * @param tailNodes {@link java.util.List} of {@link org.apache.joshua.decoder.hypergraph.HGNode} tail nodes
+ * @param i todo
+ * @param j todo
+ * @param sourcePath information about a path taken through the source {@link org.apache.joshua.lattice.Lattice}
+ * @param sentence {@link org.apache.joshua.lattice.Lattice} input
* @return an *unweighted* feature delta
*/
public final FeatureVector computeFeatures(Rule rule, List<HGNode> tailNodes, int i, int j,
@@ -203,11 +205,11 @@ public abstract class FeatureFunction {
* return the *weighted* cost of applying the feature. Provided for backward
* compatibility.
*
- * @param tailNode
- * @param i
- * @param j
- * @param sourcePath
- * @param sentID
+ * @param tailNode single {@link org.apache.joshua.decoder.hypergraph.HGNode} representing tail node
+ * @param i todo
+ * @param j todo
+ * @param sourcePath information about a path taken through the source {@link org.apache.joshua.lattice.Lattice}
+ * @param sentence {@link org.apache.joshua.lattice.Lattice} input
* @return a *weighted* feature cost
*/
public final float computeFinalCost(HGNode tailNode, int i, int j, SourcePath sourcePath,
@@ -222,12 +224,12 @@ public abstract class FeatureFunction {
* Returns the *unweighted* feature delta for the final transition (e.g., for
* the language model feature function). Provided for backward compatibility.
*
- * @param tailNode
- * @param i
- * @param j
- * @param sourcePath
- * @param sentID
- * @return
+ * @param tailNode single {@link org.apache.joshua.decoder.hypergraph.HGNode} representing tail node
+ * @param i todo
+ * @param j todo
+ * @param sourcePath information about a path taken through the source {@link org.apache.joshua.lattice.Lattice}
+ * @param sentence {@link org.apache.joshua.lattice.Lattice} input
+ * @return an *weighted* feature vector
*/
public final FeatureVector computeFinalFeatures(HGNode tailNode, int i, int j,
SourcePath sourcePath, Sentence sentence) {
@@ -247,6 +249,8 @@ public abstract class FeatureFunction {
* sorting. Later, the real cost of this feature function is called via
* compute();
*
+ * @param rule {@link org.apache.joshua.decoder.ff.tm.Rule} to be utilized within computation
+ * @param sentence {@link org.apache.joshua.lattice.Lattice} input
* @return the *weighted* cost of applying the feature.
*/
public abstract float estimateCost(Rule rule, Sentence sentence);
@@ -257,9 +261,9 @@ public abstract class FeatureFunction {
* score but is used in pruning decisions. Stateless features return 0.0f by
* default, but Stateful features might want to override this.
*
- * @param rule
- * @param state
- * @param sentence
+ * @param rule {@link org.apache.joshua.decoder.ff.tm.Rule} to be utilized within computation
+ * @param state todo
+ * @param sentence {@link org.apache.joshua.lattice.Lattice} input
* @return the *weighted* future cost estimate of applying this rule in
* context.
*/
@@ -271,7 +275,7 @@ public abstract class FeatureFunction {
* Any key without a value is added with an empty string as value Multiple values for the same key
* are not parsed. The first one is used.
*
- * @param rawArgs A string with the raw arguments and their names
+ * @param args A string with the raw arguments and their names
* @return A hash with the keys and the values of the string
*/
public static HashMap<String, String> parseArgs(String[] args) {
@@ -306,7 +310,11 @@ public abstract class FeatureFunction {
/**
* It is used when initializing translation grammars (for
* pruning purpose, and to get stateless logP for each rule).
- * This is also required to sort the rules (required by Cube-pruning).
+ * This is also required to sort the rules (required by Cube-pruning).
+ *
+ * @param rule {@link org.apache.joshua.decoder.ff.tm.Rule} to be utilized within computation
+ * @param sentID associated ID
+ * @return double value representing LogP
*/
public abstract double estimateLogP(Rule rule, int sentID);
@@ -318,7 +326,6 @@ public abstract class FeatureFunction {
* sum (for decoding). FeatureAccumulator records the named feature values
* (for k-best extraction).
*/
-
public interface Accumulator {
public void add(String name, float value);
public void add(int id, float value);
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/FeatureVector.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/FeatureVector.java b/src/main/java/org/apache/joshua/decoder/ff/FeatureVector.java
index 65ed077..778997e 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/FeatureVector.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/FeatureVector.java
@@ -35,9 +35,11 @@ import java.util.Set;
* queries each of them for their sparse features via {@link registerDenseFeatures}. Those features
* returned by each decoder are then *removed* from the sparse feature hash and placed in the dense
* feature array. Therefore, when a feature registers a dense feature, it should take care to
- * query either {@link getDense()} or {@link getSparse} when asking for the feature values later on.
+ * query either {@link org.apache.joshua.decoder.ff.FeatureVector#getDense(int)} or
+ * {@link org.apache.joshua.decoder.ff.FeatureVector#getSparse(String)} when asking for the feature
+ * values later on.
*
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*/
public class FeatureVector {
@@ -75,8 +77,8 @@ public class FeatureVector {
* **IMPORTANT** The feature values are inverted, for historical reasons, which leads to a lot
* of confusion. They have to be inverted here and when the score is actually computed. They
* are inverted here (which is used to build the feature vector representation of a rule's dense
- * features) and in {@link BilingualRule::estimateRuleCost()}, where the rule's precomputable
- * (weighted) score is cached.
+ * features) and in {@link org.apache.joshua.decoder.ff.tm.BilingualRule#estimateRuleCost(java.util.List)}
+ * , where the rule's precomputable (weighted) score is cached.
*
* @param featureString, the string of labeled and unlabeled features (probably straight from the
* grammar text file)
@@ -138,8 +140,7 @@ public class FeatureVector {
* can infer them all). This *must* be called by every feature function wishing to register
* dense features!
*
- * @param names
- * @return
+ * @param featureFunctions {@link java.util.ArrayList} of {@link org.apache.joshua.decoder.ff.FeatureFunction}'s
*/
public void registerDenseFeatures(ArrayList<FeatureFunction> featureFunctions) {
for (FeatureFunction feature: featureFunctions) {
@@ -181,6 +182,8 @@ public class FeatureVector {
* Subtracts the weights in the other feature vector from this one. Note that this is not set
* subtraction; keys found in the other FeatureVector but not in this one will be initialized with
* a value of 0.0f before subtraction.
+ *
+ * @param other another {@link org.apache.joshua.decoder.ff.FeatureVector} from which to subtract its score
*/
public void subtract(FeatureVector other) {
for (int i = 0; i < denseFeatures.size(); i++)
@@ -195,6 +198,8 @@ public class FeatureVector {
/**
* Adds the weights in the other feature vector to this one. This is set union, with values shared
* between the two being summed.
+ *
+ * @param other another {@link org.apache.joshua.decoder.ff.FeatureVector} from which to add its score
*/
public void add(FeatureVector other) {
while (denseFeatures.size() < other.denseFeatures.size())
@@ -214,6 +219,8 @@ public class FeatureVector {
/**
* Return the weight of a feature by name, after checking to determine if it is sparse or dense.
*
+ * @param feature String name of some feature
+ * @return the feature's weight
*/
public float getWeight(String feature) {
for (int i = 0; i < DENSE_FEATURE_NAMES.size(); i++) {
@@ -227,7 +234,7 @@ public class FeatureVector {
/**
* Return the weight of a sparse feature, indexed by its name.
*
- * @param feature
+ * @param feature String name of some feature
* @return the sparse feature's weight, or 0 if not found.
*/
public float getSparse(String feature) {
@@ -244,7 +251,7 @@ public class FeatureVector {
* Return the weight of a dense feature, indexed by its feature index, or 0.0f, if the feature
* is not found. In other words, this is a safe way to query the dense feature vector.
*
- * @param id
+ * @param id int representing of some dense feature
* @return the dense feature's value, or 0 if not found.
*/
public float getDense(int id) {
@@ -267,8 +274,8 @@ public class FeatureVector {
* Set the value of a feature. We need to first determine whether the feature is a dense or
* sparse one, then set accordingly.
*
- * @param feature
- * @param value
+ * @param feature String name of some feature
+ * @param value float value to set to the featue with the associated name
*/
public void set(String feature, float value) {
for (int i = 0; i < DENSE_FEATURE_NAMES.size(); i++) {
@@ -293,6 +300,9 @@ public class FeatureVector {
/**
* Computes the inner product between this feature vector and another one.
+ *
+ * @param other a {@link org.apache.joshua.decoder.ff.FeatureVector} with which to compute the inner product
+ * @return float value representing the computation
*/
public float innerProduct(FeatureVector other) {
float cost = 0.0f;
@@ -313,6 +323,8 @@ public class FeatureVector {
/***
* Moses distinguishes sparse features as those containing an underscore, so we have to fake it
* to be compatible with their tuners.
+ *
+ * @return trimmed Moses output string
*/
public String mosesString() {
StringBuilder outputString = new StringBuilder();
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/OOVPenalty.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/OOVPenalty.java b/src/main/java/org/apache/joshua/decoder/ff/OOVPenalty.java
index 0d0e0f7..69584dd 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/OOVPenalty.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/OOVPenalty.java
@@ -39,7 +39,7 @@ import org.apache.joshua.decoder.chart_parser.SourcePath;
* "mark-oovs") . These rules are all stored in a grammar whose owner is "oov". The OOV feature
* function template then fires the "OOVPenalty" feature whenever it is asked to score an OOV rule.
*
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*/
public class OOVPenalty extends StatelessFF {
private int ownerID = -1;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/PhraseModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/PhraseModel.java b/src/main/java/org/apache/joshua/decoder/ff/PhraseModel.java
index 62792dc..3eb0c2e 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/PhraseModel.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/PhraseModel.java
@@ -37,8 +37,8 @@ import org.apache.joshua.decoder.segment_file.Sentence;
* queries the weights for the set of features that are active for this grammar, storing them in an
* array.
*
- * @author Matt Post <po...@cs.jhu.edu>
- * @author Zhifei Li <zh...@gmail.com>
+ * @author Matt Post post@cs.jhu.edu
+ * @author Zhifei Li zhifei.work@gmail.com
*/
public class PhraseModel extends StatelessFF {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/SourcePathFF.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/SourcePathFF.java b/src/main/java/org/apache/joshua/decoder/ff/SourcePathFF.java
index d757303..d529559 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/SourcePathFF.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/SourcePathFF.java
@@ -32,8 +32,8 @@ import org.apache.joshua.decoder.segment_file.Sentence;
* This feature returns the scored path through the source lattice, which is recorded in a
* SourcePath object.
*
- * @author Chris Dyer <re...@umd.edu>
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Chris Dyer redpony@umd.edu
+ * @author Matt Post post@cs.jhu.edu
*/
public final class SourcePathFF extends StatelessFF {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/StatefulFF.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/StatefulFF.java b/src/main/java/org/apache/joshua/decoder/ff/StatefulFF.java
index 626eb3c..4678902 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/StatefulFF.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/StatefulFF.java
@@ -35,8 +35,8 @@ import org.apache.joshua.decoder.segment_file.Sentence;
* state-contributing objects in each HGNode. State can no longer be shared among different feature
* functions.
*
- * @author Matt Post <po...@cs.jhu.edu>
- * @author Juri Ganitkevich <ju...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
+ * @author Juri Ganitkevich juri@cs.jhu.edu
*/
public abstract class StatefulFF extends FeatureFunction {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/StatelessFF.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/StatelessFF.java b/src/main/java/org/apache/joshua/decoder/ff/StatelessFF.java
index 19f7050..e473c37 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/StatelessFF.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/StatelessFF.java
@@ -31,8 +31,8 @@ import org.apache.joshua.decoder.segment_file.Sentence;
* Stateless feature functions do not contribute any state. You need not implement this class to
* create a stateless feature function, but it provides a few convenience functions.
*
- * @author Matt Post <po...@cs.jhu.edu>
- * @author Juri Ganitkevich <ju...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
+ * @author Juri Ganitkevich juri@cs.jhu.edu
*/
public abstract class StatelessFF extends FeatureFunction {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/TargetBigram.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/TargetBigram.java b/src/main/java/org/apache/joshua/decoder/ff/TargetBigram.java
index 5661ce7..ee0f9d5 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/TargetBigram.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/TargetBigram.java
@@ -180,7 +180,7 @@ public class TargetBigram extends StatefulFF {
}
/**
- * There is nothing to be done here, since <s> and </s> are included in rules that are part
+ * There is nothing to be done here, since <s> and </s> are included in rules that are part
* of the grammar. We simply return the DP state of the tail node.
*/
@Override
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/WordPenalty.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/WordPenalty.java b/src/main/java/org/apache/joshua/decoder/ff/WordPenalty.java
index 2a40088..62c889f 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/WordPenalty.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/WordPenalty.java
@@ -31,8 +31,8 @@ import org.apache.joshua.decoder.segment_file.Sentence;
/**
*
- * @author Zhifei Li <zh...@gmail.com>
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Zhifei Li zhifei.work@gmail.com
+ * @author Matt Post post@cs.jhu.edu
*/
public final class WordPenalty extends StatelessFF {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/FragmentLMFF.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/FragmentLMFF.java b/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/FragmentLMFF.java
index e438778..cec24f2 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/FragmentLMFF.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/FragmentLMFF.java
@@ -38,33 +38,33 @@ import org.apache.joshua.decoder.hypergraph.HyperEdge;
import org.apache.joshua.decoder.segment_file.Sentence;
/**
- * Feature function that reads in a list of language model fragments and matches them against the
+ * <p>Feature function that reads in a list of language model fragments and matches them against the
* hypergraph. This allows for language model fragment "glue" features, which fire when LM fragments
* (supplied as input) are assembled. These LM fragments are presumably useful in ensuring
- * grammaticality and can be independent of the translation model fragments.
+ * grammaticality and can be independent of the translation model fragments.</p>
*
- * Usage: in the Joshua Configuration file, put
+ * <p>Usage: in the Joshua Configuration file, put</p>
*
- * feature-function = FragmentLM -lm LM_FRAGMENTS_FILE -map RULE_FRAGMENTS_MAP_FILE
+ * <code>feature-function = FragmentLM -lm LM_FRAGMENTS_FILE -map RULE_FRAGMENTS_MAP_FILE</code>
*
- * LM_FRAGMENTS_FILE is a pointer to a file containing a list of fragments that it should look for.
- * The format of the file is one fragment per line in PTB format, e.g.:
+ * <p>LM_FRAGMENTS_FILE is a pointer to a file containing a list of fragments that it should look for.
+ * The format of the file is one fragment per line in PTB format, e.g.:</p>
*
- * (S NP (VP (VBD said) SBAR) (. .))
+ * <code>(S NP (VP (VBD said) SBAR) (. .))</code>
*
- * RULE_FRAGMENTS_MAP_FILE points to a file that maps fragments to the flattened SCFG rule format
+ * <p>RULE_FRAGMENTS_MAP_FILE points to a file that maps fragments to the flattened SCFG rule format
* that Joshua uses. This mapping is necessary because Joshua's rules have been flattened, meaning
* that their internal structure has been removed, yet this structure is needed for matching LM
- * fragments. The format of the file is
+ * fragments. The format of the file is</p>
*
- * FRAGMENT ||| RULE-TARGET-SIDE
+ * <code>FRAGMENT ||| RULE-TARGET-SIDE</code>
*
- * for example,
+ * <p>for example,</p>
*
- * (S (NP (DT the) (NN man)) VP .) ||| the man [VP,1] [.,2] (SBAR (IN that) (S (NP (PRP he)) (VP
- * (VBD was) (VB done)))) ||| that he was done (VP (VBD said) SBAR) ||| said SBAR
+ * <code>(S (NP (DT the) (NN man)) VP .) ||| the man [VP,1] [.,2] (SBAR (IN that) (S (NP (PRP he)) (VP
+ * (VBD was) (VB done)))) ||| that he was done (VP (VBD said) SBAR) ||| said SBAR</code>
*
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*/
public class FragmentLMFF extends StatefulFF {
@@ -104,9 +104,9 @@ public class FragmentLMFF extends StatefulFF {
private String fragmentLMFile = "";
/**
- * @param weights
- * @param name
- * @param stateComputer
+ * @param weights a {@link org.apache.joshua.decoder.ff.FeatureVector} with weights
+ * @param args arguments passed to the feature function
+ * @param config the {@link org.apache.joshua.decoder.JoshuaConfiguration}
*/
public FragmentLMFF(FeatureVector weights, String[] args, JoshuaConfiguration config) {
super(weights, "FragmentLMFF", args, config);
@@ -139,7 +139,7 @@ public class FragmentLMFF extends StatefulFF {
/**
* Add the provided fragment to the language model, subject to some filtering.
*
- * @param fragment
+ * @param fragment a {@link org.apache.joshua.decoder.ff.fragmentlm.Tree} fragment
*/
public void addLMFragment(Tree fragment) {
if (lmFragments == null)
@@ -170,6 +170,15 @@ public class FragmentLMFF extends StatefulFF {
* that fire are any LM fragments that match the fragment associated with the current rule. LM
* fragments may recurse over the tail nodes, following 1-best backpointers until the fragment
* either matches or fails.
+ *
+ * @param rule {@link org.apache.joshua.decoder.ff.tm.Rule} to be utilized within computation
+ * @param tailNodes {@link java.util.List} of {@link org.apache.joshua.decoder.hypergraph.HGNode} tail nodes
+ * @param i todo
+ * @param j todo
+ * @param sourcePath information about a path taken through the source {@link org.apache.joshua.lattice.Lattice}
+ * @param sentence {@link org.apache.joshua.lattice.Lattice} input
+ * @param acc {@link org.apache.joshua.decoder.ff.FeatureFunction.Accumulator} object permitting generalization of feature computation
+ * @return the new dynamic programming state (null for stateless features)
*/
@Override
public DPState compute(Rule rule, List<HGNode> tailNodes, int i, int j, SourcePath sourcePath,
@@ -321,8 +330,8 @@ public class FragmentLMFF extends StatefulFF {
/**
* Maintains a state pointer used by KenLM to implement left-state minimization.
*
- * @author Matt Post <po...@cs.jhu.edu>
- * @author Juri Ganitkevitch <ju...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
+ * @author Juri Ganitkevitch juri@cs.jhu.edu
*/
public class FragmentState extends DPState {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/Tree.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/Tree.java b/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/Tree.java
index 6214560..22fc160 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/Tree.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/Tree.java
@@ -38,7 +38,7 @@ import org.apache.joshua.util.io.LineReader;
* enclosed in double-quotes when read in.
*
* @author Dan Klein
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*/
public class Tree implements Serializable {
@@ -111,7 +111,7 @@ public class Tree implements Serializable {
/**
* Computes the depth-one rule rooted at this node. If the node has no children, null is returned.
*
- * @return
+ * @return string representation of the rule
*/
public String getRule() {
if (isLeaf()) {
@@ -237,6 +237,8 @@ public class Tree implements Serializable {
* A tree is lexicalized if it has terminal nodes among the leaves of its frontier. For normal
* trees this is always true since they bottom out in terminals, but for fragments, this may or
* may not be true.
+ *
+ * @return true if the tree is lexicalized
*/
public boolean isLexicalized() {
if (this.numLexicalItems < 0) {
@@ -313,7 +315,7 @@ public class Tree implements Serializable {
* Removes the quotes around terminals. Note that the resulting tree could not be read back
* in by this class, since unquoted leaves are interpreted as nonterminals.
*
- * @return
+ * @return unquoted string
*/
public String unquotedString() {
return toString().replaceAll("\"", "");
@@ -450,8 +452,8 @@ public class Tree implements Serializable {
* models. The arguments have to be passed in to preserve Java generics, even though this is only
* ever used with String versions.
*
- * @param sos presumably "<s>"
- * @param eos presumably "</s>"
+ * @param sos presumably "<s>"
+ * @param eos presumably "</s>"
*/
public void insertSentenceMarkers(String sos, String eos) {
insertSentenceMarker(sos, 0);
@@ -465,8 +467,8 @@ public class Tree implements Serializable {
/**
*
- * @param symbol
- * @param pos
+ * @param symbol the marker to insert
+ * @param pos the position at which to insert
*/
private void insertSentenceMarker(String symbol, int pos) {
@@ -487,6 +489,9 @@ public class Tree implements Serializable {
/**
* This is a convenience function for producing a fragment from its string representation.
+ *
+ * @param ptbStr input string from which to produce a fragment
+ * @return the fragment
*/
public static Tree fromString(String ptbStr) {
PennTreeReader reader = new PennTreeReader(new StringReader(ptbStr));
@@ -531,14 +536,13 @@ public class Tree implements Serializable {
* recursively visit the derivation state objects, following the route through the hypergraph
* defined by them.
*
- * This function is like the other buildTree() function, but that one simply follows the best
- * incoming hyperedge for each node.
+ * This function is like {@link org.apache.joshua.decoder.ff.fragmentlm.Tree#buildTree(DerivationState, int)},
+ * but that one simply follows the best incoming hyperedge for each node.
*
- * @param rule
- * @param tailNodes
- * @param derivation - should not be null
- * @param maxDepth
- * @return
+ * @param rule for which corresponding internal fragment can be used to initialize the tree
+ * @param derivationStates array of state objects
+ * @param maxDepth of route through the hypergraph
+ * @return the Tree
*/
public static Tree buildTree(Rule rule, DerivationState[] derivationStates, int maxDepth) {
Tree tree = getFragmentFromYield(rule.getEnglishWords());
@@ -603,19 +607,14 @@ public class Tree implements Serializable {
}
/**
- * Builds a tree from the kth-best derivation state. This is done by initializing the tree with
+ * <p>Builds a tree from the kth-best derivation state. This is done by initializing the tree with
* the internal fragment corresponding to the rule; this will be the top of the tree. We then
* recursively visit the derivation state objects, following the route through the hypergraph
- * defined by them.
- *
- * This function is like the other buildTree() function, but that one simply follows the best
- * incoming hyperedge for each node.
+ * defined by them.</p>
*
- * @param rule
- * @param tailNodes
- * @param derivation
- * @param maxDepth
- * @return
+ * @param derivationState array of state objects
+ * @param maxDepth of route through the hypergraph
+ * @return the Tree
*/
public static Tree buildTree(DerivationState derivationState, int maxDepth) {
Rule rule = derivationState.edge.getRule();
@@ -676,9 +675,10 @@ public class Tree implements Serializable {
* This could be implemented by using the other buildTree() function and using the 1-best
* DerivationState.
*
- * @param rule
- * @param tailNodes
- * @return
+ * @param rule {@link org.apache.joshua.decoder.ff.tm.Rule} to be used whilst building the tree
+ * @param tailNodes {@link java.util.List} of {@link org.apache.joshua.decoder.hypergraph.HGNode}'s
+ * @param maxDepth to go in the tree
+ * @return shallow clone of the Tree object
*/
public static Tree buildTree(Rule rule, List<HGNode> tailNodes, int maxDepth) {
Tree tree = getFragmentFromYield(rule.getEnglishWords());
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/Trees.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/Trees.java b/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/Trees.java
index 439ba96..d06388c 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/Trees.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/Trees.java
@@ -187,6 +187,9 @@ public class Trees {
* preterminals onto one line of tags and words. Additional complexities are that conjunctions
* (tag CC) are not collapsed in this way, and that the unlabeled outer brackets are collapsed
* onto the same line as the next bracket down.
+ *
+ * @param tree you wish to render and print
+ * @return a rendered String representation of the tree
*/
public static String render(Tree tree) {
StringBuilder sb = new StringBuilder();
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/lm/AbstractLM.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/lm/AbstractLM.java b/src/main/java/org/apache/joshua/decoder/ff/lm/AbstractLM.java
index 79560fd..e8225dc 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/lm/AbstractLM.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/lm/AbstractLM.java
@@ -18,11 +18,7 @@
*/
package org.apache.joshua.decoder.ff.lm;
-import org.apache.joshua.decoder.JoshuaConfiguration;
import org.apache.joshua.decoder.Support;
-import org.apache.joshua.corpus.SymbolTable;
-
-
import java.util.List;
/**
@@ -31,7 +27,7 @@ import java.util.List;
* methods are declared final, in an attempt to limit what subclasses
* may be defined.
*
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Zhifei Li, zhifei.work@gmail.com
* @version $LastChangedDate: 2009-12-30 10:10:38 -0600 (Wed, 30 Dec 2009) $
*/
public abstract class AbstractLM extends DefaultNGramLanguageModel {
@@ -40,7 +36,7 @@ public abstract class AbstractLM extends DefaultNGramLanguageModel {
super(symbolTable, order);
}
-
+ @SuppressWarnings("null")
public final double sentenceLogProbability(
List<Integer> sentence, int order, int startIndex
) {
@@ -48,12 +44,10 @@ public abstract class AbstractLM extends DefaultNGramLanguageModel {
return (Double) null;
}
-
public final float ngramLogProbability(int[] ngram) {
return super.ngramLogProbability(ngram);
}
-
public final float ngramLogProbability(int[] ngram, int order) {
if (ngram.length > order) {
throw new RuntimeException("ngram length is greather than the max order");
@@ -77,11 +71,6 @@ public abstract class AbstractLM extends DefaultNGramLanguageModel {
protected abstract float ngramLogProbability_helper(int[] ngram, int order);
-
- /**
- * @deprecated this function is much slower than the int[]
- * version
- */
@Deprecated
public final double logProbOfBackoffState(List<Integer> ngram, int order, int qtyAdditionalBackoffWeight) {
return logProbabilityOfBackoffState(
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/lm/DefaultNGramLanguageModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/lm/DefaultNGramLanguageModel.java b/src/main/java/org/apache/joshua/decoder/ff/lm/DefaultNGramLanguageModel.java
index 4ff8f59..759479f 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/lm/DefaultNGramLanguageModel.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/lm/DefaultNGramLanguageModel.java
@@ -27,12 +27,12 @@ import org.apache.joshua.corpus.Vocabulary;
/**
* This class provides a default implementation for the Equivalent LM State optimization (namely,
* don't back off anywhere). It also provides some default implementations for more general
- * functions on the interface to fall back to more specific ones (e.g. from ArrayList<Integer> to
- * int[]) and a default implementation for sentenceLogProbability which enumerates the n-grams and
- * calls calls ngramLogProbability for each of them.
+ * functions on the interface to fall back to more specific ones (e.g. from {@link java.util.ArrayList}
+ * of {@link java.lang.Integer}'s to int[]) and a default implementation for sentenceLogProbability
+ * which enumerates the n-grams and calls calls ngramLogProbability for each of them.
*
- * @author Zhifei Li, <zh...@gmail.com>
- * @author wren ng thornton <wr...@users.sourceforge.net>
+ * @author Zhifei Li, zhifei.work@gmail.com
+ * @author wren ng thornton wren@users.sourceforge.net
*/
public abstract class DefaultNGramLanguageModel implements NGramLanguageModel {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/lm/KenLM.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/lm/KenLM.java b/src/main/java/org/apache/joshua/decoder/ff/lm/KenLM.java
index 2c43712..2864e00 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/lm/KenLM.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/lm/KenLM.java
@@ -29,7 +29,7 @@ import org.apache.joshua.decoder.ff.state_maintenance.KenLMState;
* state by itself and just passes in the ngrams for scoring.
*
* @author Kenneth Heafield
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*/
public class KenLM implements NGramLanguageModel, Comparable<KenLM> {
@@ -115,6 +115,8 @@ public class KenLM implements NGramLanguageModel, Comparable<KenLM> {
/**
* Query for n-gram probability using strings.
+ * @param words a string array of words
+ * @return float value denoting probability
*/
public float prob(String[] words) {
return probForString(pointer, words);
@@ -127,14 +129,15 @@ public class KenLM implements NGramLanguageModel, Comparable<KenLM> {
/**
* This function is the bridge to the interface in kenlm/lm/left.hh, which has KenLM score the
- * whole rule. It takes a list of words and states retrieved from tail nodes (nonterminals in the
+ * whole rule. It takes an array of words and states retrieved from tail nodes (nonterminals in the
* rule). Nonterminals have a negative value so KenLM can distinguish them. The sentence number is
* needed so KenLM knows which memory pool to use. When finished, it returns the updated KenLM
* state and the LM probability incurred along this rule.
*
- * @param words
- * @param sentId
- * @return
+ * @param words array of words
+ * @param poolPointer todo
+ * @return the updated {@link org.apache.joshua.decoder.ff.lm.KenLM.StateProbPair} e.g.
+ * KenLM state and the LM probability incurred along this rule
*/
public StateProbPair probRule(long[] words, long poolPointer) {
@@ -153,7 +156,7 @@ public class KenLM implements NGramLanguageModel, Comparable<KenLM> {
* Public facing function that estimates the cost of a rule, which value is used for sorting
* rules during cube pruning.
*
- * @param words
+ * @param words array of words
* @return the estimated cost of the rule (the (partial) n-gram probabilities of all words in the rule)
*/
public float estimateRule(long[] words) {
@@ -170,6 +173,7 @@ public class KenLM implements NGramLanguageModel, Comparable<KenLM> {
/**
* The start symbol for a KenLM is the Vocabulary.START_SYM.
+ * @return "<s>"
*/
public String getStartSymbol() {
return Vocabulary.START_SYM;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/lm/LanguageModelFF.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/lm/LanguageModelFF.java b/src/main/java/org/apache/joshua/decoder/ff/lm/LanguageModelFF.java
index f2daffd..ad05a37 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/lm/LanguageModelFF.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/lm/LanguageModelFF.java
@@ -45,14 +45,14 @@ import org.apache.joshua.decoder.segment_file.Sentence;
* This class performs the following:
* <ol>
* <li>Gets the additional LM score due to combinations of small items into larger ones by using
- * rules
- * <li>Gets the LM state
- * <li>Gets the left-side LM state estimation score
+ * rules</li>
+ * <li>Gets the LM state</li>
+ * <li>Gets the left-side LM state estimation score</li>
* </ol>
*
- * @author Matt Post <po...@cs.jhu.edu>
- * @author Juri Ganitkevitch <ju...@cs.jhu.edu>
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Matt Post post@cs.jhu.edu
+ * @author Juri Ganitkevitch juri@cs.jhu.edu
+ * @author Zhifei Li, zhifei.work@gmail.com
*/
public class LanguageModelFF extends StatefulFF {
@@ -65,13 +65,14 @@ public class LanguageModelFF extends StatefulFF {
* <ol>
* <li>We assume it is a backoff lm, and high-order ngram implies low-order ngram; absense of
* low-order ngram implies high-order ngram</li>
- * <li>For a ngram, existence of backoffweight => existence a probability Two ways of dealing with
+ * <li>For a ngram, existence of backoffweight => existence a probability Two ways of dealing with
* low counts:
* <ul>
* <li>SRILM: don't multiply zeros in for unknown words</li>
* <li>Pharaoh: cap at a minimum score exp(-10), including unknown words</li>
* </ul>
* </li>
+ * </ol>
*/
protected NGramLanguageModel languageModel;
@@ -160,10 +161,6 @@ public class LanguageModelFF extends StatefulFF {
/**
* Initializes the underlying language model.
- *
- * @param config
- * @param type
- * @param path
*/
protected void initializeLM() {
if (type.equals("kenlm")) {
@@ -265,7 +262,7 @@ public class LanguageModelFF extends StatefulFF {
/**
* Sets the class map if this is a class LM
- * @param classMap
+ * @param fileName
* @throws IOException
*/
public void setClassMap(String fileName) throws IOException {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/lm/NGramLanguageModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/lm/NGramLanguageModel.java b/src/main/java/org/apache/joshua/decoder/ff/lm/NGramLanguageModel.java
index 4043171..882424b 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/lm/NGramLanguageModel.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/lm/NGramLanguageModel.java
@@ -22,10 +22,10 @@ package org.apache.joshua.decoder.ff.lm;
* An interface for new language models to implement. An object of this type is passed to
* LanguageModelFF, which will handle all the dynamic programming and state maintenance.
*
- * @author wren ng thornton <wr...@users.sourceforge.net>
- * @author Zhifei Li, <zh...@gmail.com>
- * @author Matt Post <po...@cs.jhu.edu>
- * @author Juri Ganitkevitch <ju...@cs.jhu.edu>
+ * @author wren ng thornton wren@users.sourceforge.net
+ * @author Zhifei Li, zhifei.work@gmail.com
+ * @author Matt Post post@cs.jhu.edu
+ * @author Juri Ganitkevitch juri@cs.jhu.edu
*/
public interface NGramLanguageModel {
@@ -41,12 +41,12 @@ public interface NGramLanguageModel {
/**
* Language models may have their own private vocabulary mapping strings to integers; for example,
* if they make use of a compile format (as KenLM and BerkeleyLM do). This mapping is likely
- * different from the global mapping containing in joshua.corpus.Vocabulary, which is used to
+ * different from the global mapping containing in {@link org.apache.joshua.corpus.Vocabulary}, which is used to
* convert the input string and grammars. This function is used to tell the language model what
* the global mapping is, so that the language model can convert it into its own private mapping.
*
- * @param word
- * @param id
+ * @param token string token to be registered
+ * @param id to associate with this word
* @return Whether any collisions were detected.
*/
boolean registerWord(String token, int id);
@@ -63,9 +63,9 @@ public interface NGramLanguageModel {
/**
* Compute the probability of a single word given its context.
*
- * @param ngram
- * @param order
- * @return
+ * @param ngram the NGram for which we wish to compute the probability
+ * @param order NGram order/context
+ * @return float representing the probability
*/
float ngramLogProbability(int[] ngram, int order);
[2/3] incubator-joshua git commit: JOSHUA-252 Make it possible to use
Maven to build Joshua
Posted by le...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/lm/StateMinimizingLanguageModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/lm/StateMinimizingLanguageModel.java b/src/main/java/org/apache/joshua/decoder/ff/lm/StateMinimizingLanguageModel.java
index b3f6eca..f0e0f03 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/lm/StateMinimizingLanguageModel.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/lm/StateMinimizingLanguageModel.java
@@ -37,8 +37,8 @@ import org.apache.joshua.decoder.segment_file.Sentence;
/**
* Wrapper for KenLM LMs with left-state minimization. We inherit from the regular
*
- * @author Matt Post <po...@cs.jhu.edu>
- * @author Juri Ganitkevitch <ju...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
+ * @author Juri Ganitkevitch juri@cs.jhu.edu
*/
public class StateMinimizingLanguageModel extends LanguageModelFF {
@@ -66,10 +66,6 @@ public class StateMinimizingLanguageModel extends LanguageModelFF {
/**
* Initializes the underlying language model.
- *
- * @param config
- * @param type
- * @param path
*/
@Override
public void initializeLM() {
@@ -162,10 +158,10 @@ public class StateMinimizingLanguageModel extends LanguageModelFF {
/**
* Destroys the pool created to allocate state for this sentence. Called from the
- * {@link joshua.decoder.Translation} class after outputting the sentence or k-best list. Hosting
+ * {@link org.apache.joshua.decoder.Translation} class after outputting the sentence or k-best list. Hosting
* this map here in KenLMFF statically allows pools to be shared across KenLM instances.
*
- * @param sentId
+ * @param sentId a key in the poolmap table to destroy
*/
public void destroyPool(int sentId) {
if (poolMap.containsKey(sentId))
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/lm/bloomfilter_lm/BloomFilterLanguageModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/lm/bloomfilter_lm/BloomFilterLanguageModel.java b/src/main/java/org/apache/joshua/decoder/ff/lm/bloomfilter_lm/BloomFilterLanguageModel.java
index 21dd819..958ea16 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/lm/bloomfilter_lm/BloomFilterLanguageModel.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/lm/bloomfilter_lm/BloomFilterLanguageModel.java
@@ -115,6 +115,7 @@ public class BloomFilterLanguageModel extends DefaultNGramLanguageModel implemen
*
* @param order the order of the language model
* @param filename path to the file where the language model is stored
+ * @throws IOException if the bloom filter language model cannot be rebuilt from the input file
*/
public BloomFilterLanguageModel(int order, String filename) throws IOException {
super(order);
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/lm/buildin_lm/TrieLM.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/lm/buildin_lm/TrieLM.java b/src/main/java/org/apache/joshua/decoder/ff/lm/buildin_lm/TrieLM.java
index 654561c..8a7e786 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/lm/buildin_lm/TrieLM.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/lm/buildin_lm/TrieLM.java
@@ -30,9 +30,7 @@ import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.apache.joshua.corpus.SymbolTable;
import org.apache.joshua.corpus.Vocabulary;
-import org.apache.joshua.decoder.JoshuaConfiguration;
import org.apache.joshua.decoder.ff.lm.AbstractLM;
import org.apache.joshua.decoder.ff.lm.ArpaFile;
import org.apache.joshua.decoder.ff.lm.ArpaNgram;
@@ -94,8 +92,8 @@ public class TrieLM extends AbstractLM { //DefaultNGramLanguageModel {
/**
* Constructs a language model object from the specified ARPA file.
*
- * @param arpaFile
- * @throws FileNotFoundException
+ * @param arpaFile input ARPA file
+ * @throws FileNotFoundException if the input file cannot be located
*/
public TrieLM(ArpaFile arpaFile) throws FileNotFoundException {
super(arpaFile.getVocab().size(), arpaFile.getOrder());
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/state_maintenance/DPState.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/state_maintenance/DPState.java b/src/main/java/org/apache/joshua/decoder/ff/state_maintenance/DPState.java
index bfc7533..e117fde 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/state_maintenance/DPState.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/state_maintenance/DPState.java
@@ -21,8 +21,8 @@ package org.apache.joshua.decoder.ff.state_maintenance;
/**
* Abstract class enforcing explicit implementation of the standard methods.
*
- * @author Zhifei Li, <zh...@gmail.com>
- * @author Juri Ganitkevitch, <ju...@cs.jhu.edu>
+ * @author Zhifei Li, zhifei.work@gmail.com
+ * @author Juri Ganitkevitch, juri@cs.jhu.edu
*/
public abstract class DPState {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/state_maintenance/KenLMState.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/state_maintenance/KenLMState.java b/src/main/java/org/apache/joshua/decoder/ff/state_maintenance/KenLMState.java
index d352383..4fdc631 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/state_maintenance/KenLMState.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/state_maintenance/KenLMState.java
@@ -21,8 +21,8 @@ package org.apache.joshua.decoder.ff.state_maintenance;
/**
* Maintains a state pointer used by KenLM to implement left-state minimization.
*
- * @author Matt Post <po...@cs.jhu.edu>
- * @author Juri Ganitkevitch <ju...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
+ * @author Juri Ganitkevitch juri@cs.jhu.edu
*/
public class KenLMState extends DPState {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/state_maintenance/NgramDPState.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/state_maintenance/NgramDPState.java b/src/main/java/org/apache/joshua/decoder/ff/state_maintenance/NgramDPState.java
index bf6e0a5..b269bd9 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/state_maintenance/NgramDPState.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/state_maintenance/NgramDPState.java
@@ -23,8 +23,8 @@ import java.util.Arrays;
import org.apache.joshua.corpus.Vocabulary;
/**
- * @author Zhifei Li, <zh...@gmail.com>
- * @author Juri Ganitkevitch, <ju...@cs.jhu.edu>
+ * @author Zhifei Li, zhifei.work@gmail.com
+ * @author Juri Ganitkevitch, juri@cs.jhu.edu
*/
public class NgramDPState extends DPState {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/AbstractGrammar.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/AbstractGrammar.java b/src/main/java/org/apache/joshua/decoder/ff/tm/AbstractGrammar.java
index 188c2a9..a4ea2f5 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/AbstractGrammar.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/AbstractGrammar.java
@@ -44,7 +44,7 @@ import cern.colt.Arrays;
*
* @author Zhifei Li
* @author Lane Schwartz
- * @author Matt Post <post@cs.jhu.edu
+ * @author Matt Post post@cs.jhu.edu
*/
public abstract class AbstractGrammar implements Grammar {
@@ -92,6 +92,7 @@ public abstract class AbstractGrammar implements Grammar {
* Constructs an empty, unsorted grammar.
*
* @see Grammar#isSorted()
+ * @param config a {@link org.apache.joshua.decoder.JoshuaConfiguration} object
*/
public AbstractGrammar(JoshuaConfiguration config) {
this.joshuaConfiguration = config;
@@ -110,6 +111,7 @@ public abstract class AbstractGrammar implements Grammar {
* Cube-pruning requires that the grammar be sorted based on the latest feature functions. To
* avoid synchronization, this method should be called before multiple threads are initialized for
* parallel decoding
+ * @param models {@link java.util.List} of {@link org.apache.joshua.decoder.ff.FeatureFunction}'s
*/
public void sortGrammar(List<FeatureFunction> models) {
Trie root = getTrieRoot();
@@ -127,13 +129,13 @@ public abstract class AbstractGrammar implements Grammar {
/**
* Sets the flag indicating whether this grammar is sorted.
* <p>
- * This method is called by {@link #sortGrammar(ArrayList)} to indicate that the grammar has been
- * sorted.
+ * This method is called by {@link org.apache.joshua.decoder.ff.tm.AbstractGrammar#sortGrammar(List)}
+ * to indicate that the grammar has been sorted.</p>
*
- * Its scope is protected so that child classes that override <code>sortGrammar</code> will also
- * be able to call this method to indicate that the grammar has been sorted.
+ * <p>Its scope is protected so that child classes that override <code>sortGrammar</code> will also
+ * be able to call this method to indicate that the grammar has been sorted.</p>
*
- * @param sorted
+ * @param sorted set to true if the grammar is sorted
*/
protected void setSorted(boolean sorted) {
this.sorted = sorted;
@@ -190,8 +192,10 @@ public abstract class AbstractGrammar implements Grammar {
* Adds OOV rules for all words in the input lattice to the current grammar. Uses addOOVRule() so that
* sub-grammars can define different types of OOV rules if needed (as is used in {@link PhraseTable}).
*
+ * @param grammar Grammar in the Trie
* @param inputLattice the lattice representing the input sentence
* @param featureFunctions a list of feature functions used for scoring
+ * @param onlyTrue determine if word is actual OOV.
*/
public static void addOOVRules(Grammar grammar, Lattice<Token> inputLattice,
List<FeatureFunction> featureFunctions, boolean onlyTrue) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/BilingualRule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/BilingualRule.java b/src/main/java/org/apache/joshua/decoder/ff/tm/BilingualRule.java
index 6e35e2d..b2299ba 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/BilingualRule.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/BilingualRule.java
@@ -28,7 +28,7 @@ import org.apache.joshua.corpus.SymbolTable;
* Normally, the feature score in the rule should be *cost* (i.e.,
* -LogP), so that the feature weight should be positive
*
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Zhifei Li, zhifei.work@gmail.com
* @version $LastChangedDate: 2010-01-20 19:46:54 -0600 (Wed, 20 Jan 2010) $
*/
public class BilingualRule extends MonolingualRule {
@@ -49,9 +49,9 @@ public class BilingualRule extends MonolingualRule {
* @param featureScores Feature value scores for the rule.
* @param arity Number of nonterminals in the source language
* right-hand side.
- * @param owner
- * @param latticeCost
- * @param ruleID
+ * @param owner todo
+ * @param latticeCost todo
+ * @param ruleID todo
*/
public BilingualRule(int lhs, int[] sourceRhs, int[] targetRhs, float[] featureScores, int arity, int owner, float latticeCost, int ruleID) {
super(lhs, sourceRhs, featureScores, arity, owner, latticeCost, ruleID);
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/Grammar.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/Grammar.java b/src/main/java/org/apache/joshua/decoder/ff/tm/Grammar.java
index 57ec0a2..9748ba0 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/Grammar.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/Grammar.java
@@ -25,8 +25,8 @@ import org.apache.joshua.decoder.ff.FeatureFunction;
/**
* Grammar is a class for wrapping a trie of TrieGrammar in order to store holistic metadata.
*
- * @author wren ng thornton <wr...@users.sourceforge.net>
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author wren ng thornton wren@users.sourceforge.net
+ * @author Zhifei Li, zhifei.work@gmail.com
*/
public interface Grammar {
@@ -45,7 +45,7 @@ public interface Grammar {
* <p>
* Cube-pruning requires that the grammar be sorted based on the latest feature functions.
*
- * @param weights The model weights.
+ * @param models list of {@link org.apache.joshua.decoder.ff.FeatureFunction}'s
*/
void sortGrammar(List<FeatureFunction> models);
@@ -73,6 +73,7 @@ public interface Grammar {
* @param pathLength Length of the input path in a source input lattice. If a source input phrase
* is used instead of a lattice, this value will likely be ignored by the underlying
* implementation, but would normally be defined as <code>endIndex-startIndex</code>
+ * @return true if there is a rule for this span
*/
boolean hasRuleForSpan(int startIndex, int endIndex, int pathLength);
@@ -93,6 +94,12 @@ public interface Grammar {
/**
* This is used to construct a manual rule supported from outside the grammar, but the owner
* should be the same as the grammar. Rule ID will the same as OOVRuleId, and no lattice cost
+ * @param lhs todo
+ * @param sourceWords todo
+ * @param targetWords todo
+ * @param scores todo
+ * @param arity todo
+ * @return the constructed {@link org.apache.joshua.decoder.ff.tm.Rule}
*/
@Deprecated
Rule constructManualRule(int lhs, int[] sourceWords, int[] targetWords, float[] scores, int arity);
@@ -100,7 +107,7 @@ public interface Grammar {
/**
* Dump the grammar to disk.
*
- * @param file
+ * @param file the file path to write to
*/
@Deprecated
void writeGrammarOnDisk(String file);
@@ -115,26 +122,28 @@ public interface Grammar {
/**
* Return the grammar's owner.
+ * @return grammar owner
*/
int getOwner();
/**
- * Return the maximum source phrase length (terminals + nonterminals).
+ * Return the maximum source phrase length (terminals + nonterminals)
+ * @return the maximum source phrase length
*/
int getMaxSourcePhraseLength();
/**
* Add an OOV rule for the requested word for the grammar.
*
- * @param word
- * @param featureFunctions
+ * @param word input word to add rules to
+ * @param featureFunctions a {@link java.util.List} of {@link org.apache.joshua.decoder.ff.FeatureFunction}'s
*/
void addOOVRules(int word, List<FeatureFunction> featureFunctions);
/**
* Add a rule to the grammar.
*
- * @param Rule the rule
+ * @param rule the {@link org.apache.joshua.decoder.ff.tm.Rule}
*/
void addRule(Rule rule);
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/GrammarReader.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/GrammarReader.java b/src/main/java/org/apache/joshua/decoder/ff/tm/GrammarReader.java
index e340a85..5fc2576 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/GrammarReader.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/GrammarReader.java
@@ -97,7 +97,7 @@ public abstract class GrammarReader<R extends Rule> implements Iterable<R>, Iter
* For correct behavior <code>close</code> must be called on every GrammarReader, however this
* code attempts to avoid resource leaks.
*
- * @see joshua.util.io.LineReader
+ * @see org.apache.joshua.util.io.LineReader
*/
@Override
protected void finalize() throws Throwable {
@@ -173,7 +173,7 @@ public abstract class GrammarReader<R extends Rule> implements Iterable<R>, Iter
/**
* Removes square brackets (and index, if present) from nonterminal id
- * @param tokenID
+ * @param tokenID the int ID to clean
* @return cleaned ID
*/
public static int cleanNonTerminal(int tokenID) {
@@ -183,7 +183,7 @@ public abstract class GrammarReader<R extends Rule> implements Iterable<R>, Iter
/**
* Removes square brackets (and index, if present) from nonterminal id
- * @param token
+ * @param token the string ID to clean
* @return cleaned token
*/
public static String cleanNonTerminal(String token) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/MonolingualRule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/MonolingualRule.java b/src/main/java/org/apache/joshua/decoder/ff/tm/MonolingualRule.java
index 812e669..e3aa999 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/MonolingualRule.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/MonolingualRule.java
@@ -29,7 +29,7 @@ import org.apache.joshua.decoder.ff.FeatureFunction;
/**
* this class implements MonolingualRule
*
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Zhifei Li, zhifei.work@gmail.com
* @version $LastChangedDate: 2010-02-10 09:59:38 -0600 (Wed, 10 Feb 2010) $
*/
public class MonolingualRule extends Rule {
@@ -90,9 +90,9 @@ public class MonolingualRule extends Rule {
* @param featureScores Feature value scores for the rule.
* @param arity Number of nonterminals in the source language
* right-hand side.
- * @param owner
- * @param latticeCost
- * @param ruleID
+ * @param owner todo
+ * @param latticeCost todo
+ * @param ruleID todo
*/
public MonolingualRule(int lhs, int[] sourceRhs, float[] featureScores, int arity, int owner, float latticeCost, int ruleID) {
this.lhs = lhs;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/PhraseRule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/PhraseRule.java b/src/main/java/org/apache/joshua/decoder/ff/tm/PhraseRule.java
index 1b8b871..f9097f8 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/PhraseRule.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/PhraseRule.java
@@ -22,17 +22,17 @@ import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
/***
- * A class for reading in rules from a Moses phrase table. Most of the conversion work is done
- * in {@link joshua.decoder.ff.tm.format.PhraseFormatReader}. This includes prepending every
+ * <p>A class for reading in rules from a Moses phrase table. Most of the conversion work is done
+ * in {@link org.apache.joshua.decoder.ff.tm.format.PhraseFormatReader}. This includes prepending every
* rule with a nonterminal, so that the phrase-based decoder can assume the same hypergraph
* format as the hierarchical decoder (by pretending to be a strictly left-branching grammar and
* dispensing with the notion of coverage spans). However, prepending the nonterminals means all
* the alignments are off by 1. We do not want to fix those when reading in due to the expense,
- * so instead we use this rule which adjust the alignments on the fly.
+ * so instead we use this rule which adjust the alignments on the fly.</p>
*
- * Also, we only convert the Moses dense features on the fly, via this class.
+ * <p>Also, we only convert the Moses dense features on the fly, via this class.</p>
*
- * TODO: this class should also be responsible for prepending the nonterminals.
+ * <p>TODO: this class should also be responsible for prepending the nonterminals.</p>
*
* @author Matt Post
*
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/Rule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/Rule.java b/src/main/java/org/apache/joshua/decoder/ff/tm/Rule.java
index 06d4153..4db3972 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/Rule.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/Rule.java
@@ -42,16 +42,11 @@ import org.apache.joshua.decoder.segment_file.Sentence;
* Note that not all features need to be negative log probs, but you should be aware that they
* will be negated, so if you want a positive count, it should come in as negative.
*
- * @author Zhifei Li, <zh...@gmail.com>
- */
-
-
-/**
* Normally, the feature score in the rule should be *cost* (i.e., -LogP), so that the feature
* weight should be positive
*
- * @author Zhifei Li, <zh...@gmail.com>
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Zhifei Li, zhifei.work@gmail.com
+ * @author Matt Post post@cs.jhu.edu
*/
public class Rule implements Comparator<Rule>, Comparable<Rule> {
@@ -100,7 +95,7 @@ public class Rule implements Comparator<Rule>, Comparable<Rule> {
* @param targetRhs Target language right-hand side of the rule.
* @param sparseFeatures Feature value scores for the rule.
* @param arity Number of nonterminals in the source language right-hand side.
- * @param owner
+ * @param owner todo
*/
public Rule(int lhs, int[] sourceRhs, int[] targetRhs, String sparseFeatures, int arity, int owner) {
this.lhs = lhs;
@@ -114,7 +109,13 @@ public class Rule implements Comparator<Rule>, Comparable<Rule> {
}
/**
- * Constructor used by PackedGrammar's sortRules().
+ * Constructor used by PackedGrammar's sortRules()
+ * @param lhs todo
+ * @param sourceRhs todo
+ * @param targetRhs todo
+ * @param features todo
+ * @param arity todo
+ * @param owner todo
*/
public Rule(int lhs, int[] sourceRhs, int[] targetRhs, FeatureVector features, int arity, int owner) {
this.lhs = lhs;
@@ -130,6 +131,11 @@ public class Rule implements Comparator<Rule>, Comparable<Rule> {
/**
* Constructor used for SamtFormatReader and GrammarBuilderWalkerFunction's getRuleWithSpans()
* Owner set to -1
+ * @param lhs todo
+ * @param sourceRhs todo
+ * @param targetRhs todo
+ * @param sparseFeatures todo
+ * @param arity todo
*/
public Rule(int lhs, int[] sourceRhs, int[] targetRhs, String sparseFeatures, int arity) {
this(lhs, sourceRhs, targetRhs, sparseFeatures, arity, -1);
@@ -137,6 +143,12 @@ public class Rule implements Comparator<Rule>, Comparable<Rule> {
/**
* Constructor used for addOOVRules(), HieroFormatReader and PhraseRule.
+ * @param lhs todo
+ * @param sourceRhs todo
+ * @param targetRhs todo
+ * @param sparseFeatures todo
+ * @param arity todo
+ * @param alignment todo
*/
public Rule(int lhs, int[] sourceRhs, int[] targetRhs, String sparseFeatures, int arity, String alignment) {
this(lhs, sourceRhs, targetRhs, sparseFeatures, arity);
@@ -283,6 +295,8 @@ public class Rule implements Comparator<Rule>, Comparable<Rule> {
* This function returns the dense (phrasal) features discovered when the rule was loaded. Dense
* features are the list of unlabeled features that preceded labeled ones. They can also be
* specified as labeled features of the form "tm_OWNER_INDEX", but the former format is preferred.
+ *
+ * @return the {@link org.apache.joshua.decoder.ff.FeatureVector} for this rule
*/
public FeatureVector getFeatureVector() {
return featuresSupplier.get();
@@ -389,7 +403,7 @@ public class Rule implements Comparator<Rule>, Comparable<Rule> {
/**
* Returns a version of the rule suitable for reading in from a text file.
*
- * @return
+ * @return string version of the rule
*/
public String textFormat() {
StringBuffer sb = new StringBuffer();
@@ -425,6 +439,8 @@ public class Rule implements Comparator<Rule>, Comparable<Rule> {
/**
* Returns an alignment as a sequence of integers. The integers at positions i and i+1 are paired,
* with position i indexing the source and i+1 the target.
+ *
+ * @return a byte[] from the {@link com.google.common.base.Supplier}
*/
public byte[] getAlignment() {
return this.alignmentSupplier.get();
@@ -468,7 +484,7 @@ public class Rule implements Comparator<Rule>, Comparable<Rule> {
/**
* Return the French (source) nonterminals as list of Strings
*
- * @return
+ * @return a list of strings
*/
public int[] getForeignNonTerminals() {
int[] nts = new int[getArity()];
@@ -481,6 +497,8 @@ public class Rule implements Comparator<Rule>, Comparable<Rule> {
/**
* Returns an array of size getArity() containing the source indeces of non terminals.
+ *
+ * @return an array of size getArity() containing the source indeces of non terminals
*/
public int[] getNonTerminalSourcePositions() {
int[] nonTerminalPositions = new int[getArity()];
@@ -495,6 +513,8 @@ public class Rule implements Comparator<Rule>, Comparable<Rule> {
/**
* Parses the Alignment byte[] into a Map from target to (possibly a list of) source positions.
* Used by the WordAlignmentExtractor.
+ *
+ * @return a {@link java.util.Map} of alignments
*/
public Map<Integer, List<Integer>> getAlignmentMap() {
byte[] alignmentArray = getAlignment();
@@ -515,7 +535,7 @@ public class Rule implements Comparator<Rule>, Comparable<Rule> {
/**
* Return the English (target) nonterminals as list of Strings
*
- * @return
+ * @return list of strings
*/
public int[] getEnglishNonTerminals() {
int[] nts = new int[getArity()];
@@ -570,8 +590,8 @@ public class Rule implements Comparator<Rule>, Comparable<Rule> {
/**
* Matches the string representation of the rule's source side against a sentence
*
- * @param sentence
- * @return
+ * @param sentence {@link org.apache.joshua.lattice.Lattice} input
+ * @return true if there is a match
*/
public boolean matches(Sentence sentence) {
boolean match = getPattern().matcher(sentence.fullSource()).find();
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/RuleCollection.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/RuleCollection.java b/src/main/java/org/apache/joshua/decoder/ff/tm/RuleCollection.java
index f527878..a45c41b 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/RuleCollection.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/RuleCollection.java
@@ -29,7 +29,7 @@ import org.apache.joshua.decoder.ff.FeatureFunction;
*
* @author Zhifei Li
* @author Lane Schwartz
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*/
public interface RuleCollection {
@@ -37,18 +37,22 @@ public interface RuleCollection {
* Returns true if the rules are sorted. This is used to allow rules to be sorted in an amortized
* fashion; rather than sorting all trie nodes when the grammar is originally loaded, we sort them
* only as the decoder actually needs them.
+ * @return true if rules are sorted
*/
boolean isSorted();
/**
- * This returns a list of the rules, sorting them if necessary.
+ * This returns a list of the rules, sorting them if necessary.
*
- * Implementations of this function should be synchronized.
+ * Implementations of this function should be synchronized.
+ * @param models {@link java.util.List} of {@link org.apache.joshua.decoder.ff.FeatureFunction}'s
+ * @return the {@link java.util.List} of sorted rules
*/
List<Rule> getSortedRules(List<FeatureFunction> models);
/**
* Get the list of rules. There are no guarantees about whether they're sorted or not.
+ * @return the {@link java.util.List} of rules, there is no gurantee they will be sorted
*/
List<Rule> getRules();
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/SentenceFilteredGrammar.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/SentenceFilteredGrammar.java b/src/main/java/org/apache/joshua/decoder/ff/tm/SentenceFilteredGrammar.java
index 0d1875b..ce04e15 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/SentenceFilteredGrammar.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/SentenceFilteredGrammar.java
@@ -32,7 +32,7 @@ import org.apache.joshua.decoder.segment_file.Sentence;
* trie, a subset of the original trie, that only contains trie paths that are reachable from
* traversals of the current sentence.
*
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*/
public class SentenceFilteredGrammar extends MemoryBasedBatchGrammar {
private AbstractGrammar baseGrammar;
@@ -44,8 +44,8 @@ public class SentenceFilteredGrammar extends MemoryBasedBatchGrammar {
* Construct a new sentence-filtered grammar. The main work is done in the enclosed trie (obtained
* from the base grammar, which contains the complete grammar).
*
- * @param baseGrammar
- * @param sentence
+ * @param baseGrammar a new {@link org.apache.joshua.decoder.ff.tm.AbstractGrammar} to populate
+ * @param sentence {@link org.apache.joshua.lattice.Lattice} input
*/
SentenceFilteredGrammar(AbstractGrammar baseGrammar, Sentence sentence) {
super(baseGrammar.joshuaConfiguration);
@@ -90,8 +90,8 @@ public class SentenceFilteredGrammar extends MemoryBasedBatchGrammar {
/**
* A convenience function that counts the number of rules in a grammar's trie.
*
- * @param node
- * @return
+ * @param node the {@link org.apache.joshua.decoder.ff.tm.Trie} implementation for which to count rules
+ * @return the number of rules
*/
public int getNumRules(Trie node) {
int numRules = 0;
@@ -144,6 +144,7 @@ public class SentenceFilteredGrammar extends MemoryBasedBatchGrammar {
* subsequent ones would have to consume just one word. We then just have to record in the
* recursive call whether the last traversal was a nonterminal or not.
*
+ * @param unfilteredTrieRoot todo
* @return the root of the filtered trie
*/
private SentenceFilteredTrie filter(Trie unfilteredTrieRoot) {
@@ -246,6 +247,7 @@ public class SentenceFilteredGrammar extends MemoryBasedBatchGrammar {
* source side of each rule collection against the input sentence. Failed matches are discarded,
* and trie nodes extending from that position need not be explored.
*
+ * @param unfilteredTrie todo
* @return the root of the filtered trie if any rules were retained, otherwise null
*/
@SuppressWarnings("unused")
@@ -283,7 +285,7 @@ public class SentenceFilteredGrammar extends MemoryBasedBatchGrammar {
* Implements a filtered trie, by sitting on top of a base trie and annotating nodes that match
* the given input sentence.
*
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*
*/
public class SentenceFilteredTrie implements Trie {
@@ -297,8 +299,7 @@ public class SentenceFilteredGrammar extends MemoryBasedBatchGrammar {
/**
* Constructor.
*
- * @param trieRoot
- * @param source
+ * @param unfilteredTrieNode todo
*/
public SentenceFilteredTrie(Trie unfilteredTrieNode) {
this.unfilteredTrieNode = unfilteredTrieNode;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/Trie.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/Trie.java b/src/main/java/org/apache/joshua/decoder/ff/tm/Trie.java
index d2c54d9..51d2dd8 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/Trie.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/Trie.java
@@ -25,15 +25,15 @@ import java.util.Iterator;
/**
* An interface for trie-like data structures.
*
- * @author wren ng thornton <wr...@users.sourceforge.net>
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author wren ng thornton wren@users.sourceforge.net
+ * @author Zhifei Li, zhifei.work@gmail.com
*/
public interface Trie {
/**
* Traverse one ply further down the trie. If there is no match, the result is null.
*
- * @param wordID
+ * @param wordID input word ID
* @return Child node of this trie
*/
Trie match(int wordID);
@@ -53,30 +53,30 @@ public interface Trie {
* null.
*
* @return A list of extended <code>Trie</code> nodes if this node has extensions,
- * <code>null<code>
+ * <code>null</code>
* otherwise
*/
Collection<? extends Trie> getExtensions();
/**
- * If the trie node has extensions, get a list of their labels.
+ * If the trie node has extensions, get a {@link java.util.HashMap} of their labels.
*
- * @return
+ * @return a {@link java.util.HashMap} pf node extensions
*/
HashMap<Integer,? extends Trie> getChildren();
/**
* Returns an iterator over the trie node's extensions with terminal labels.
*
- * @return
+ * @return the {@link java.util.Iterator} created over the trie node's extensions with terminal labels
*/
Iterator<Integer> getTerminalExtensionIterator();
/**
* Returns an iterator over the trie node's extensions with nonterminal labels.
*
- * @return
+ * @return the {@link java.util.Iterator} created over the trie node's extensions with terminal labels
*/
Iterator<Integer> getNonterminalExtensionIterator();
@@ -100,6 +100,8 @@ public interface Trie {
* true.</li>
* <li>The collection must be sorted (at least as used by TMGrammar)</li>
* </ol>
+ * @return a {@link org.apache.joshua.decoder.ff.tm.RuleCollection} representing the rules
+ * at the current node/state
*/
RuleCollection getRuleCollection();
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/format/HieroFormatReader.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/format/HieroFormatReader.java b/src/main/java/org/apache/joshua/decoder/ff/tm/format/HieroFormatReader.java
index a9507ad..04a206a 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/format/HieroFormatReader.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/format/HieroFormatReader.java
@@ -25,8 +25,7 @@ import org.apache.joshua.decoder.ff.tm.Rule;
/**
* This class implements reading files in the format defined by David Chiang for Hiero.
*
- * @author Unknown
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*/
public class HieroFormatReader extends GrammarReader<Rule> {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/format/PhraseFormatReader.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/format/PhraseFormatReader.java b/src/main/java/org/apache/joshua/decoder/ff/tm/format/PhraseFormatReader.java
index 4d37803..870683a 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/format/PhraseFormatReader.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/format/PhraseFormatReader.java
@@ -23,17 +23,17 @@ import org.apache.joshua.decoder.ff.tm.PhraseRule;
import org.apache.joshua.util.io.LineReader;
/***
- * This class reads in the Moses phrase table format, with support for the source and target side,
+ * <p>This class reads in the Moses phrase table format, with support for the source and target side,
* list of features, and word alignments. It works by simply casting the phrase-based rules to
- * left-branching hierarchical rules and passing them on to its parent class, {@HieroFormatReader}.
+ * left-branching hierarchical rules and passing them on to its parent class, {@link org.apache.joshua.decoder.ff.tm.format.HieroFormatReader}.</p>
*
- * There is also a tool to convert the grammars directly, so that they can be suitably packed. Usage:
+ * <p>There is also a tool to convert the grammars directly, so that they can be suitably packed. Usage:</p>
*
* <pre>
- * cat PHRASE_TABLE | java -cp $JOSHUA/class joshua.decoder.ff.tm.format.PhraseFormatReader > grammar
+ * cat PHRASE_TABLE | java -cp $JOSHUA/class org.apache.joshua.decoder.ff.tm.format.PhraseFormatReader > grammar
* </pre>
*
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*
*/
@@ -116,7 +116,7 @@ public class PhraseFormatReader extends HieroFormatReader {
/**
* Converts a Moses phrase table to a Joshua grammar.
*
- * @param args
+ * @param args arguments required to do the conversion
*/
public static void main(String[] args) {
PhraseFormatReader reader = new PhraseFormatReader();
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/hash_based/MemoryBasedBatchGrammar.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/hash_based/MemoryBasedBatchGrammar.java b/src/main/java/org/apache/joshua/decoder/ff/tm/hash_based/MemoryBasedBatchGrammar.java
index 6ad6d50..f1078c4 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/hash_based/MemoryBasedBatchGrammar.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/hash_based/MemoryBasedBatchGrammar.java
@@ -44,8 +44,8 @@ import org.apache.joshua.util.FormatUtils;
* french sides so far (2) A HashMap of next-layer trie nodes, the next french word used as the key
* in HashMap
*
- * @author Zhifei Li <zh...@gmail.com>
- * @author Matt Post <post@cs.jhu.edu
+ * @author Zhifei Li zhifei.work@gmail.com
+ * @author Matt Post post@cs.jhu.edu
*/
public class MemoryBasedBatchGrammar extends AbstractGrammar {
@@ -254,8 +254,8 @@ public class MemoryBasedBatchGrammar extends AbstractGrammar {
/***
* Takes an input word and creates an OOV rule in the current grammar for that word.
*
- * @param sourceWord
- * @param featureFunctions
+ * @param sourceWord integer representation of word
+ * @param featureFunctions {@link java.util.List} of {@link org.apache.joshua.decoder.ff.FeatureFunction}'s
*/
@Override
public void addOOVRules(int sourceWord, List<FeatureFunction> featureFunctions) {
@@ -288,7 +288,7 @@ public class MemoryBasedBatchGrammar extends AbstractGrammar {
/**
* Adds a default set of glue rules.
*
- * @param featureFunctions
+ * @param featureFunctions an {@link java.util.ArrayList} of {@link org.apache.joshua.decoder.ff.FeatureFunction}'s
*/
public void addGlueRules(ArrayList<FeatureFunction> featureFunctions) {
HieroFormatReader reader = new HieroFormatReader();
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/hash_based/MemoryBasedRuleBin.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/hash_based/MemoryBasedRuleBin.java b/src/main/java/org/apache/joshua/decoder/ff/tm/hash_based/MemoryBasedRuleBin.java
index 2ab5843..f91df1e 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/hash_based/MemoryBasedRuleBin.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/hash_based/MemoryBasedRuleBin.java
@@ -24,7 +24,7 @@ import org.apache.joshua.decoder.ff.tm.Rule;
/**
* Stores a collection of all rules with the same french side (and thus same arity).
*
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Zhifei Li, zhifei.work@gmail.com
*/
public class MemoryBasedRuleBin extends BasicRuleCollection {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/hash_based/MemoryBasedTrie.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/hash_based/MemoryBasedTrie.java b/src/main/java/org/apache/joshua/decoder/ff/tm/hash_based/MemoryBasedTrie.java
index c14e54e..998688a 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/hash_based/MemoryBasedTrie.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/hash_based/MemoryBasedTrie.java
@@ -26,7 +26,7 @@ import org.apache.joshua.decoder.ff.tm.RuleCollection;
import org.apache.joshua.decoder.ff.tm.Trie;
/**
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Zhifei Li, zhifei.work@gmail.com
*/
public class MemoryBasedTrie implements Trie {
MemoryBasedRuleBin ruleBin = null;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/packed/PackedGrammar.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/packed/PackedGrammar.java b/src/main/java/org/apache/joshua/decoder/ff/tm/packed/PackedGrammar.java
index 77fb233..a90684e 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/packed/PackedGrammar.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/packed/PackedGrammar.java
@@ -192,6 +192,7 @@ public class PackedGrammar extends AbstractGrammar {
/**
* Computes the MD5 checksum of the vocabulary file.
* Can be used for comparing vocabularies across multiple packedGrammars.
+ * @return the computed checksum
*/
public String computeVocabularyChecksum() {
MessageDigest md;
@@ -801,7 +802,7 @@ public class PackedGrammar extends AbstractGrammar {
* to then put a nonterminal on the source and target sides to treat the phrase pairs like
* left-branching rules, which is how Joshua deals with phrase decoding.
*
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*
*/
public final class PackedPhrasePair extends PackedRule {
@@ -856,7 +857,7 @@ public class PackedGrammar extends AbstractGrammar {
/**
* Take the English phrase of the underlying rule and prepend an [X].
*
- * @return
+ * @return the augmented phrase
*/
@Override
public int[] getEnglish() {
@@ -866,7 +867,7 @@ public class PackedGrammar extends AbstractGrammar {
/**
* Take the French phrase of the underlying rule and prepend an [X].
*
- * @return
+ * @return the augmented French phrase
*/
@Override
public int[] getFrench() {
@@ -880,7 +881,7 @@ public class PackedGrammar extends AbstractGrammar {
/**
* Similarly the alignment array needs to be shifted over by one.
*
- * @return
+ * @return the byte[] alignment
*/
@Override
public byte[] getAlignment() {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/ff/tm/packed/SliceAggregatingTrie.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/packed/SliceAggregatingTrie.java b/src/main/java/org/apache/joshua/decoder/ff/tm/packed/SliceAggregatingTrie.java
index 8054cda..c6d03a6 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/packed/SliceAggregatingTrie.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/tm/packed/SliceAggregatingTrie.java
@@ -37,28 +37,29 @@ import org.apache.joshua.decoder.ff.tm.Trie;
import org.apache.joshua.decoder.ff.tm.hash_based.ExtensionIterator;
/**
- * SliceAggregatingTrie collapses multiple tries
- * with the same source root (i.e. tries from multiple packed slices).
+ * <p>SliceAggregatingTrie collapses multiple tries
+ * with the same source root (i.e. tries from multiple packed slices).</p>
*
- * Consider the example below.
+ * <p>Consider the example below.
* Without SliceAggregatingTries, the following grammar rules could have only
- * partitioned by splitting rule lists when the first word of SOURCE changes. (">" markers).
+ * partitioned by splitting rule lists when the first word of SOURCE changes. (">" markers).</p>
*
- * Using a SliceAggregatingTrie allows splitting at changes of second SOURCE words (">>" marker).
+ * <p>Using a SliceAggregatingTrie allows splitting at changes of second SOURCE words (">>" marker).</p>
*
+ * <pre>
* EXAMPLE: (LHS ||| SOURCE ||| TARGET)
* [X] ||| - ||| -
- * >
+ * >
* [X] ||| [X] ||| [X]
- * >>
+ * >>
* [X] ||| [X] a ||| [X] A
* [X] ||| [X] a ||| [X] A
- * >>
+ * >>
* [X] ||| [X] b ||| [X] B
- * >
+ * >
* [X] ||| u ||| u
- *
- * A SliceAggregatingTrie node behaves just like a regular Trie node but subsumes a list of extensions/children.
+ * </pre>
+ * <p>A SliceAggregatingTrie node behaves just like a regular Trie node but subsumes a list of extensions/children.
* This class hides the complexity of having multiple tries with the same root
* from nodes one level up.
* Similar to PackedRoot, it maintains a lookup table of children's
@@ -70,7 +71,7 @@ import org.apache.joshua.decoder.ff.tm.hash_based.ExtensionIterator;
* must be found in exactly one of the subtries.
* (!) This assumption relies on the sort order of the packed grammar.
* If the grammar was incorrectly sorted and then packed, construction
- * of SliceAggregatingTrie nodes fails.
+ * of SliceAggregatingTrie nodes fails.</p>
*
* @author fhieber
*/
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/hypergraph/AlignedSourceTokens.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/hypergraph/AlignedSourceTokens.java b/src/main/java/org/apache/joshua/decoder/hypergraph/AlignedSourceTokens.java
index 6a4bed6..948001f 100644
--- a/src/main/java/org/apache/joshua/decoder/hypergraph/AlignedSourceTokens.java
+++ b/src/main/java/org/apache/joshua/decoder/hypergraph/AlignedSourceTokens.java
@@ -24,13 +24,17 @@ import java.util.ListIterator;
/**
* Class that represents a one to (possibly) many alignment from target to
* source. Extends from a LinkedList. Instances of this class are updated by the
- * WordAlignmentExtractor.substitute() method. The <shiftBy> method shifts the
+ * WordAlignmentExtractor.substitute() method.
+ * The {@link org.apache.joshua.decoder.hypergraph.AlignedSourceTokens#shiftBy(int, int)}
+ * method shifts the
* elements in the list by a scalar to reflect substitutions of non terminals in
* the rule. if indexes are final, i.e. the point instance has been substituted
- * into a parent WordAlignmentState once, <isFinal> is set to true. This is
+ * into a parent WordAlignmentState once,
+ * {@link org.apache.joshua.decoder.hypergraph.AlignedSourceTokens#isFinal} is set to true.
+ * This is
* necessary since the final source index of a point is known once we have
* substituted in a complete WordAlignmentState into its parent. If the index in
- * the list is a non terminal, <isNonTerminal> = true
+ * the list is a non terminal, {@link org.apache.joshua.decoder.hypergraph.AlignedSourceTokens#isNonTerminal} = true
*/
class AlignedSourceTokens extends LinkedList<Integer> {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/hypergraph/AllSpansWalker.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/hypergraph/AllSpansWalker.java b/src/main/java/org/apache/joshua/decoder/hypergraph/AllSpansWalker.java
index 1338414..1aad06f 100644
--- a/src/main/java/org/apache/joshua/decoder/hypergraph/AllSpansWalker.java
+++ b/src/main/java/org/apache/joshua/decoder/hypergraph/AllSpansWalker.java
@@ -27,7 +27,7 @@ import org.apache.joshua.corpus.Span;
* Uses {@link ForestWalker} to visit one {@link HGNode} per span of the chart. No guarantees are
* provided as to which HGNode will be visited in each span.
*
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*
*/
@@ -42,8 +42,9 @@ public class AllSpansWalker {
* This function wraps a {@link ForestWalker}, preventing calls to its walker function for all but
* the first node reached for each span.
*
- * @param node
- * @param walker
+ * @param node the {@link org.apache.joshua.decoder.hypergraph.HGNode} we wish to walk
+ * @param walker the {@link org.apache.joshua.decoder.hypergraph.WalkerFunction}
+ * implementation to do the walking
*/
public void walk(HGNode node, final WalkerFunction walker) {
new ForestWalker().walk(node, new org.apache.joshua.decoder.hypergraph.WalkerFunction() {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/hypergraph/DefaultInsideOutside.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/hypergraph/DefaultInsideOutside.java b/src/main/java/org/apache/joshua/decoder/hypergraph/DefaultInsideOutside.java
index b429176..c6dae77 100644
--- a/src/main/java/org/apache/joshua/decoder/hypergraph/DefaultInsideOutside.java
+++ b/src/main/java/org/apache/joshua/decoder/hypergraph/DefaultInsideOutside.java
@@ -25,7 +25,7 @@ import java.util.HashMap;
* to use the functions here, one need to extend the class to provide a way to calculate the
* transitionLogP based on feature set
*
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Zhifei Li, zhifei.work@gmail.com
* @version $LastChangedDate$
*/
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/hypergraph/HGNode.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/hypergraph/HGNode.java b/src/main/java/org/apache/joshua/decoder/hypergraph/HGNode.java
index a38fec9..1e357e2 100644
--- a/src/main/java/org/apache/joshua/decoder/hypergraph/HGNode.java
+++ b/src/main/java/org/apache/joshua/decoder/hypergraph/HGNode.java
@@ -28,8 +28,8 @@ import org.apache.joshua.decoder.ff.state_maintenance.DPState;
/**
* this class implement Hypergraph node (i.e., HGNode); also known as Item in parsing.
*
- * @author Zhifei Li, <zh...@gmail.com>
- * @author Juri Ganitkevitch, <ju...@cs.jhu.edu>
+ * @author Zhifei Li, zhifei.work@gmail.com
+ * @author Juri Ganitkevitch, juri@cs.jhu.edu
*/
// TODO: handle the case that the Hypergraph only maintains the one-best tree
@@ -93,6 +93,8 @@ public class HGNode {
* Adds the hyperedge to the list of incoming hyperedges (i.e., ways to form this node), creating
* the list if necessary. We then update the cache of the best incoming hyperedge via a call to
* the (obscurely named) semiringPlus().
+ * @param hyperEdge the {@link org.apache.joshua.decoder.hypergraph.HyperEdge} to add
+ * to the list of incoming hyperedges
*/
public void addHyperedgeInNode(HyperEdge hyperEdge) {
if (hyperEdge != null) {
@@ -106,6 +108,8 @@ public class HGNode {
/**
* Convenience function to add a list of hyperedges one at a time.
+ * @param hyperedges a {@link java.util.List} of {@link org.apache.joshua.decoder.hypergraph.HyperEdge}'s
+ * to add to the current HGNode.
*/
public void addHyperedgesInNode(List<HyperEdge> hyperedges) {
for (HyperEdge hyperEdge : hyperedges)
@@ -114,6 +118,7 @@ public class HGNode {
/**
* Updates the cache of the best incoming hyperedge.
+ * @param hyperEdge an incoming {{@link org.apache.joshua.decoder.hypergraph.HyperEdge}
*/
public void semiringPlus(HyperEdge hyperEdge) {
if (null == bestHyperedge || bestHyperedge.getBestDerivationScore() < hyperEdge.getBestDerivationScore()) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/hypergraph/HyperEdge.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/hypergraph/HyperEdge.java b/src/main/java/org/apache/joshua/decoder/hypergraph/HyperEdge.java
index 128ee68..d7bcc4d 100644
--- a/src/main/java/org/apache/joshua/decoder/hypergraph/HyperEdge.java
+++ b/src/main/java/org/apache/joshua/decoder/hypergraph/HyperEdge.java
@@ -26,8 +26,8 @@ import org.apache.joshua.decoder.ff.tm.Rule;
/**
* this class implement Hyperedge
*
- * @author Zhifei Li, <zh...@gmail.com>
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Zhifei Li, zhifei.work@gmail.com
+ * @author Matt Post post@cs.jhu.edu
*/
public class HyperEdge {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/hypergraph/HyperGraph.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/hypergraph/HyperGraph.java b/src/main/java/org/apache/joshua/decoder/hypergraph/HyperGraph.java
index e921027..516b347 100644
--- a/src/main/java/org/apache/joshua/decoder/hypergraph/HyperGraph.java
+++ b/src/main/java/org/apache/joshua/decoder/hypergraph/HyperGraph.java
@@ -39,7 +39,7 @@ import org.apache.joshua.decoder.segment_file.Sentence;
* Note: to seed the kbest extraction, each deduction should have the best_cost properly set. We do
* not require any list being sorted
*
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Zhifei Li, zhifei.work@gmail.com
*/
public class HyperGraph {
@@ -141,7 +141,8 @@ public class HyperGraph {
/**
* Dump the hypergraph to the specified file.
*
- * @param fileName
+ * @param fileName local file path
+ * @param model {@link java.util.List} of {@link org.apache.joshua.decoder.ff.FeatureFunction}'s
*/
public void dump(String fileName, List<FeatureFunction> model) {
try ( PrintWriter out = new PrintWriter(fileName, "UTF-8") ) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/hypergraph/HyperGraphPruning.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/hypergraph/HyperGraphPruning.java b/src/main/java/org/apache/joshua/decoder/hypergraph/HyperGraphPruning.java
index ff44a25..27f5525 100644
--- a/src/main/java/org/apache/joshua/decoder/hypergraph/HyperGraphPruning.java
+++ b/src/main/java/org/apache/joshua/decoder/hypergraph/HyperGraphPruning.java
@@ -26,7 +26,7 @@ import org.apache.joshua.corpus.Vocabulary;
* during the pruning process, many Item/Deductions may not be explored at all due to the early-stop
* in pruning_deduction
*
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Zhifei Li, zhifei.work@gmail.com
* @version $LastChangedDate$
*/
public class HyperGraphPruning extends TrivialInsideOutside {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/hypergraph/KBestExtractor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/hypergraph/KBestExtractor.java b/src/main/java/org/apache/joshua/decoder/hypergraph/KBestExtractor.java
index 324cf4c..9e7cbbb 100644
--- a/src/main/java/org/apache/joshua/decoder/hypergraph/KBestExtractor.java
+++ b/src/main/java/org/apache/joshua/decoder/hypergraph/KBestExtractor.java
@@ -47,49 +47,49 @@ import org.apache.joshua.util.FormatUtils;
import cern.colt.Arrays;
/**
- * This class implements lazy k-best extraction on a hyper-graph.
+ * <p>This class implements lazy k-best extraction on a hyper-graph.</p>
*
- * K-best extraction over hypergraphs is a little hairy, but is best understood in the following
+ * <p>K-best extraction over hypergraphs is a little hairy, but is best understood in the following
* manner. Imagine a hypergraph, which is composed of nodes connected by hyperedges. A hyperedge has
* exactly one parent node and 1 or more tail nodes, corresponding to the rank of the rule that gave
- * rise to the hyperedge. Each node has 1 or more incoming hyperedges.
+ * rise to the hyperedge. Each node has 1 or more incoming hyperedges.</p>
*
- * K-best extraction works in the following manner. A derivation is a set of nodes and hyperedges
+ * <p>K-best extraction works in the following manner. A derivation is a set of nodes and hyperedges
* that leads from the root node down and exactly covers the source-side sentence. To define a
* derivation, we start at the root node, choose one of its incoming hyperedges, and then recurse to
- * the tail (or antecedent) nodes of that hyperedge, where we continually make the same decision.
+ * the tail (or antecedent) nodes of that hyperedge, where we continually make the same decision.</p>
*
- * Each hypernode has its hyperedges sorted according to their model score. To get the best
+ * <p>Each hypernode has its hyperedges sorted according to their model score. To get the best
* (Viterbi) derivation, we simply recursively follow the best hyperedge coming in to each
- * hypernode.
+ * hypernode.</p>
*
- * How do we get the second-best derivation? It is defined by changing exactly one of the decisions
+ * <p>How do we get the second-best derivation? It is defined by changing exactly one of the decisions
* about which hyperedge to follow in the recursion. Somewhere, we take the second-best. Similarly,
* the third-best derivation makes a single change from the second-best: either making another
* (differnt) second-best choice somewhere along the 1-best derivation, or taking the third-best
- * choice at the same spot where the second-best derivation took the second-best choice. And so on.
+ * choice at the same spot where the second-best derivation took the second-best choice. And so on.</p>
*
- * This class uses two classes that encode the necessary meta-information. The first is the
+ * <p>This class uses two classes that encode the necessary meta-information. The first is the
* DerivationState class. It roughly corresponds to a hyperedge, and records, for each of that
* hyperedge's tail nodes, which-best to take. So for a hyperedge with three tail nodes, the 1-best
* derivation will be (1,1,1), the second-best will be one of (2,1,1), (1,2,1), or (1,1,2), the
- * third best will be one of
+ * third best will be one of</p>
*
- * (3,1,1), (2,2,1), (1,1,3)
+ * <code>(3,1,1), (2,2,1), (1,1,3)</code>
*
- * and so on.
+ * <p>and so on.</p>
*
- * The configuration parameter `output-format` controls what exactly is extracted from the forest.
+ * <p>The configuration parameter `output-format` controls what exactly is extracted from the forest.
* See documentation for that below. Note that Joshua does not store individual feature values while
* decoding, but only the cost of each edge (in the form of a float). Therefore, if you request
* the features values (`%f` in `output-format`), the feature functions must be replayed, which
- * is expensive.
+ * is expensive.</p>
*
- * The configuration parameter `top-n` controls how many items are returned. If this is set to 0,
- * k-best extraction should be turned off entirely.
+ * <p>The configuration parameter `top-n` controls how many items are returned. If this is set to 0,
+ * k-best extraction should be turned off entirely.</p>
*
- * @author Zhifei Li, <zh...@gmail.com>
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Zhifei Li, zhifei.work@gmail.com
+ * @author Matt Post post@cs.jhu.edu
*/
public class KBestExtractor {
private final JoshuaConfiguration joshuaConfiguration;
@@ -162,7 +162,12 @@ public class KBestExtractor {
* Compute the string that is output from the decoder, using the "output-format" config file
* parameter as a template.
*
- * You may need to reset_state() before you call this function for the first time.
+ * You may need to {@link org.apache.joshua.decoder.hypergraph.KBestExtractor#resetState()}
+ * before you call this function for the first time.
+ *
+ * @param node todo
+ * @param k todo
+ * @return todo
*/
public String getKthHyp(HGNode node, int k) {
@@ -228,9 +233,9 @@ public class KBestExtractor {
* If requested, projects source-side lettercase to target, and appends the alignment from
* to the source-side sentence in ||s.
*
- * @param hypothesis
- * @param state
- * @return
+ * @param hypothesis todo
+ * @param state todo
+ * @return source-side lettercase to target, and appends the alignment from to the source-side sentence in ||s
*/
private String maybeProjectCase(String hypothesis, DerivationState state) {
String output = hypothesis;
@@ -260,6 +265,9 @@ public class KBestExtractor {
/**
* Convenience function for k-best extraction that prints to STDOUT.
+ * @param hg the {@link org.apache.joshua.decoder.hypergraph.HyperGraph} from which to extract
+ * @param topN the number of k
+ * @throws IOException if there is an error writing the extraction
*/
public void lazyKBestExtractOnHG(HyperGraph hg, int topN) throws IOException {
lazyKBestExtractOnHG(hg, topN, new BufferedWriter(new OutputStreamWriter(System.out)));
@@ -279,7 +287,7 @@ public class KBestExtractor {
* @param hg the hypergraph to extract from
* @param topN how many to extract
* @param out object to write to
- * @throws IOException
+ * @throws IOException if there is an error writing the extraction
*/
public void lazyKBestExtractOnHG(HyperGraph hg, int topN, BufferedWriter out) throws IOException {
@@ -308,11 +316,13 @@ public class KBestExtractor {
}
/**
- * Returns the VirtualNode corresponding to an HGNode. If no such VirtualNode exists, it is
- * created.
+ * Returns the {@link org.apache.joshua.decoder.hypergraph.KBestExtractor.VirtualNode}
+ * corresponding to an {@link org.apache.joshua.decoder.hypergraph.HGNode}.
+ * If no such VirtualNode exists, it is created.
*
- * @param hgnode
- * @return the corresponding VirtualNode
+ * @param hgnode from which we wish to create a
+ * {@link org.apache.joshua.decoder.hypergraph.KBestExtractor.VirtualNode}
+ * @return the corresponding {@link org.apache.joshua.decoder.hypergraph.KBestExtractor.VirtualNode}
*/
private VirtualNode getVirtualNode(HGNode hgnode) {
VirtualNode virtualNode = virtualNodesTable.get(hgnode);
@@ -330,7 +340,6 @@ public class KBestExtractor {
* k-best derivations from that point on, retaining the derivations computed so far and a priority
* queue of candidates.
*/
-
private class VirtualNode {
// The node being annotated.
@@ -357,7 +366,7 @@ public class KBestExtractor {
/**
* This returns a DerivationState corresponding to the kth-best derivation rooted at this node.
*
- * @param kbestExtractor
+ * @param kbestExtractor todo
* @param k (indexed from one)
* @return the k-th best (1-indexed) hypothesis, or null if there are no more.
*/
@@ -651,7 +660,7 @@ public class KBestExtractor {
* assumption that the total number of words in the hypothesis scales linearly with the input
* sentence span.
*
- * @return
+ * @return float representing {@link org.apache.joshua.decoder.BLEU} score
*/
public float computeBLEU() {
if (stats == null) {
@@ -678,7 +687,7 @@ public class KBestExtractor {
* Returns the model cost. This is obtained by subtracting off the incorporated BLEU score (if
* used).
*
- * @return
+ * @return float representing model cost
*/
public float getModelCost() {
return this.cost;
@@ -687,7 +696,7 @@ public class KBestExtractor {
/**
* Returns the model cost plus the BLEU score.
*
- * @return
+ * @return float representing model cost plus the BLEU score
*/
public float getCost() {
return cost - weights.getSparse("BLEU") * bleu;
@@ -725,6 +734,7 @@ public class KBestExtractor {
/**
* DerivationState objects are unique to each VirtualNode, so the unique identifying information
* only need contain the edge position and the ranks.
+ * @return hashof the edge position and ranks
*/
public int hashCode() {
int hash = edgePos;
@@ -738,6 +748,8 @@ public class KBestExtractor {
/**
* Visits every state in the derivation in a depth-first order.
+ * @param visitor todo
+ * @return todo
*/
private DerivationVisitor visit(DerivationVisitor visitor) {
return visit(visitor, 0, 0);
@@ -808,9 +820,9 @@ public class KBestExtractor {
* function looks up the VirtualNode corresponding to the HGNode pointed to by the edge's
* {tailNodeIndex}th tail node.
*
- * @param edge
- * @param tailNodeIndex
- * @return
+ * @param edge todo
+ * @param tailNodeIndex todo
+ * @return todo
*/
public DerivationState getChildDerivationState(HyperEdge edge, int tailNodeIndex) {
HGNode child = edge.getTailNodes().get(tailNodeIndex);
@@ -840,7 +852,7 @@ public class KBestExtractor {
* way to do different things to the tree (e.g., extract its words, assemble a derivation, and so
* on) without having to rewrite the node-visiting code.
*
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*/
public interface DerivationVisitor {
/**
@@ -953,7 +965,7 @@ public class KBestExtractor {
* Assembles an informative version of the derivation. Each rule is printed as it is encountered.
* Don't try to parse this output; make something that writes out JSON or something, instead.
*
- * @author Matt Post <post@cs.jhu.edu
+ * @author Matt Post post@cs.jhu.edu
*/
public class DerivationExtractor implements DerivationVisitor {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/hypergraph/TrivialInsideOutside.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/hypergraph/TrivialInsideOutside.java b/src/main/java/org/apache/joshua/decoder/hypergraph/TrivialInsideOutside.java
index 4f1d950..67be0c1 100644
--- a/src/main/java/org/apache/joshua/decoder/hypergraph/TrivialInsideOutside.java
+++ b/src/main/java/org/apache/joshua/decoder/hypergraph/TrivialInsideOutside.java
@@ -19,7 +19,7 @@
package org.apache.joshua.decoder.hypergraph;
/**
- * @author Zhifei Li, <zh...@gmail.com>
+ * @author Zhifei Li, zhifei.work@gmail.com
* @version $LastChangedDate$
*/
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/hypergraph/ViterbiExtractor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/hypergraph/ViterbiExtractor.java b/src/main/java/org/apache/joshua/decoder/hypergraph/ViterbiExtractor.java
index b6e7166..94c2bff 100644
--- a/src/main/java/org/apache/joshua/decoder/hypergraph/ViterbiExtractor.java
+++ b/src/main/java/org/apache/joshua/decoder/hypergraph/ViterbiExtractor.java
@@ -28,8 +28,8 @@ import org.apache.joshua.decoder.ff.FeatureVector;
import org.apache.joshua.decoder.segment_file.Sentence;
/**
- * @author Zhifei Li, <zh...@gmail.com>
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Zhifei Li, zhifei.work@gmail.com
+ * @author Matt Post post@cs.jhu.edu
*/
public class ViterbiExtractor {
@@ -61,25 +61,33 @@ public class ViterbiExtractor {
}
}
}
-
+
public static void viterbiWalk(final HGNode node, final WalkerFunction walker) {
viterbiWalk(node, walker, 0);
}
-
+
/**
* Returns the Viterbi translation of the Hypergraph (includes sentence markers)
+ * @param hg a {@link org.apache.joshua.decoder.hypergraph.HyperGraph} we wish to
+ * obtain a Viterbi translation for
+ * @return a String Viterbi translation
*/
public static String getViterbiString(final HyperGraph hg) {
if (hg == null)
return "";
-
+
final WalkerFunction viterbiOutputStringWalker = new OutputStringExtractor(false);
viterbiWalk(hg.goalNode, viterbiOutputStringWalker);
return viterbiOutputStringWalker.toString();
}
-
+
/**
* Returns the Viterbi feature vector
+ * @param hg a {@link org.apache.joshua.decoder.hypergraph.HyperGraph} we wish to
+ * obtain a Viterbi features for
+ * @param featureFunctions a {@link java.util.List} of {@link org.apache.joshua.decoder.ff.FeatureFunction}'s
+ * @param sentence {@link org.apache.joshua.lattice.Lattice} input
+ * @return a Viterbi {@link org.apache.joshua.decoder.ff.FeatureVector.FeatureVector}
*/
public static FeatureVector getViterbiFeatures(
final HyperGraph hg,
@@ -87,38 +95,46 @@ public class ViterbiExtractor {
final Sentence sentence) {
if (hg == null)
return new FeatureVector();
-
+
final FeatureVectorExtractor extractor = new FeatureVectorExtractor(
featureFunctions, sentence);
- viterbiWalk(hg.goalNode, extractor);
- return extractor.getFeatures();
+ viterbiWalk(hg.goalNode, extractor);
+ return extractor.getFeatures();
}
-
+
/**
* Returns the Viterbi Word Alignments as String.
+ * @param hg input {@link org.apache.joshua.decoder.hypergraph.HyperGraph}
+ * @return the Viterbi Word Alignments as String
*/
public static String getViterbiWordAlignments(final HyperGraph hg) {
if (hg == null)
return "";
-
+
final WordAlignmentExtractor wordAlignmentWalker = new WordAlignmentExtractor();
viterbiWalk(hg.goalNode, wordAlignmentWalker);
return wordAlignmentWalker.toString();
}
-
+
/**
* Returns the Viterbi Word Alignments as list of lists (target-side).
+ * @param hg input {@link org.apache.joshua.decoder.hypergraph.HyperGraph}
+ * @return a {@link java.util.List} of Viterbi Word Alignments
*/
public static List<List<Integer>> getViterbiWordAlignmentList(final HyperGraph hg) {
if (hg == null)
return emptyList();
-
+
final WordAlignmentExtractor wordAlignmentWalker = new WordAlignmentExtractor();
viterbiWalk(hg.goalNode, wordAlignmentWalker);
return wordAlignmentWalker.getFinalWordAlignments();
}
-
- /** find 1best hypergraph */
+
+ /**
+ * find 1best hypergraph
+ * @param hg_in input {@link org.apache.joshua.decoder.hypergraph.HyperGraph}
+ * @return new best {@link org.apache.joshua.decoder.hypergraph.HyperGraph}
+ */
public static HyperGraph getViterbiTreeHG(HyperGraph hg_in) {
HyperGraph res =
new HyperGraph(cloneNodeWithBestHyperedge(hg_in.goalNode), -1, -1, null);
@@ -152,7 +168,7 @@ public class ViterbiExtractor {
List<HGNode> antNodes = null;
if (null != inEdge.getTailNodes()) {
antNodes = new ArrayList<HGNode>(inEdge.getTailNodes());// l_ant_items will be changed in
- // get_1best_tree_item
+ // get_1best_tree_item
}
HyperEdge res =
new HyperEdge(inEdge.getRule(), inEdge.getBestDerivationScore(), inEdge.getTransitionLogP(false),
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/hypergraph/WalkerFunction.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/hypergraph/WalkerFunction.java b/src/main/java/org/apache/joshua/decoder/hypergraph/WalkerFunction.java
index 67bcfc2..811521c 100644
--- a/src/main/java/org/apache/joshua/decoder/hypergraph/WalkerFunction.java
+++ b/src/main/java/org/apache/joshua/decoder/hypergraph/WalkerFunction.java
@@ -28,6 +28,9 @@ public interface WalkerFunction {
* Function that is applied to node at tail node index nodeIndex.
* nodeIndex indicates the index of node in the list of tailnodes for the
* outgoing edge.
+ * @param node the {{@link org.apache.joshua.decoder.hypergraph.HGNode} we
+ * wish to apply some Walker Function to.
+ * @param nodeIndex node in the list of tailnodes for the outgoing edge
*/
void apply(HGNode node, int nodeIndex);
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/hypergraph/WordAlignmentExtractor.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/hypergraph/WordAlignmentExtractor.java b/src/main/java/org/apache/joshua/decoder/hypergraph/WordAlignmentExtractor.java
index 98937c4..04d0897 100644
--- a/src/main/java/org/apache/joshua/decoder/hypergraph/WordAlignmentExtractor.java
+++ b/src/main/java/org/apache/joshua/decoder/hypergraph/WordAlignmentExtractor.java
@@ -96,6 +96,7 @@ public class WordAlignmentExtractor implements WalkerFunction, DerivationVisitor
/**
* Final word alignment without sentence markers
* or empty list if stack is empty.
+ * @return a final alignment list
*/
public List<List<Integer>> getFinalWordAlignments() {
if (stack.isEmpty()) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/hypergraph/WordAlignmentState.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/hypergraph/WordAlignmentState.java b/src/main/java/org/apache/joshua/decoder/hypergraph/WordAlignmentState.java
index 39700d2..5140652 100644
--- a/src/main/java/org/apache/joshua/decoder/hypergraph/WordAlignmentState.java
+++ b/src/main/java/org/apache/joshua/decoder/hypergraph/WordAlignmentState.java
@@ -83,6 +83,7 @@ public class WordAlignmentState {
/**
* if there are no more NonTerminals to substitute,
* this state is said to be complete
+ * @return true if complete
*/
public boolean isComplete() {
return numNT == 0;
@@ -91,6 +92,7 @@ public class WordAlignmentState {
/**
* builds the final alignment string in the standard alignment format: src -
* trg. Sorted by trg indexes. Disregards the sentence markers.
+ * @return result string
*/
public String toFinalString() {
StringBuilder sb = new StringBuilder();
@@ -111,6 +113,7 @@ public class WordAlignmentState {
* builds the final alignment list.
* each entry in the list corresponds to a list of aligned source tokens.
* First and last item in trgPoints is skipped.
+ * @return a final alignment list
*/
public List<List<Integer>> toFinalList() {
assert (isComplete() == true);
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/io/DeNormalize.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/io/DeNormalize.java b/src/main/java/org/apache/joshua/decoder/io/DeNormalize.java
index a90a7d2..be2b05a 100644
--- a/src/main/java/org/apache/joshua/decoder/io/DeNormalize.java
+++ b/src/main/java/org/apache/joshua/decoder/io/DeNormalize.java
@@ -26,18 +26,17 @@ import java.util.regex.Pattern;
* <UL>
* <LI>Capitalize the first character in the string</LI>
* <LI>Detokenize</LI>
- * <UL>
* <LI>Delete whitespace in front of periods and commas</LI>
* <LI>Join contractions</LI>
* <LI>Capitalize name titles (Mr Ms Miss Dr etc.)</LI>
- * <LI>TODO: Handle surrounding characters ([{<"''">}])</LI>
+ * <LI>TODO: Handle surrounding characters ([{<"''">}])</LI>
* <LI>TODO: Join multi-period abbreviations (e.g. M.Phil. i.e.)</LI>
* <LI>TODO: Handle ambiguities like "st.", which can be an abbreviation for both "Saint" and
* "street"</LI>
* <LI>TODO: Capitalize both the title and the name of a person, e.g. Mr. Morton (named entities
* should be demarcated).</LI>
* </UL>
- * </UL> <bold>N.B.</bold> These methods all assume that every translation result that will be
+ * <b>N.B.</b> These methods all assume that every translation result that will be
* denormalized has the following format:
* <UL>
* <LI>There is only one space between every pair of tokens</LI>
@@ -45,7 +44,6 @@ import java.util.regex.Pattern;
* <LI>There is no whitespace after the final token</LI>
* <LI>Standard spaces are the only type of whitespace</LI>
* </UL>
- * </UL>
*/
public class DeNormalize {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/io/TranslationRequestStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/io/TranslationRequestStream.java b/src/main/java/org/apache/joshua/decoder/io/TranslationRequestStream.java
index 32978e8..432f1fb 100644
--- a/src/main/java/org/apache/joshua/decoder/io/TranslationRequestStream.java
+++ b/src/main/java/org/apache/joshua/decoder/io/TranslationRequestStream.java
@@ -34,7 +34,7 @@ import org.apache.joshua.decoder.segment_file.Sentence;
* expects plain-text input, which can be plain sentences or PLF-encoded lattices. If
* '-input-type json' is passed to the decoder, it will instead read JSON objects from the input
* stream, with the following format:
- *
+ * <pre>
* {
* "data": {
* "translations": [
@@ -44,8 +44,8 @@ import org.apache.joshua.decoder.segment_file.Sentence;
* ]
* }
* }
- *
- * @author Matt Post <po...@cs.jhu.edu>
+ * </pre>
+ * @author Matt Post post@cs.jhu.edu
* @author orluke
*/
public class TranslationRequestStream {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/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 69e1447..ee8a2a9 100644
--- a/src/main/java/org/apache/joshua/decoder/phrase/Candidate.java
+++ b/src/main/java/org/apache/joshua/decoder/phrase/Candidate.java
@@ -170,7 +170,7 @@ public class Candidate {
}
/**
- * This returns the target side {@link Phrase}, which is a {@link Rule} object. This is just a
+ * This returns the target side {@link org.apache.joshua.corpus.Phrase}, which is a {@link org.apache.joshua.decoder.ff.tm.Rule} object. This is just a
* convenience function that works by returning the phrase indexed in ranks[1].
*
* @return the phrase at position ranks[1]
@@ -194,7 +194,7 @@ public class Candidate {
/**
* Returns the bit vector of this hypothesis. The bit vector is computed by ORing the coverage
* vector of the tail node (hypothesis) and the source span of phrases in this candidate.
- * @return
+ * @return the bit vector of this hypothesis
*/
public Coverage getCoverage() {
Coverage cov = new Coverage(getHypothesis().getCoverage());
@@ -203,9 +203,9 @@ public class Candidate {
}
/**
- * Sets the result of a candidate (should just be moved to the constructor).
+ * Sets the result of a candidate (TODO should just be moved to the constructor).
*
- * @param result
+ * @param result todo
*/
public void setResult(ComputeNodeResult result) {
this.result = result;
@@ -221,7 +221,7 @@ public class Candidate {
* The Future Cost item should probably just be implemented as another kind of feature function,
* but it would require some reworking of that interface, which isn't worth it.
*
- * @return
+ * @return the sum of two costs: the HypoState cost + the transition cost
*/
public float score() {
return getHypothesis().getScore() + future_delta + result.getTransitionCost();
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/phrase/Coverage.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/phrase/Coverage.java b/src/main/java/org/apache/joshua/decoder/phrase/Coverage.java
index 9d8feb1..744f2e7 100644
--- a/src/main/java/org/apache/joshua/decoder/phrase/Coverage.java
+++ b/src/main/java/org/apache/joshua/decoder/phrase/Coverage.java
@@ -69,8 +69,7 @@ public class Coverage {
/**
* Initialize a coverage vector from another Coverage vector, creating a separate object.
*
- * @param firstZero
- * @param bits
+ * @param other an existing coverage vector from which to create a new coverage vector
*/
public Coverage(Coverage other) {
this.firstZero = other.firstZero;
@@ -81,8 +80,8 @@ public class Coverage {
* Turns on all bits from position start to position (end - 1), that is, in the range [start .. end).
* This is done relative to the current coverage vector, of course, which may not start at 0.
*
- * @param begin
- * @param end
+ * @param begin bits at start position
+ * @param end bits at end position (end - 1)
*/
public void set(int begin, int end) {
assert compatible(begin, end);
@@ -112,6 +111,7 @@ public class Coverage {
/**
* Convenience function.
+ * @param todo
*/
public final void set(Span span) {
set(span.start, span.end);
@@ -155,7 +155,7 @@ public class Coverage {
* Find the left bound of the gap in which the phrase [begin, ...) sits.
*
* @param begin the start index of the phrase being applied.
- * @return
+ * @return todo
*/
public int leftOpening(int begin) {
for (int i = begin - firstZero; i > 0; --i) {
@@ -173,12 +173,15 @@ public class Coverage {
/**
* LeftOpen() and RightOpen() find the larger gap in which a new source phrase pair sits.
* When using a phrase pair covering (begin, end), the pair
- *
+ * <pre>
* (LeftOpen(begin), RightOpen(end, sentence_length))
+ * </pre>
*
* provides this gap.
*
* Finds the right bound of the enclosing gap, or the end of sentence, whichever is less.
+ * @param end end of phrase pair
+ * @param senetenceLength length of sentence
*/
public int rightOpening(int end, int sentenceLength) {
for (int i = end - firstZero; i < Math.min(64, sentenceLength - firstZero); i++) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/src/main/java/org/apache/joshua/decoder/phrase/Hypothesis.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/phrase/Hypothesis.java b/src/main/java/org/apache/joshua/decoder/phrase/Hypothesis.java
index 9e6135e..faee2ae 100644
--- a/src/main/java/org/apache/joshua/decoder/phrase/Hypothesis.java
+++ b/src/main/java/org/apache/joshua/decoder/phrase/Hypothesis.java
@@ -28,13 +28,13 @@ import org.apache.joshua.decoder.hypergraph.HGNode;
import org.apache.joshua.decoder.hypergraph.HyperEdge;
/**
- * Represents a hypothesis, a translation of some coverage of the input. Extends {@link HGNode},
- * through a bit of a hack. Whereas (i,j) represents the span of an {@link HGNode}, i here is not used,
+ * Represents a hypothesis, a translation of some coverage of the input. Extends {@link org.apache.joshua.decoder.hypergraph.HGNode},
+ * through a bit of a hack. Whereas (i,j) represents the span of an {@link org.apache.joshua.decoder.hypergraph.HGNode}, i here is not used,
* and j is overloaded to denote the span of the phrase being applied. The complete coverage vector
* can be obtained by looking at the tail pointer and casting it.
*
* @author Kenneth Heafield
- * @author Matt Post <po...@cs.jhu.edu>
+ * @author Matt Post post@cs.jhu.edu
*/
public class Hypothesis extends HGNode implements Comparable<Hypothesis> {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/1fc0590e/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 1ed2705..653217b 100644
--- a/src/main/java/org/apache/joshua/decoder/phrase/Stack.java
+++ b/src/main/java/org/apache/joshua/decoder/phrase/Stack.java
@@ -126,7 +126,7 @@ public class Stack extends ArrayList<Hypothesis> {
/**
* Receives a partially-initialized translation candidate and places it on the
* priority queue after scoring it with all of the feature functions. In this
- * respect it is like {@link CubePruneState} (it could make use of that class with
+ * respect it is like {@link org.apache.joshua.decoder.chart_parser.CubePruneState} (it could make use of that class with
* a little generalization of spans / coverage).
*
* This function is also used to (fairly concisely) implement constrained decoding. Before
@@ -168,9 +168,6 @@ public class Stack extends ArrayList<Hypothesis> {
* Cube pruning. Repeatedly pop the top candidate, creating a new hyperedge from it, adding it to
* the k-best list, and then extending the list of candidates with extensions of the current
* candidate.
- *
- * @param context
- * @param output
*/
public void search() {
int to_pop = config.pop_limit;