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/25 15:30:48 UTC
[1/2] incubator-joshua git commit: JOSHUA-252 Make it possible to use
Maven to build Joshua
Repository: incubator-joshua
Updated Branches:
refs/heads/JOSHUA-252 1fc0590e9 -> aead62094
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 a4ab800..d89c948 100644
--- a/src/main/java/org/apache/joshua/lattice/Lattice.java
+++ b/src/main/java/org/apache/joshua/lattice/Lattice.java
@@ -72,6 +72,7 @@ public class Lattice<Value> implements Iterable<Node<Value>> {
* order, the behavior of the lattice is not defined.
*
* @param nodes A list of nodes which must be in topological order.
+ * @param config a populated {@link org.apache.joshua.decoder.JoshuaConfiguration}
*/
public Lattice(List<Node<Value>> nodes, JoshuaConfiguration config) {
this.nodes = nodes;
@@ -91,6 +92,7 @@ public class Lattice<Value> implements Iterable<Node<Value>> {
* Instantiates a lattice from a linear chain of values, i.e., a sentence.
*
* @param linearChain a sequence of Value objects
+ * @param config a populated {@link org.apache.joshua.decoder.JoshuaConfiguration}
*/
public Lattice(Value[] linearChain, JoshuaConfiguration config) {
this.latticeHasAmbiguity = false;
@@ -125,7 +127,8 @@ 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 arc
+ * @param arc an {@link org.apache.joshua.lattice.Arc} of values
+ * @return the shortest distance between two nodes
*/
public int distance(Arc<Value> arc) {
return this.getShortestPath(arc.getTail().getNumber(), arc.getHead().getNumber());
@@ -138,8 +141,8 @@ public class Lattice<Value> implements Iterable<Node<Value>> {
/**
* Convenience method to get a lattice from a linear sequence of {@link Token} objects.
*
- * @param source
- * @param config
+ * @param source input string from which to create a {@link org.apache.joshua.lattice.Lattice}
+ * @param config a populated {@link org.apache.joshua.decoder.JoshuaConfiguration}
* @return Lattice representation of the linear chain.
*/
public static Lattice<Token> createTokenLatticeFromString(String source, JoshuaConfiguration config) {
@@ -243,6 +246,7 @@ public class Lattice<Value> implements Iterable<Node<Value>> {
* Constructs a lattice from a given string representation.
*
* @param data String representation of a lattice.
+ * @param config a populated {@link org.apache.joshua.decoder.JoshuaConfiguration}
* @return A lattice that corresponds to the given string.
*/
public static Lattice<String> createStringLatticeFromString(String data, JoshuaConfiguration config) {
@@ -325,7 +329,7 @@ public class Lattice<Value> implements Iterable<Node<Value>> {
/**
* Gets the shortest distance through the lattice.
- *
+ * @return int representing the shortest distance through the lattice
*/
public int getShortestDistance() {
if (distances == null)
@@ -442,9 +446,9 @@ public class Lattice<Value> implements Iterable<Node<Value>> {
* Replaced the arc from node i to j with the supplied lattice. This is used to do OOV
* segmentation of words in a lattice.
*
- * @param i
- * @param j
- * @param newNodes
+ * @param i start node of arc
+ * @param j end node of arc
+ * @param newNodes new nodes used within the replacement operation
*/
public void insert(int i, int j, List<Node<Value>> newNodes) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/src/main/java/org/apache/joshua/lattice/Node.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/lattice/Node.java b/src/main/java/org/apache/joshua/lattice/Node.java
index 09fb150..ecff22e 100644
--- a/src/main/java/org/apache/joshua/lattice/Node.java
+++ b/src/main/java/org/apache/joshua/lattice/Node.java
@@ -55,6 +55,7 @@ public class Node<Label> {
/**
* Constructs a new node with the specified numeric identifier.
+ * @param id the new node identifier
*/
public Node(int id) {
this.id = id;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/src/main/java/org/apache/joshua/metrics/BLEU.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/metrics/BLEU.java b/src/main/java/org/apache/joshua/metrics/BLEU.java
index a37dcaf..79e630b 100644
--- a/src/main/java/org/apache/joshua/metrics/BLEU.java
+++ b/src/main/java/org/apache/joshua/metrics/BLEU.java
@@ -147,6 +147,9 @@ public class BLEU extends EvaluationMetric {
/**
* Computes the BLEU sufficient statistics on a hypothesis.
+ * @param cand_str todo
+ * @param i todo
+ * @return int[] representing statistics on a hypothesis
*/
public int[] suffStats(String cand_str, int i) {
int[] stats = new int[suffStatsCount];
@@ -172,9 +175,9 @@ public class BLEU extends EvaluationMetric {
/**
* Computes the precision sufficient statistics, clipping counts.
*
- * @param stats
- * @param words
- * @param i
+ * @param stats int[] representing statistics on a hypothesis.
+ * @param words String[] of input terms
+ * @param i todo
*/
public void set_prec_suffStats(int[] stats, String[] words, int i) {
HashMap<String, Integer>[] candCountsArray = getNgramCountsArray(words);
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/src/main/java/org/apache/joshua/metrics/EvaluationMetric.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/metrics/EvaluationMetric.java b/src/main/java/org/apache/joshua/metrics/EvaluationMetric.java
index 4ca1675..1ec546d 100644
--- a/src/main/java/org/apache/joshua/metrics/EvaluationMetric.java
+++ b/src/main/java/org/apache/joshua/metrics/EvaluationMetric.java
@@ -213,9 +213,9 @@ public abstract class EvaluationMetric {
/**
* Calculates sufficient statistics on each sentence in the corpus, returning them as arrays.
*
- * @param cand_strings
- * @param cand_indices
- * @return
+ * @param cand_strings todo
+ * @param cand_indices todo
+ * @return todo
*/
public int[][] suffStats(String[] cand_strings, int[] cand_indices) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 0ed8a95..0660e8a 100644
--- a/src/main/java/org/apache/joshua/oracle/OracleExtractionHG.java
+++ b/src/main/java/org/apache/joshua/oracle/OracleExtractionHG.java
@@ -58,7 +58,7 @@ public class OracleExtractionHG extends SplitHg {
protected int src_sent_len = 0;
protected int ref_sent_len = 0;
protected int g_lm_order = 4; // only used for decide whether to get the LM state by this class or
- // not in compute_state
+ // not in compute_state
static protected boolean do_local_ngram_clip = false;
static protected boolean maitain_length_state = false;
static protected int g_bleu_order = 4;
@@ -76,8 +76,8 @@ public class OracleExtractionHG extends SplitHg {
protected HashMap<String, Integer> tbl_ref_ngrams = new HashMap<String, Integer>();
static boolean always_maintain_seperate_lm_state = true; // if true: the virtual item maintain its
- // own lm state regardless whether
- // lm_order>=g_bleu_order
+ // own lm state regardless whether
+ // lm_order>=g_bleu_order
int lm_feat_id = 0; // the baseline LM feature id
@@ -88,7 +88,7 @@ public class OracleExtractionHG extends SplitHg {
* It seems that the symbol table here should only need to represent monolingual terminals, plus
* nonterminals.
*
- * @param lm_feat_id_
+ * @param lm_feat_id_ a language model feature identifier
*/
public OracleExtractionHG(int lm_feat_id_) {
this.lm_feat_id = lm_feat_id_;
@@ -111,7 +111,7 @@ public class OracleExtractionHG extends SplitHg {
*/
if (6 != args.length) {
System.out
- .println("Usage: java Decoder f_hypergraphs f_rule_tbl f_ref_files f_orc_out lm_order orc_extract_nbest");
+ .println("Usage: java Decoder f_hypergraphs f_rule_tbl f_ref_files f_orc_out lm_order orc_extract_nbest");
System.out.println("num of args is " + args.length);
for (int i = 0; i < args.length; i++) {
System.out.println("arg is: " + args[i]);
@@ -123,12 +123,9 @@ public class OracleExtractionHG extends SplitHg {
String f_ref_files = args[2].trim();
String f_orc_out = args[3].trim();
int lm_order = Integer.parseInt(args[4].trim());
- boolean orc_extract_nbest = Boolean.valueOf(args[5].trim()); // oracle extraction from nbest or
- // hg
+ boolean orc_extract_nbest = Boolean.valueOf(args[5].trim()); // oracle extraction from nbest or hg
- // ??????????????????????????????????????
int baseline_lm_feat_id = 0;
- // ??????????????????????????????????????
KBestExtractor kbest_extractor = null;
int topN = 300;// TODO
@@ -280,7 +277,7 @@ public class OracleExtractionHG extends SplitHg {
DPStateOracle dps = compute_state(parent_item, cur_dt, l_ant_virtual_item, tbl_ref_ngrams,
do_local_ngram_clip, g_lm_order, avg_ref_len, bleu_score, tbl_suffix, tbl_prefix);
VirtualDeduction t_dt = new VirtualDeduction(cur_dt, l_ant_virtual_item, -bleu_score[0]);// cost:
- // -best_bleu
+ // -best_bleu
g_num_virtual_deductions++;
add_deduction(parent_item, virtual_item_sigs, t_dt, dps, true);
}
@@ -355,11 +352,11 @@ public class OracleExtractionHG extends SplitHg {
// ################## deductions *not* under "goal item"
HashMap<String, Integer> new_ngram_counts = new HashMap<String, Integer>();// new ngrams created
- // due to the
- // combination
+ // due to the
+ // combination
HashMap<String, Integer> old_ngram_counts = new HashMap<String, Integer>();// the ngram that has
- // already been
- // computed
+ // already been
+ // computed
int total_hyp_len = 0;
int[] num_ngram_match = new int[g_bleu_order];
int[] en_words = dt.getRule().getEnglish();
@@ -378,7 +375,7 @@ public class OracleExtractionHG extends SplitHg {
left_state_sequence = new ArrayList<Integer>();
right_state_sequence = new ArrayList<Integer>();
correct_lm_order = g_bleu_order; // if lm_order is smaller than g_bleu_order, we will get the
- // lm state by ourself
+ // lm state by ourself
}
// #### get left_state_sequence, right_state_sequence, total_hyp_len, num_ngram_match
@@ -438,7 +435,7 @@ public class OracleExtractionHG extends SplitHg {
// BUG: Whoa, is that an actual hard-coded ID in there? :)
if (final_count < 0) {
throw new RuntimeException("negative count for ngram: " + Vocabulary.word(11844)
- + "; new: " + new_ngram_counts.get(ngram) + "; old: " + old_ngram_counts.get(ngram));
+ + "; new: " + new_ngram_counts.get(ngram) + "; old: " + old_ngram_counts.get(ngram));
}
}
if (final_count > 0) { // TODO: not correct/global ngram clip
@@ -625,7 +622,13 @@ public class OracleExtractionHG extends SplitHg {
}
}
- /** accumulate ngram counts into tbl. */
+ /**
+ * accumulate ngram counts into tbl.
+ * @param tbl a {@link java.util.HashMap} which is used to store ngram counts
+ * @param order todo
+ * @param wrds an {@link java.util.ArrayList} containing {@link java.lang.Integer} word representations
+ * @param ignore_null_equiv_symbol set to true to skip some nGrams
+ */
public void get_ngrams(HashMap<String, Integer> tbl, int order, ArrayList<Integer> wrds,
boolean ignore_null_equiv_symbol) {
for (int i = 0; i < wrds.size(); i++) {
@@ -686,9 +689,9 @@ public class OracleExtractionHG extends SplitHg {
} else {
// BUG: use joshua.util.Regex.spaces.split(...)
num_ngram_match[ngram.split("\\s+").length - 1] += (Integer) hyp_ngram_tbl.get(ngram);// without
- // ngram
- // count
- // clipping
+ // ngram
+ // count
+ // clipping
}
}
}
@@ -772,7 +775,7 @@ public class OracleExtractionHG extends SplitHg {
}
}
}
-
+
@SuppressWarnings("unused")
public boolean contain_ngram(ArrayList<Integer> wrds, int start_pos, int end_pos) {
if (end_pos < start_pos)
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/src/main/java/org/apache/joshua/server/ServerThread.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/server/ServerThread.java b/src/main/java/org/apache/joshua/server/ServerThread.java
index 5f42be6..28c47ed 100644
--- a/src/main/java/org/apache/joshua/server/ServerThread.java
+++ b/src/main/java/org/apache/joshua/server/ServerThread.java
@@ -51,6 +51,7 @@ public class ServerThread extends Thread implements HttpHandler {
*
* @param socket the socket representing the input/output streams
* @param decoder the configured decoder that handles performing translations
+ * @param joshuaConfiguration a populated {@link org.apache.joshua.decoder.JoshuaConfiguration}
*/
public ServerThread(Socket socket, Decoder decoder, JoshuaConfiguration joshuaConfiguration) {
this.joshuaConfiguration = joshuaConfiguration;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 e8f403c..2915685 100644
--- a/src/main/java/org/apache/joshua/subsample/AlignedSubsampler.java
+++ b/src/main/java/org/apache/joshua/subsample/AlignedSubsampler.java
@@ -53,6 +53,7 @@ public class AlignedSubsampler extends Subsampler {
* @param epath path to source E files
* @param apath path to source alignment files
* @param output basename for output files (will append extensions)
+ * @throws IOException if there is an error reading the input file(s)
*/
public void subsample(String filelist, float targetFtoERatio, String extf, String exte,
String exta, String fpath, String epath, String apath, String output) throws IOException {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 36bcab5..31e51e3 100644
--- a/src/main/java/org/apache/joshua/subsample/BiCorpus.java
+++ b/src/main/java/org/apache/joshua/subsample/BiCorpus.java
@@ -29,24 +29,28 @@ import org.apache.joshua.corpus.Phrase;
* @version $LastChangedDate$
*/
public class BiCorpus implements Iterable<PhrasePair> {
- // Making these final requires Java6, doesn't work in Java5
protected final String foreignFileName;
protected final String nativeFileName;
protected final String alignmentFileName;
- // ===============================================================
- // Constructors
- // ===============================================================
/**
* Constructor for unaligned BiCorpus.
+ * @param foreignFileName todo
+ * @param nativeFileName todo
+ * @throws IOException todo
*/
public BiCorpus(String foreignFileName, String nativeFileName) throws IOException {
this(foreignFileName, nativeFileName, null);
}
-
/**
* Constructor for word-aligned BiCorpus.
+ * @param foreignFileName todo
+ * @param nativeFileName todo
+ * @param alignmentFileName todo
+ * @throws IOException todo
+ * @throws IllegalArgumentException todo
+ * @throws IndexOutOfBoundsException todo
*/
public BiCorpus(String foreignFileName, String nativeFileName, String alignmentFileName)
throws IOException, IllegalArgumentException, IndexOutOfBoundsException {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 3dfaffd..eda3bf5 100644
--- a/src/main/java/org/apache/joshua/subsample/BiCorpusFactory.java
+++ b/src/main/java/org/apache/joshua/subsample/BiCorpusFactory.java
@@ -51,17 +51,32 @@ public class BiCorpusFactory {
}
- /** Generate unaligned BiCorpus by default. */
+ /**
+ * Generate unaligned {@link org.apache.joshua.subsample.BiCorpus} by default.
+ * @param f todo
+ * @return an unaligned {@link org.apache.joshua.subsample.BiCorpus}
+ * @throws IOException if there is an error reading input file
+ */
public BiCorpus fromFiles(String f) throws IOException {
return this.unalignedFromFiles(f);
}
- /** Generate unaligned BiCorpus. */
+ /**
+ * Generate unaligned BiCorpus.
+ * @param f todo
+ * @return an unaligned {@link org.apache.joshua.subsample.BiCorpus}
+ * @throws IOException if there is an error reading input file
+ */
public BiCorpus unalignedFromFiles(String f) throws IOException {
return new BiCorpus(fpath + f + extf, epath + f + exte);
}
- /** Generate aligned BiCorpus. */
+ /**
+ * Generate aligned BiCorpus.
+ * @param f todo
+ * @return an aligned {@link org.apache.joshua.subsample.BiCorpus}
+ * @throws IOException if there is an error reading input file
+ */
public BiCorpus alignedFromFiles(String f) throws IOException {
return new BiCorpus(fpath + f + extf, epath + f + exte, apath + f + exta);
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 dac8054..d3cfd89 100644
--- a/src/main/java/org/apache/joshua/subsample/Subsampler.java
+++ b/src/main/java/org/apache/joshua/subsample/Subsampler.java
@@ -81,6 +81,7 @@ public class Subsampler {
* @param fpath path to source F files
* @param epath path to source E files
* @param output basename for output files (will append extensions)
+ * @throws IOException if there is an issue reading one of the input files
*/
public void subsample(String filelist, float targetFtoERatio, String extf, String exte,
String fpath, String epath, String output) throws IOException {
@@ -92,7 +93,13 @@ public class Subsampler {
}
/**
- * The main wrapper for the subsample worker. Closes the PhraseWriter before exiting.
+ * The main wrapper for the subsample worker. Closes the
+ * {@link org.apache.joshua.subsample.PhraseWriter} before exiting.
+ * @param filelist list of source files to subsample from
+ * @param targetFtoERatio goal for ratio of output F length to output E length
+ * @param out a {@link org.apache.joshua.subsample.PhraseWriter} to flush data to
+ * @param bcFactory used to generate a sentence-aligned {@link org.apache.joshua.subsample.BiCorpus}
+ * @throws IOException if there is an issue reading one of the input files
*/
protected void subsample(String filelist, float targetFtoERatio, PhraseWriter out,
BiCorpusFactory bcFactory) throws IOException {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 6772057..ecdb527 100644
--- a/src/main/java/org/apache/joshua/subsample/SubsamplerCLI.java
+++ b/src/main/java/org/apache/joshua/subsample/SubsamplerCLI.java
@@ -69,6 +69,7 @@ public class SubsamplerCLI {
/**
* Return all Options. The HelpFormatter will print them in sorted order, so it doesn't matter
* when we add them. Subclasses should override this method by adding more options.
+ * @return all of the {@link org.apache.commons.cli.Options}
*/
public Options getCliOptions() {
return new Options().addOption(ot).addOption(otest).addOption(of).addOption(oe)
@@ -76,7 +77,9 @@ public class SubsamplerCLI {
}
/**
- * This method should be overridden to return the class used in runSubsampler.
+ * This method should be overridden to return the class used in
+ * {@link org.apache.joshua.subsample.SubsamplerCLI#runSubsampler(String[], int, int, float)}.
+ * @return the {@link org.apache.joshua.subsample.Subsampler} implementation
*/
public String getClassName() {
return Subsampler.class.getName();
@@ -85,6 +88,11 @@ public class SubsamplerCLI {
/**
* Callback to run the subsampler. This function needs access to the variables holding each
* Option, thus all this closure nonsense.
+ * @param testFiles a String array of test files
+ * @param maxN todo
+ * @param targetCount todo
+ * @param ratio todo
+ * @throws IOException if there is an issue whilst reading input files
*/
public void runSubsampler(String[] testFiles, int maxN, int targetCount, float ratio)
throws IOException {
@@ -95,6 +103,7 @@ public class SubsamplerCLI {
/**
* Non-static version of main so that we can define anonymous local classes to override or extend
* the above.
+ * @param args a String array of input options
*/
public void runMain(String[] args) {
Options o = this.getCliOptions();
[2/2] 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/aead6209
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/aead6209
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/aead6209
Branch: refs/heads/JOSHUA-252
Commit: aead62094032c6ee9f02144713e68e1602e9bed8
Parents: 1fc0590
Author: Lewis John McGibbney <le...@gmail.com>
Authored: Wed May 25 08:35:51 2016 -0700
Committer: Lewis John McGibbney <le...@gmail.com>
Committed: Wed May 25 08:35:51 2016 -0700
----------------------------------------------------------------------
.../apache/joshua/corpus/ContiguousPhrase.java | 60 +-
.../java/org/apache/joshua/corpus/Corpus.java | 21 +-
.../java/org/apache/joshua/corpus/Span.java | 4 +-
.../org/apache/joshua/corpus/SymbolTable.java | 598 +++++++++----------
.../apache/joshua/corpus/TerminalIterator.java | 5 +-
.../org/apache/joshua/corpus/Vocabulary.java | 11 +-
.../joshua/corpus/syntax/ArraySyntaxTree.java | 15 +-
.../org/apache/joshua/decoder/ArgsParser.java | 5 +-
.../java/org/apache/joshua/decoder/Decoder.java | 16 +-
.../apache/joshua/decoder/DecoderThread.java | 15 +-
.../joshua/decoder/StructuredTranslation.java | 2 +
.../java/org/apache/joshua/decoder/Support.java | 3 +-
.../decoder/chart_parser/ComputeNodeResult.java | 31 +-
.../joshua/decoder/ff/fragmentlm/Tree.java | 2 +-
.../org/apache/joshua/decoder/ff/lm/KenLM.java | 1 +
.../joshua/decoder/ff/lm/LanguageModelFF.java | 67 ++-
.../decoder/hypergraph/ViterbiExtractor.java | 2 +-
.../apache/joshua/decoder/io/DeNormalize.java | 4 +-
.../apache/joshua/decoder/phrase/Coverage.java | 31 +-
.../apache/joshua/decoder/phrase/Future.java | 37 +-
.../joshua/decoder/phrase/Hypothesis.java | 2 +-
.../joshua/decoder/phrase/PhraseChart.java | 22 +-
.../joshua/decoder/phrase/PhraseTable.java | 13 +-
.../org/apache/joshua/decoder/phrase/Stack.java | 17 +-
.../apache/joshua/decoder/phrase/Stacks.java | 12 +-
.../joshua/decoder/phrase/TargetPhrases.java | 5 +-
.../decoder/segment_file/ConstraintRule.java | 9 +-
.../decoder/segment_file/ConstraintSpan.java | 4 +
.../joshua/decoder/segment_file/Sentence.java | 17 +-
.../joshua/decoder/segment_file/Token.java | 6 +-
.../java/org/apache/joshua/lattice/Lattice.java | 18 +-
.../java/org/apache/joshua/lattice/Node.java | 1 +
.../java/org/apache/joshua/metrics/BLEU.java | 9 +-
.../apache/joshua/metrics/EvaluationMetric.java | 6 +-
.../joshua/oracle/OracleExtractionHG.java | 45 +-
.../org/apache/joshua/server/ServerThread.java | 1 +
.../joshua/subsample/AlignedSubsampler.java | 1 +
.../org/apache/joshua/subsample/BiCorpus.java | 14 +-
.../joshua/subsample/BiCorpusFactory.java | 21 +-
.../org/apache/joshua/subsample/Subsampler.java | 9 +-
.../apache/joshua/subsample/SubsamplerCLI.java | 11 +-
41 files changed, 603 insertions(+), 570 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/src/main/java/org/apache/joshua/corpus/ContiguousPhrase.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/corpus/ContiguousPhrase.java b/src/main/java/org/apache/joshua/corpus/ContiguousPhrase.java
index 855a7c1..af669b7 100644
--- a/src/main/java/org/apache/joshua/corpus/ContiguousPhrase.java
+++ b/src/main/java/org/apache/joshua/corpus/ContiguousPhrase.java
@@ -31,37 +31,16 @@ import java.util.List;
*/
public class ContiguousPhrase extends AbstractPhrase {
- // ===============================================================
- // Constants
- // ===============================================================
-
- // ===============================================================
- // Member variables
- // ===============================================================
-
protected int startIndex;
protected int endIndex;
protected Corpus corpusArray;
- // ===============================================================
- // Constructor(s)
- // ===============================================================
-
public ContiguousPhrase(int startIndex, int endIndex, Corpus corpusArray) {
this.startIndex = startIndex;
this.endIndex = endIndex;
this.corpusArray = corpusArray;
}
-
- // ===============================================================
- // Public
- // ===============================================================
-
- // ===========================================================
- // Accessor methods (set/get)
- // ===========================================================
-
/**
* This method copies the phrase into an array of ints. This method should be avoided if possible.
*
@@ -75,23 +54,15 @@ public class ContiguousPhrase extends AbstractPhrase {
return words;
}
-
public int getWordID(int position) {
return corpusArray.getWordID(startIndex + position);
// return corpusArray.corpus[startIndex+position];
}
-
public int size() {
return endIndex - startIndex;
}
-
- // ===========================================================
- // Methods
- // ===========================================================
-
-
/**
* Gets all possible subphrases of this phrase, up to and including the phrase itself. For
* example, the phrase "I like cheese ." would return the following:
@@ -114,7 +85,6 @@ public class ContiguousPhrase extends AbstractPhrase {
return getSubPhrases(size());
}
-
/**
* Returns a list of subphrases only of length <code>maxLength</code> or smaller.
*
@@ -134,7 +104,6 @@ public class ContiguousPhrase extends AbstractPhrase {
return phrases;
}
-
/**
* creates a new phrase object from the indexes provided.
* <P>
@@ -148,36 +117,9 @@ public class ContiguousPhrase extends AbstractPhrase {
return new ContiguousPhrase(startIndex + start, startIndex + end, corpusArray);
}
-
- // ===============================================================
- // Protected
- // ===============================================================
-
- // ===============================================================
- // Methods
- // ===============================================================
-
-
- // ===============================================================
- // Private
- // ===============================================================
-
- // ===============================================================
- // Methods
- // ===============================================================
-
-
- // ===============================================================
- // Static
- // ===============================================================
-
-
- // ===============================================================
- // Main
- // ===============================================================
-
/**
* Main contains test code
+ * @param args String array of arguments used to run this class.
*/
public static void main(String[] args) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/src/main/java/org/apache/joshua/corpus/Corpus.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/corpus/Corpus.java b/src/main/java/org/apache/joshua/corpus/Corpus.java
index a943dd2..1a7d1b0 100755
--- a/src/main/java/org/apache/joshua/corpus/Corpus.java
+++ b/src/main/java/org/apache/joshua/corpus/Corpus.java
@@ -34,6 +34,7 @@ public interface Corpus { // extends Externalizable {
// ===============================================================
/**
+ * @param position the position at which we want to obtain a word ID
* @return the integer representation of the Word at the specified position in the corpus.
*/
int getWordID(int position);
@@ -51,7 +52,7 @@ public interface Corpus { // extends Externalizable {
/**
* Gets the sentence index of each specified position.
*
- * @param position Index into the corpus
+ * @param positions Index into the corpus
* @return array of the sentence indices associated with the specified positions in the corpus.
*/
int[] getSentenceIndices(int[] positions);
@@ -60,6 +61,7 @@ public interface Corpus { // extends Externalizable {
* Gets the position in the corpus of the first word of the specified sentence. If the sentenceID
* is outside of the bounds of the sentences, then it returns the last position in the corpus + 1.
*
+ * @param sentenceID a specific sentence to obtain a position for
* @return the position in the corpus of the first word of the specified sentence. If the
* sentenceID is outside of the bounds of the sentences, then it returns the last position
* in the corpus + 1.
@@ -69,6 +71,7 @@ public interface Corpus { // extends Externalizable {
/**
* Gets the exclusive end position of a sentence in the corpus.
*
+ * @param sentenceID a specific sentence to obtain an end position for
* @return the position in the corpus one past the last word of the specified sentence. If the
* sentenceID is outside of the bounds of the sentences, then it returns one past the last
* position in the corpus.
@@ -113,7 +116,7 @@ public interface Corpus { // extends Externalizable {
* @param phrase the superphrase that the comparsion phrase is drawn from
* @param phraseStart the point in the phrase where the comparison begins (inclusive)
* @param phraseEnd the point in the phrase where the comparison ends (exclusive)
- * @return an int that follows the conventions of java.util.Comparator.compareTo()
+ * @return an int that follows the conventions of {@link java.util.Comparator#compare(Object, Object)}
*/
int comparePhrase(int corpusStart, Phrase phrase, int phraseStart, int phraseEnd);
@@ -122,9 +125,9 @@ public interface Corpus { // extends Externalizable {
* Compares the phrase that starts at position start with the phrase passed in. Compares the
* entire phrase.
*
- * @param corpusStart
- * @param phrase
- * @return
+ * @param corpusStart position start
+ * @param phrase {@link org.apache.joshua.corpus.Phrase} to compare against
+ * @return an int that follows the conventions of {@link java.util.Comparator#compare(Object, Object)}
*/
int comparePhrase(int corpusStart, Phrase phrase);
@@ -134,15 +137,15 @@ public interface Corpus { // extends Externalizable {
* @param position1 the position in the corpus where the first suffix begins
* @param position2 the position in the corpus where the second suffix begins
* @param maxComparisonLength a cutoff point to stop the comparison
- * @return an int that follows the conventions of java.util.Comparator.compareTo()
+ * @return an int that follows the conventions of {@link java.util.Comparator#compare(Object, Object)}
*/
int compareSuffixes(int position1, int position2, int maxComparisonLength);
/**
*
- * @param startPosition
- * @param endPosition
- * @return
+ * @param startPosition start position for phrase
+ * @param endPosition end position for phrase
+ * @return the {@link org.apache.joshua.corpus.ContiguousPhrase}
*/
ContiguousPhrase getPhrase(int startPosition, int endPosition);
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/src/main/java/org/apache/joshua/corpus/Span.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/corpus/Span.java b/src/main/java/org/apache/joshua/corpus/Span.java
index 753b007..414fe95 100644
--- a/src/main/java/org/apache/joshua/corpus/Span.java
+++ b/src/main/java/org/apache/joshua/corpus/Span.java
@@ -90,8 +90,8 @@ public class Span implements Iterable<Integer>, Comparable<Span> {
/**
* Returns true if the other span does not intersect with this one.
- * @param o
- * @return
+ * @param o new {@link org.apache.joshua.corpus.Span} to check for intersection
+ * @return true if the other span does not intersect with this one
*/
public boolean disjointFrom(Span o) {
if (start < o.start) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 b108477..274e8b9 100644
--- a/src/main/java/org/apache/joshua/corpus/SymbolTable.java
+++ b/src/main/java/org/apache/joshua/corpus/SymbolTable.java
@@ -17,9 +17,9 @@
* under the License.
*/
package org.apache.joshua.corpus;
-
+
import java.util.Collection;
-
+
/**
* Represents a symbol table capable of mapping between strings and
* symbols.
@@ -29,303 +29,299 @@ import java.util.Collection;
* @version $LastChangedDate: 2009-11-24 23:07:43 -0600 (Tue, 24 Nov 2009) $
*/
public interface SymbolTable {
-
- //TODO Remove all hard-coded references to nonterminals
-
- /**
- * The unknown word's ID will be the size of the vocabulary,
- * ensuring that it is outside of the vocabulary. Note that
- * for vocabularies which have not been fixed yet, this
- * means the actual value is volatile and therefore a word
- * ID can only be compared against UNKNOWN_WORD at the time
- * the word ID is generated (otherwise unknown words can
- * become "known" if new words are added to the vocabulary
- * before testing).
- * <p>
- * Negative IDs are reserved for non-terminals.
- *
- * Zero is reserved as the UNKNOWN_WORD.
- */
- int UNKNOWN_WORD = 1;
-
- /** String representation for out-of-vocabulary words. */
- String UNKNOWN_WORD_STRING = "<unk>";
-
- /**
- * Integer representation of the bare (non-indexed) nonterminal X,
- * which represents a wild-card gap in a phrase.
- * <p>
- * All nonterminals are guaranteed to be represented by negative integers.
- */
- int X = -1;
-
- /**
- * String representation of the bare (non-indexed) nonterminal X,
- * which represents a wild-card gap in a phrase.
- */
- String X_STRING = "[X]";
-
-
-
- /**
- * String representation of the nonterminal X with index 1,
- * which represents a wild-card gap in a phrase.
- */
- String X1_STRING = "[X,1]";
-
-
-
- /**
- * String representation of the nonterminal X with index 2,
- * which represents a wild-card gap in a phrase.
- */
- String X2_STRING = "[X,2]";
-
- /**
- * Integer representation of the nonterminal S.
- * <p>
- * All nonterminals are guaranteed to be represented by negative integers.
- */
- int S = -4;
-
- /**
- * String representation of the nonterminal S..
- */
- String S_STRING = "[S]";
-
- /**
- * Integer representation of the nonterminal X with index 1,
- * which represents a wild-card gap in a phrase.
- * <p>
- * All nonterminals are guaranteed to be represented by negative integers.
- */
- int S1 = -5;
-
- /**
- * String representation of the nonterminal X with index 2,
- * which represents a wild-card gap in a phrase.
- */
- String S1_STRING = "[S,1]";
-
- /**
- * Gets a unique integer identifier for the nonterminal.
- * <p>
- * The integer returned is guaranteed to be a negative number.
- *
- * If the nonterminal is {@link #X_STRING},
- * then the value returned must be {@link #X}.
- *
- * Otherwise, the value returned must be a negative number
- * whose value is less than {@link X}.
- *
- * @param nonterminal Nonterminal symbol
- * @return a unique integer identifier for the nonterminal
- */
- int addNonterminal(String nonterminal);
-
- /**
- * Gets a unique integer identifier for the terminal.
- *
- * @param terminal Terminal symbol
- * @return a unique integer identifier for the terminal
- */
- int addTerminal(String terminal);
-
- /**
- * Gets the unique integer identifiers for the words.
- *
- * @param words Array of symbols
- * @return the unique integer identifiers for the words
- */
- int[] addTerminals(String[] words);
-
- /**
- * Gets the unique integer identifiers for the words
- * in the sentence.
- *
- * @param sentence Space-delimited string of symbols
- * @return the unique integer identifiers for the words
- * in the sentence
- */
- int[] addTerminals(String sentence);
-
- /**
- * Gets an integer identifier for the word.
- * <p>
- * If the word is in the vocabulary, the integer returned
- * will uniquely identify that word.
- * <p>
- * If the word is not in the vocabulary, the integer returned
- * by <code>getUnknownWordID</code> may be returned.
- *
- * Alternatively, implementations may, if they choose, add
- * unknown words and assign them a symbol ID instead of
- * returning <code>getUnknownWordID</code>.
- *
- * @see #getUnknownWordID
- * @return the unique integer identifier for wordString,
- * 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);
-
- /**
- * Gets the integer identifiers for all words in the provided
- * sentence.
- * <p>
- * The sentence will be split (on spaces) into words, then
- * the integer identifier for each word will be retrieved
- * using <code>getID</code>.
- *
- * @see #getID(String)
- * @param sentence String of words, separated by spaces.
- * @return Array of integer identifiers for each word in
- * the sentence
- */
- int[] getIDs(String sentence);
-
- /**
- * Gets the String that corresponds to the specified integer
- * identifier.
- * <p>
- * If the identifier is in the symbol vocabulary, the String
- * returned will correspond to that identifier.
- *
- * Otherwise, the String returned by <code>getUnknownWord<code>
- * will be returned.
- *
- * @return the String that corresponds to the specified
- * integer identifier, or the result of
- * <code>getUnknownWord</code> if the identifier
- * does not correspond to a word in the vocabulary
- */
- String getTerminal(int wordID);
-
- /**
- * Gets the String that corresponds to the specified integer
- * identifier.
- * <p>
- * This method can be called for terminals or nonterminals.
- *
- * @param tokenID Integer identifier
- * @return the String that corresponds to the specified
- * integer identifier
- */
- String getWord(int tokenID);
-
- /**
- * Gets the String that corresponds to the sequence of
- * specified integer identifiers.
- *
- * @param ids Sequence of integer identifiers
- * @return the String that corresponds to the sequence of
- * specified integer identifiers
- */
- String getWords(int[] ids);
-
- /**
- *
- * @param wordIDs
- * @return
- */
- String getTerminals(int[] wordIDs);
-
- /**
- * Gets a collection over all symbol identifiers for the
- * vocabulary.
- *
- * @return a collection over all symbol identifiers for the
- * vocabulary
- */
- Collection<Integer> getAllIDs();
-
- /**
- * Gets the list of all words represented by this vocabulary.
- *
- * @return the list of all words represented by this
- * vocabulary
- */
- Collection<String> getWords();
-
- /**
- * Gets the number of unique words in the vocabulary.
- *
- * @return the number of unique words in the vocabulary.
- */
- int size();
-
- /**
- * Gets the integer symbol representation of the unknown
- * word.
- *
- * @return the integer symbol representation of the unknown
- * word.
- */
- int getUnknownWordID();
-
- /**
- * Gets the string representation of the unknown word.
- *
- * @return the string representation of the unknown word.
- */
- String getUnknownWord();
-
- /**
- * Returns <code>true</code> if the symbol id represents a
- * nonterminal, <code>false</code> otherwise.
- *
- * @param id
- * @return <code>true</code> if the symbol id represents a
- * nonterminal, <code>false</code> otherwise.
- */
- boolean isNonterminal(int id);
-
- /**
- * Gets the lowest-valued allowable terminal symbol id in
- * this table.
- *
- * @return the lowest-valued allowable terminal symbol id
- * in this table.
- */
- int getLowestID();
-
-
- /**
- * Gets the highest-valued allowable terminal symbol id in
- * this table.
- * <p>
- * NOTE: This may or may not return the same value as
- * <code>size</code>.
- *
- * @return the highest-valued allowable terminal symbol id
- * in this table.
- */
- int getHighestID();
-
- /**
- *
- *
- * @param id
- * @return
- */
- int getTargetNonterminalIndex(int id);//first convert id to its String mapping, then call the function below
-
- /**
- *
- *
- * @param word
- * @return
- */
- int getTargetNonterminalIndex(String word);
-
- /**
- *
- *
- * @param wordIDs
- * @param ntIndexIncrements
- * @return
- */
- String getWords(int[] wordIDs, boolean ntIndexIncrements);
-
+
+ //TODO Remove all hard-coded references to nonterminals
+
+ /**
+ * The unknown word's ID will be the size of the vocabulary,
+ * ensuring that it is outside of the vocabulary. Note that
+ * for vocabularies which have not been fixed yet, this
+ * means the actual value is volatile and therefore a word
+ * ID can only be compared against UNKNOWN_WORD at the time
+ * the word ID is generated (otherwise unknown words can
+ * become "known" if new words are added to the vocabulary
+ * before testing).
+ * <p>
+ * Negative IDs are reserved for non-terminals.
+ *
+ * Zero is reserved as the UNKNOWN_WORD.
+ */
+ int UNKNOWN_WORD = 1;
+
+ /** String representation for out-of-vocabulary words. */
+ String UNKNOWN_WORD_STRING = "<unk>";
+
+ /**
+ * Integer representation of the bare (non-indexed) nonterminal X,
+ * which represents a wild-card gap in a phrase.
+ * <p>
+ * All nonterminals are guaranteed to be represented by negative integers.
+ */
+ int X = -1;
+
+ /**
+ * String representation of the bare (non-indexed) nonterminal X,
+ * which represents a wild-card gap in a phrase.
+ */
+ String X_STRING = "[X]";
+
+
+
+ /**
+ * String representation of the nonterminal X with index 1,
+ * which represents a wild-card gap in a phrase.
+ */
+ String X1_STRING = "[X,1]";
+
+
+
+ /**
+ * String representation of the nonterminal X with index 2,
+ * which represents a wild-card gap in a phrase.
+ */
+ String X2_STRING = "[X,2]";
+
+ /**
+ * Integer representation of the nonterminal S.
+ * <p>
+ * All nonterminals are guaranteed to be represented by negative integers.
+ */
+ int S = -4;
+
+ /**
+ * String representation of the nonterminal S..
+ */
+ String S_STRING = "[S]";
+
+ /**
+ * Integer representation of the nonterminal X with index 1,
+ * which represents a wild-card gap in a phrase.
+ * <p>
+ * All nonterminals are guaranteed to be represented by negative integers.
+ */
+ int S1 = -5;
+
+ /**
+ * String representation of the nonterminal X with index 2,
+ * which represents a wild-card gap in a phrase.
+ */
+ String S1_STRING = "[S,1]";
+
+ /**
+ * Gets a unique integer identifier for the nonterminal.
+ * <p>
+ * The integer returned is guaranteed to be a negative number.
+ *
+ * If the nonterminal is {@link #X_STRING},
+ * then the value returned must be {@link #X}.
+ *
+ * Otherwise, the value returned must be a negative number
+ * whose value is less than {@link X}.
+ *
+ * @param nonterminal Nonterminal symbol
+ * @return a unique integer identifier for the nonterminal
+ */
+ int addNonterminal(String nonterminal);
+
+ /**
+ * Gets a unique integer identifier for the terminal.
+ *
+ * @param terminal Terminal symbol
+ * @return a unique integer identifier for the terminal
+ */
+ int addTerminal(String terminal);
+
+ /**
+ * Gets the unique integer identifiers for the words.
+ *
+ * @param words Array of symbols
+ * @return the unique integer identifiers for the words
+ */
+ int[] addTerminals(String[] words);
+
+ /**
+ * Gets the unique integer identifiers for the words
+ * in the sentence.
+ *
+ * @param sentence Space-delimited string of symbols
+ * @return the unique integer identifiers for the words
+ * in the sentence
+ */
+ int[] addTerminals(String sentence);
+
+ /**
+ * Gets an integer identifier for the word.
+ * <p>
+ * If the word is in the vocabulary, the integer returned
+ * will uniquely identify that word.
+ * <p>
+ * If the word is not in the vocabulary, the integer returned
+ * by <code>getUnknownWordID</code> may be returned.
+ *
+ * Alternatively, implementations may, if they choose, add
+ * unknown words and assign them a symbol ID instead of
+ * returning <code>getUnknownWordID</code>.
+ *
+ * @see #getUnknownWordID
+ * @return the unique integer identifier for wordString,
+ * 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);
+
+ /**
+ * Gets the integer identifiers for all words in the provided
+ * sentence.
+ * <p>
+ * The sentence will be split (on spaces) into words, then
+ * the integer identifier for each word will be retrieved
+ * using <code>getID</code>.
+ *
+ * @see #getID(String)
+ * @param sentence String of words, separated by spaces.
+ * @return Array of integer identifiers for each word in
+ * the sentence
+ */
+ int[] getIDs(String sentence);
+
+ /**
+ * Gets the String that corresponds to the specified integer
+ * identifier.
+ * <p>
+ * If the identifier is in the symbol vocabulary, the String
+ * returned will correspond to that identifier.
+ *
+ * Otherwise, the String returned by <code>getUnknownWord</code>
+ * will be returned.
+ *
+ * @param wordID an integer identifier for a specific String
+ * @return the String that corresponds to the specified
+ * integer identifier, or the result of
+ * <code>getUnknownWord</code> if the identifier
+ * does not correspond to a word in the vocabulary
+ */
+ String getTerminal(int wordID);
+
+ /**
+ * Gets the String that corresponds to the specified integer
+ * identifier.
+ * <p>
+ * This method can be called for terminals or nonterminals.
+ *
+ * @param tokenID Integer identifier
+ * @return the String that corresponds to the specified
+ * integer identifier
+ */
+ String getWord(int tokenID);
+
+ /**
+ * Gets the String that corresponds to the sequence of
+ * specified integer identifiers.
+ *
+ * @param ids Sequence of integer identifiers
+ * @return the String that corresponds to the sequence of
+ * specified integer identifiers
+ */
+ String getWords(int[] ids);
+
+ /**
+ *
+ * @param wordIDs an int[] of identifiers for a specific Strings
+ * @return the String that corresponds to the specified
+ * integer identifiers
+ */
+ String getTerminals(int[] wordIDs);
+
+ /**
+ * Gets a collection over all symbol identifiers for the
+ * vocabulary.
+ *
+ * @return a collection over all symbol identifiers for the
+ * vocabulary
+ */
+ Collection<Integer> getAllIDs();
+
+ /**
+ * Gets the list of all words represented by this vocabulary.
+ *
+ * @return the list of all words represented by this
+ * vocabulary
+ */
+ Collection<String> getWords();
+
+ /**
+ * Gets the number of unique words in the vocabulary.
+ *
+ * @return the number of unique words in the vocabulary.
+ */
+ int size();
+
+ /**
+ * Gets the integer symbol representation of the unknown
+ * word.
+ *
+ * @return the integer symbol representation of the unknown
+ * word.
+ */
+ int getUnknownWordID();
+
+ /**
+ * Gets the string representation of the unknown word.
+ *
+ * @return the string representation of the unknown word.
+ */
+ String getUnknownWord();
+
+ /**
+ * Returns <code>true</code> if the symbol id represents a
+ * nonterminal, <code>false</code> otherwise.
+ *
+ * @param id int symbol id
+ * @return <code>true</code> if the symbol id represents a
+ * nonterminal, <code>false</code> otherwise.
+ */
+ boolean isNonterminal(int id);
+
+ /**
+ * Gets the lowest-valued allowable terminal symbol id in
+ * this table.
+ *
+ * @return the lowest-valued allowable terminal symbol id
+ * in this table.
+ */
+ int getLowestID();
+
+
+ /**
+ * Gets the highest-valued allowable terminal symbol id in
+ * this table.
+ * <p>
+ * NOTE: This may or may not return the same value as
+ * <code>size</code>.
+ *
+ * @return the highest-valued allowable terminal symbol id
+ * in this table.
+ */
+ int getHighestID();
+
+ /**
+ * @param id todo
+ * @return todo
+ */
+ int getTargetNonterminalIndex(int id);//first convert id to its String mapping, then call the function below
+
+ /**
+ * @param word todo
+ * @return todo
+ */
+ int getTargetNonterminalIndex(String word);
+
+ /**
+ * @param wordIDs todo
+ * @param ntIndexIncrements todo
+ * @return todo
+ */
+ String getWords(int[] wordIDs, boolean ntIndexIncrements);
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/src/main/java/org/apache/joshua/corpus/TerminalIterator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/corpus/TerminalIterator.java b/src/main/java/org/apache/joshua/corpus/TerminalIterator.java
index 8f2a576..e82b4cc 100644
--- a/src/main/java/org/apache/joshua/corpus/TerminalIterator.java
+++ b/src/main/java/org/apache/joshua/corpus/TerminalIterator.java
@@ -39,8 +39,7 @@ public class TerminalIterator implements Iterator<Integer> {
/**
* Constructs an iterator for the terminals in the given list of words.
*
- * @param vocab
- * @param words
+ * @param words array of words
*/
public TerminalIterator(int[] words) {
this.words = words;
@@ -75,7 +74,7 @@ public class TerminalIterator implements Iterator<Integer> {
/**
* Unsupported operation, guaranteed to throw an UnsupportedOperationException.
*
- * @throws UnsupportedOperationException
+ * @throws UnsupportedOperationException operation not supported yet!
*/
public void remove() {
throw new UnsupportedOperationException();
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 f89a198..582efc6 100644
--- a/src/main/java/org/apache/joshua/corpus/Vocabulary.java
+++ b/src/main/java/org/apache/joshua/corpus/Vocabulary.java
@@ -83,9 +83,9 @@ public class Vocabulary implements Externalizable {
* Reads a vocabulary from file. This deletes any additions to the vocabulary made prior to
* reading the file.
*
- * @param file_name
+ * @param vocab_file path to a vocabulary file
* @return Returns true if vocabulary was read without mismatches or collisions.
- * @throws IOException
+ * @throws IOException of the file cannot be found or read properly
*/
public static boolean read(final File vocab_file) throws IOException {
DataInputStream vocab_stream =
@@ -131,6 +131,9 @@ public class Vocabulary implements Externalizable {
* 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?
+ *
+ * @param token a token to obtain an id for
+ * @return the token id
*/
public static int id(String token) {
// First attempt an optimistic read
@@ -233,8 +236,8 @@ public class Vocabulary implements Externalizable {
/**
* Returns true if the Vocabulary ID represents a nonterminal.
*
- * @param id
- * @return
+ * @param id vocabularly ID to check
+ * @return true if the Vocabulary ID represents a nonterminal
*/
public static boolean nt(int id) {
return (id < 0);
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/src/main/java/org/apache/joshua/corpus/syntax/ArraySyntaxTree.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/corpus/syntax/ArraySyntaxTree.java b/src/main/java/org/apache/joshua/corpus/syntax/ArraySyntaxTree.java
index dc98585..f374279 100644
--- a/src/main/java/org/apache/joshua/corpus/syntax/ArraySyntaxTree.java
+++ b/src/main/java/org/apache/joshua/corpus/syntax/ArraySyntaxTree.java
@@ -280,17 +280,14 @@ public class ArraySyntaxTree implements SyntaxTree, Externalizable {
// TODO: bothersome no-backwards-arrays method.
}
}
-
return labels;
}
-
@Override
public int[] getTerminals() {
return getTerminals(0, terminals.size());
}
-
@Override
public int[] getTerminals(int from, int to) {
int[] span = new int[to - from];
@@ -299,40 +296,32 @@ public class ArraySyntaxTree implements SyntaxTree, Externalizable {
return span;
}
-
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
// TODO Auto-generated method stub
-
}
-
public void writeExternal(ObjectOutput out) throws IOException {
// TODO Auto-generated method stub
-
}
-
/**
* Reads Penn Treebank format file
+ * @param file_name the string path of the Penn Treebank file
+ * @throws IOException if the file does not exist
*/
public void readExternalText(String file_name) throws IOException {
LineReader reader = new LineReader(file_name);
-
initialize();
-
for (String line : reader) {
if (line.trim().equals("")) continue;
appendFromPennFormat(line);
}
}
-
public void writeExternalText(String file_name) throws IOException {
// TODO Auto-generated method stub
-
}
-
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/src/main/java/org/apache/joshua/decoder/ArgsParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ArgsParser.java b/src/main/java/org/apache/joshua/decoder/ArgsParser.java
index 0346a0f..97aa2ec 100644
--- a/src/main/java/org/apache/joshua/decoder/ArgsParser.java
+++ b/src/main/java/org/apache/joshua/decoder/ArgsParser.java
@@ -37,8 +37,9 @@ public class ArgsParser {
* Parse the arguments passed from the command line when the JoshuaDecoder application was
* executed from the command line.
*
- * @param args
- * @throws IOException
+ * @param args string array of input arguments
+ * @param joshuaConfiguration the {@link org.apache.joshua.decoder.JoshuaConfiguration}
+ * @throws IOException if there is an error wit the input arguments
*/
public ArgsParser(String[] args, JoshuaConfiguration joshuaConfiguration) throws IOException {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 29ccce6..be94d71 100644
--- a/src/main/java/org/apache/joshua/decoder/Decoder.java
+++ b/src/main/java/org/apache/joshua/decoder/Decoder.java
@@ -116,7 +116,8 @@ public class Decoder {
/**
* Constructor method that creates a new decoder using the specified configuration file.
*
- * @param configFile Name of configuration file.
+ * @param joshuaConfiguration a populated {@link org.apache.joshua.decoder.JoshuaConfiguration}
+ * @param configFile name of configuration file.
*/
public Decoder(JoshuaConfiguration joshuaConfiguration, String configFile) {
this(joshuaConfiguration);
@@ -127,6 +128,7 @@ public class Decoder {
* Factory method that creates a new decoder using the specified configuration file.
*
* @param configFile Name of configuration file.
+ * @return a configured {@link org.apache.joshua.decoder.Decoder}
*/
public static Decoder createDecoder(String configFile) {
JoshuaConfiguration joshuaConfiguration = new JoshuaConfiguration();
@@ -153,6 +155,8 @@ public class Decoder {
* <p>
* This method is called by unit tests or any outside packages (e.g., MERT) relying on the
* decoder.
+ * @param joshuaConfiguration a {@link org.apache.joshua.decoder.JoshuaConfiguration} object
+ * @return an uninitialized decoder for use in testing
*/
static public Decoder getUninitalizedDecoder(JoshuaConfiguration joshuaConfiguration) {
return new Decoder(joshuaConfiguration);
@@ -437,9 +441,9 @@ public class Decoder {
* (possibly boundless) set of input sentences. Each request launches its own thread to read the
* sentences of the request.
*
- * @param request
- * @return an iterable set of Translation objects
- * @throws IOException
+ * @param request the populated {@link org.apache.joshua.decoder.io.TranslationRequestStream}
+ * @param out an appropriate {@link java.io.OutputStream} to write results to
+ * @throws IOException if there is an error with the input stream or writing the output
*/
public void decodeAll(TranslationRequestStream request, OutputStream out) throws IOException {
Translations translations = new Translations(request);
@@ -497,8 +501,8 @@ public class Decoder {
/**
* We can also just decode a single sentence.
*
- * @param sentence
- * @return The translated sentence
+ * @param sentence {@link org.apache.joshua.lattice.Lattice} input
+ * @return the sentence {@link org.apache.joshua.decoder.Translation}
*/
public Translation decode(Sentence sentence) {
// Get a thread.
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 c5835fd..0f80335 100644
--- a/src/main/java/org/apache/joshua/decoder/DecoderThread.java
+++ b/src/main/java/org/apache/joshua/decoder/DecoderThread.java
@@ -91,6 +91,7 @@ public class DecoderThread extends Thread {
* Translate a sentence.
*
* @param sentence The sentence to be translated.
+ * @return the sentence {@link org.apache.joshua.decoder.Translation}
*/
public Translation translate(Sentence sentence) {
@@ -105,7 +106,7 @@ public class DecoderThread extends Thread {
Decoder.LOG(1, String.format("Translation %d: Translation took 0 seconds", sentence.id()));
return new Translation(sentence, null, featureFunctions, joshuaConfiguration);
}
-
+
long startTime = System.currentTimeMillis();
int numGrammars = allGrammars.size();
@@ -113,7 +114,7 @@ public class DecoderThread extends Thread {
for (int i = 0; i < allGrammars.size(); i++)
grammars[i] = allGrammars.get(i);
-
+
if (joshuaConfiguration.segment_oovs)
sentence.segmentOOVs(grammars);
@@ -127,7 +128,7 @@ public class DecoderThread extends Thread {
if (joshuaConfiguration.search_algorithm.equals("stack")) {
Stacks stacks = new Stacks(sentence, this.featureFunctions, grammars, joshuaConfiguration);
-
+
hypergraph = stacks.search();
} else {
/* Seeding: the chart only sees the grammars, not the factories */
@@ -135,10 +136,10 @@ public class DecoderThread extends Thread {
joshuaConfiguration.goal_symbol, joshuaConfiguration);
hypergraph = (joshuaConfiguration.use_dot_chart)
- ? chart.expand()
- : chart.expandSansDotChart();
+ ? chart.expand()
+ : chart.expandSansDotChart();
}
-
+
} catch (java.lang.OutOfMemoryError e) {
Decoder.LOG(1, String.format("Input %d: out of memory", sentence.id()));
hypergraph = null;
@@ -155,7 +156,7 @@ public class DecoderThread extends Thread {
}
/*****************************************************************************************/
-
+
/*
* Synchronous parsing.
*
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 bdfde54..8aa518e 100644
--- a/src/main/java/org/apache/joshua/decoder/StructuredTranslation.java
+++ b/src/main/java/org/apache/joshua/decoder/StructuredTranslation.java
@@ -106,6 +106,7 @@ public class StructuredTranslation {
/**
* Returns a list of target to source alignments.
+ * @return a list of target to source alignments
*/
public List<List<Integer>> getTranslationWordAlignments() {
return translationWordAlignments;
@@ -117,6 +118,7 @@ public class StructuredTranslation {
/**
* Time taken to build output information from the hypergraph.
+ * @return the time taken to build output information from the hypergraph
*/
public Float getExtractionTime() {
return extractionTime;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 22bfe89..e513aef 100644
--- a/src/main/java/org/apache/joshua/decoder/Support.java
+++ b/src/main/java/org/apache/joshua/decoder/Support.java
@@ -33,14 +33,15 @@ public class Support {
return (a > b) ? a : b;
}
-
public static int[] toArray(List<Integer> in) {
return subIntArray(in, 0, in.size());
}
/**
+ * @param in a {@link java.util.List} of Integer
* @param start inclusive
* @param end exclusive
+ * @return sub int[] from start to end
*/
public static int[] subIntArray(List<Integer> in, int start, int end) {
int[] res = new int[end - start];
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 ce0b190..73c3cd0 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
@@ -52,13 +52,20 @@ public class ComputeNodeResult {
// The StateComputer objects themselves serve as keys.
private List<DPState> dpStates;
-
+
/**
* Computes the new state(s) that are produced when applying the given rule to the list of tail
* nodes. Also computes a range of costs of doing so (the transition cost, the total (Viterbi)
* cost, and a score that includes a future cost estimate).
*
* Old version that doesn't use the derivation state.
+ * @param featureFunctions {@link java.util.List} of {@link org.apache.joshua.decoder.ff.FeatureFunction}'s
+ * @param rule {@link org.apache.joshua.decoder.ff.tm.Rule} to use when computing th node result
+ * @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
*/
public ComputeNodeResult(List<FeatureFunction> featureFunctions, Rule rule, List<HGNode> tailNodes,
int i, int j, SourcePath sourcePath, Sentence sentence) {
@@ -66,12 +73,12 @@ public class ComputeNodeResult {
// The total Viterbi cost of this edge. This is the Viterbi cost of the tail nodes, plus
// whatever costs we incur applying this rule to create a new hyperedge.
float viterbiCost = 0.0f;
-
+
if (Decoder.VERBOSE >= 4) {
System.err.println("ComputeNodeResult():");
System.err.println("-> RULE " + rule);
}
-
+
/*
* Here we sum the accumulated cost of each of the tail nodes. The total cost of the new
* hyperedge (the inside or Viterbi cost) is the sum of these nodes plus the cost of the
@@ -95,7 +102,7 @@ public class ComputeNodeResult {
// The future cost estimate is a heuristic estimate of the outside cost of this edge.
float futureCostEstimate = 0.0f;
-
+
/*
* We now iterate over all the feature functions, computing their cost and their expected future
* cost.
@@ -105,7 +112,7 @@ public class ComputeNodeResult {
DPState newState = feature.compute(rule, tailNodes, i, j, sourcePath, sentence, acc);
transitionCost += acc.getScore();
-
+
if (Decoder.VERBOSE >= 4)
System.err.println(String.format("-> FEATURE %s = %.3f * %.3f = %.3f",
feature.getName(), acc.getScore() / Decoder.weights.getSparse(feature.getName()),
@@ -116,19 +123,19 @@ public class ComputeNodeResult {
allDPStates.add(((StatefulFF)feature).getStateIndex(), newState);
}
}
-
+
viterbiCost += transitionCost;
if (Decoder.VERBOSE >= 4)
System.err.println(String.format("-> COST = %.3f", transitionCost));
-
+
// Set the final results.
this.pruningCostEstimate = viterbiCost + futureCostEstimate;
this.viterbiCost = viterbiCost;
this.transitionCost = transitionCost;
this.dpStates = allDPStates;
}
-
+
/**
* This is called from {@link org.apache.joshua.decoder.chart_parser.Cell}
* when making the final transition to the goal state.
@@ -159,13 +166,13 @@ public class ComputeNodeResult {
}
return cost;
}
-
+
public static FeatureVector computeTransitionFeatures(List<FeatureFunction> featureFunctions,
HyperEdge edge, int i, int j, Sentence sentence) {
// Initialize the set of features with those that were present with the rule in the grammar.
FeatureVector featureDelta = new FeatureVector();
-
+
// === compute feature logPs
for (FeatureFunction ff : featureFunctions) {
// A null rule signifies the final transition.
@@ -175,7 +182,7 @@ public class ComputeNodeResult {
featureDelta.add(ff.computeFeatures(edge.getRule(), edge.getTailNodes(), i, j, edge.getSourcePath(), sentence));
}
}
-
+
return featureDelta;
}
@@ -190,7 +197,7 @@ public class ComputeNodeResult {
public float getViterbiCost() {
return this.viterbiCost;
}
-
+
public float getBaseCost() {
return getViterbiCost() - getTransitionCost();
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 22fc160..96c428f 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
@@ -536,7 +536,7 @@ public class Tree implements Serializable {
* recursively visit the derivation state objects, following the route through the hypergraph
* defined by them.
*
- * This function is like {@link org.apache.joshua.decoder.ff.fragmentlm.Tree#buildTree(DerivationState, int)},
+ * This function is like Tree#buildTree(DerivationState, int),
* but that one simply follows the best incoming hyperedge for each node.
*
* @param rule for which corresponding internal fragment can be used to initialize the tree
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 2864e00..dd21de0 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
@@ -90,6 +90,7 @@ public class KenLM implements NGramLanguageModel, Comparable<KenLM> {
/**
* Constructor if order is not known.
* Order will be inferred from the model.
+ * @param file_name string path to an input file
*/
public KenLM(String file_name) {
pointer = construct(file_name);
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 ad05a37..5cb45ac 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
@@ -91,7 +91,7 @@ public class LanguageModelFF extends StatefulFF {
/* Whether this is a class-based LM */
private boolean isClassLM;
private ClassMap classMap;
-
+
protected class ClassMap {
private final int OOV_id = Vocabulary.getUnknownId();
@@ -134,7 +134,7 @@ public class LanguageModelFF extends StatefulFF {
this.type = parsedArgs.get("lm_type");
this.ngramOrder = Integer.parseInt(parsedArgs.get("lm_order"));
this.path = parsedArgs.get("lm_file");
-
+
if (parsedArgs.containsKey("class_map"))
try {
this.isClassLM = true;
@@ -146,14 +146,14 @@ public class LanguageModelFF extends StatefulFF {
// The dense feature initialization hasn't happened yet, so we have to retrieve this as sparse
this.weight = weights.getSparse(name);
-
+
initializeLM();
}
-
+
@Override
public ArrayList<String> reportDenseFeatures(int index) {
denseFeatureIndex = index;
-
+
ArrayList<String> names = new ArrayList<String>();
names.add(name);
return names;
@@ -165,7 +165,7 @@ public class LanguageModelFF extends StatefulFF {
protected void initializeLM() {
if (type.equals("kenlm")) {
this.languageModel = new KenLM(ngramOrder, path);
-
+
} else if (type.equals("berkeleylm")) {
this.languageModel = new LMGrammarBerkeley(ngramOrder, path);
@@ -177,14 +177,14 @@ public class LanguageModelFF extends StatefulFF {
Vocabulary.registerLanguageModel(this.languageModel);
Vocabulary.id(config.default_non_terminal);
-
+
startSymbolId = Vocabulary.id(Vocabulary.START_SYM);
}
public NGramLanguageModel getLM() {
return this.languageModel;
}
-
+
public String logString() {
if (languageModel != null)
return String.format("%s, order %d (weight %.3f)", name, languageModel.getOrder(), weight);
@@ -217,9 +217,9 @@ public class LanguageModelFF extends StatefulFF {
newState = computeTransition(rule.getEnglish(), tailNodes, acc);
}
}
-
+
}
-
+
return newState;
}
@@ -227,15 +227,19 @@ public class LanguageModelFF extends StatefulFF {
* Input sentences can be tagged with information specific to the language model. This looks for
* such annotations by following a word's alignments back to the source words, checking for
* annotations, and replacing the surface word if such annotations are found.
- *
+ * @param rule the {@link org.apache.joshua.decoder.ff.tm.Rule} to use
+ * @param begin todo
+ * @param end todo
+ * @param sentence {@link org.apache.joshua.lattice.Lattice} input
+ * @return todo
*/
protected int[] getTags(Rule rule, int begin, int end, Sentence sentence) {
/* Very important to make a copy here, so the original rule is not modified */
int[] tokens = Arrays.copyOf(rule.getEnglish(), rule.getEnglish().length);
byte[] alignments = rule.getAlignment();
-// System.err.println(String.format("getTags() %s", rule.getRuleString()));
-
+ // System.err.println(String.format("getTags() %s", rule.getRuleString()));
+
/* For each target-side token, project it to each of its source-language alignments. If any of those
* are annotated, take the first annotation and quit.
*/
@@ -246,8 +250,8 @@ public class LanguageModelFF extends StatefulFF {
if (alignments[j] == i) {
String annotation = sentence.getAnnotation((int)alignments[i] + begin, "class");
if (annotation != null) {
-// System.err.println(String.format(" word %d source %d abs %d annotation %d/%s",
-// i, alignments[i], alignments[i] + begin, annotation, Vocabulary.word(annotation)));
+ // System.err.println(String.format(" word %d source %d abs %d annotation %d/%s",
+ // i, alignments[i], alignments[i] + begin, annotation, Vocabulary.word(annotation)));
tokens[i] = Vocabulary.id(annotation);
break;
}
@@ -256,22 +260,23 @@ public class LanguageModelFF extends StatefulFF {
}
}
}
-
+
return tokens;
}
-
+
/**
* Sets the class map if this is a class LM
- * @param fileName
- * @throws IOException
+ * @param fileName a string path to a file
+ * @throws IOException if there is an error reading the input file
*/
public void setClassMap(String fileName) throws IOException {
this.classMap = new ClassMap(fileName);
}
-
-
+
/**
* Replace each word in a rule with the target side classes.
+ * @param rule {@link org.apache.joshua.decoder.ff.tm.Rule} to use when obtaining tokens
+ * @return int[] of tokens
*/
protected int[] getClasses(Rule rule) {
if (this.classMap == null) {
@@ -369,7 +374,7 @@ public class LanguageModelFF extends StatefulFF {
int ccount = 0;
float transitionLogP = 0.0f;
int[] left_context = null;
-
+
for (int c = 0; c < enWords.length; c++) {
int curID = enWords[c];
@@ -390,7 +395,7 @@ public class LanguageModelFF extends StatefulFF {
if (ccount == this.ngramOrder) {
// Compute the current word probability, and remove it.
float prob = this.languageModel.ngramLogProbability(current, this.ngramOrder);
-// System.err.println(String.format("-> prob(%s) = %f", Vocabulary.getWords(current), prob));
+ // System.err.println(String.format("-> prob(%s) = %f", Vocabulary.getWords(current), prob));
transitionLogP += prob;
System.arraycopy(current, 1, shadow, 0, this.ngramOrder - 1);
int[] tmp = current;
@@ -409,7 +414,7 @@ public class LanguageModelFF extends StatefulFF {
if (ccount == this.ngramOrder) {
// Compute the current word probability, and remove it.s
float prob = this.languageModel.ngramLogProbability(current, this.ngramOrder);
-// System.err.println(String.format("-> prob(%s) = %f", Vocabulary.getWords(current), prob));
+ // System.err.println(String.format("-> prob(%s) = %f", Vocabulary.getWords(current), prob));
transitionLogP += prob;
System.arraycopy(current, 1, shadow, 0, this.ngramOrder - 1);
int[] tmp = current;
@@ -419,7 +424,7 @@ public class LanguageModelFF extends StatefulFF {
}
}
}
-// acc.add(name, transitionLogP);
+ // acc.add(name, transitionLogP);
acc.add(denseFeatureIndex, transitionLogP);
if (left_context != null) {
@@ -441,8 +446,8 @@ public class LanguageModelFF extends StatefulFF {
*/
private NgramDPState computeFinalTransition(NgramDPState state, Accumulator acc) {
-// System.err.println(String.format("LanguageModel::computeFinalTransition()"));
-
+ // System.err.println(String.format("LanguageModel::computeFinalTransition()"));
+
float res = 0.0f;
LinkedList<Integer> currentNgram = new LinkedList<Integer>();
int[] leftContext = state.getLeftLMStateWords();
@@ -462,14 +467,14 @@ public class LanguageModelFF extends StatefulFF {
}
// Tell the accumulator
-// acc.add(name, res);
+ // acc.add(name, res);
acc.add(denseFeatureIndex, res);
// State is the same
return new NgramDPState(leftContext, rightContext);
}
-
+
/**
* Compatibility method for {@link #scoreChunkLogP(int[], boolean, boolean)}
*/
@@ -477,7 +482,7 @@ public class LanguageModelFF extends StatefulFF {
boolean skipStart) {
return scoreChunkLogP(Ints.toArray(words), considerIncompleteNgrams, skipStart);
}
-
+
/**
* This function is basically a wrapper for NGramLanguageModel::sentenceLogProbability(). It
* computes the probability of a phrase ("chunk"), using lower-order n-grams for the first n-1
@@ -506,7 +511,7 @@ public class LanguageModelFF extends StatefulFF {
return score;
}
-
+
/**
* Public method to set LM_INDEX back to 0.
* Required if multiple instances of the JoshuaDecoder live in the same JVM.
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 94c2bff..734e0aa 100644
--- a/src/main/java/org/apache/joshua/decoder/hypergraph/ViterbiExtractor.java
+++ b/src/main/java/org/apache/joshua/decoder/hypergraph/ViterbiExtractor.java
@@ -87,7 +87,7 @@ public class ViterbiExtractor {
* 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}
+ * @return a Viterbi {@link org.apache.joshua.decoder.ff.FeatureVector}
*/
public static FeatureVector getViterbiFeatures(
final HyperGraph hg,
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 be2b05a..cc6e839 100644
--- a/src/main/java/org/apache/joshua/decoder/io/DeNormalize.java
+++ b/src/main/java/org/apache/joshua/decoder/io/DeNormalize.java
@@ -51,8 +51,8 @@ public class DeNormalize {
/**
* Apply all the denormalization methods to the normalized input line.
*
- * @param normalized
- * @return
+ * @param normalized a normalized input line
+ * @return the denormalized String
*/
public static String processSingleLine(String normalized) {
// The order in which the methods are applied could matter in some situations. E.g., a token to
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 744f2e7..2c674fc 100644
--- a/src/main/java/org/apache/joshua/decoder/phrase/Coverage.java
+++ b/src/main/java/org/apache/joshua/decoder/phrase/Coverage.java
@@ -29,7 +29,7 @@ import org.apache.joshua.corpus.Span;
*/
public class Coverage {
-
+
// The index of the first uncovered word
private int firstZero;
@@ -45,12 +45,12 @@ public class Coverage {
firstZero = 0;
bits = new BitSet(INITIAL_LENGTH);
}
-
+
public Coverage(int firstZero) {
this.firstZero = firstZero;
bits = new BitSet(INITIAL_LENGTH);
}
-
+
/**
* Pretty-prints the coverage vector, making a guess about the length
*/
@@ -86,8 +86,8 @@ public class Coverage {
public void set(int begin, int end) {
assert compatible(begin, end);
-// StringBuffer sb = new StringBuffer();
-// sb.append(String.format("SET(%d,%d) %s", begin, end, this));
+ // StringBuffer sb = new StringBuffer();
+ // sb.append(String.format("SET(%d,%d) %s", begin, end, this));
if (begin == firstZero) {
// A concatenation.
@@ -105,13 +105,13 @@ public class Coverage {
bits.or(pattern(begin, end));
}
-// sb.append(String.format(" -> %s", this));
-// System.err.println(sb);
+ // sb.append(String.format(" -> %s", this));
+ // System.err.println(sb);
}
-
+
/**
* Convenience function.
- * @param todo
+ * @param span todo
*/
public final void set(Span span) {
set(span.start, span.end);
@@ -134,7 +134,7 @@ public class Coverage {
}
return false;
}
-
+
/**
* Returns the source sentence index of the first uncovered word.
*
@@ -181,7 +181,8 @@ public class Coverage {
*
* 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
+ * @param sentenceLength length of sentence
+ * @return todo
*/
public int rightOpening(int end, int sentenceLength) {
for (int i = end - firstZero; i < Math.min(64, sentenceLength - firstZero); i++) {
@@ -191,7 +192,7 @@ public class Coverage {
}
return sentenceLength;
}
-
+
/**
* Creates a bit vector with the same offset as the current coverage vector, flipping on
* bits begin..end.
@@ -201,7 +202,7 @@ public class Coverage {
* @return a bit vector (relative) with positions [begin..end) on
*/
public BitSet pattern(int begin, int end) {
-// System.err.println(String.format("pattern(%d,%d) %d %s %s", begin, end, firstZero, begin >= firstZero, toString()));
+ // System.err.println(String.format("pattern(%d,%d) %d %s %s", begin, end, firstZero, begin >= firstZero, toString()));
assert begin >= firstZero;
BitSet pattern = new BitSet(INITIAL_LENGTH);
pattern.set(begin - firstZero, end - firstZero);
@@ -211,12 +212,12 @@ public class Coverage {
/**
* Returns the underlying coverage bits.
*
- * @return
+ * @return {@link java.util.BitSet} vector of bits
*/
public BitSet getCoverage() {
return bits;
}
-
+
@Override
public boolean equals(Object obj) {
if (obj instanceof Coverage) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/src/main/java/org/apache/joshua/decoder/phrase/Future.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/phrase/Future.java b/src/main/java/org/apache/joshua/decoder/phrase/Future.java
index 352a23e..aa24390 100644
--- a/src/main/java/org/apache/joshua/decoder/phrase/Future.java
+++ b/src/main/java/org/apache/joshua/decoder/phrase/Future.java
@@ -22,18 +22,19 @@ import org.apache.joshua.decoder.Decoder;
import org.apache.joshua.util.ChartSpan;
public class Future {
-
+
// Square matrix with half the values ignored.
private ChartSpan<Float> entries;
private int sentlen;
-
+
/**
* Computes bottom-up the best way to cover all spans of the input sentence, using the phrases
- * that have been assembled in a {@link PhraseChart}. Requires that there be a translation at least
- * for every word (which can be accomplished with a pass-through grammar).
+ * that have been assembled in a {@link org.apache.joshua.decoder.phrase.PhraseChart}.
+ * Requires that there be a translation at least for every word (which can be
+ * accomplished with a pass-through grammar).
*
- * @param chart
+ * @param chart an input {@link org.apache.joshua.decoder.phrase.PhraseChart}
*/
public Future(PhraseChart chart) {
@@ -50,7 +51,7 @@ public class Future {
// Insert phrases
int max_end = Math.min(begin + chart.MaxSourcePhraseLength(), chart.SentenceLength());
for (int end = begin + 1; end <= max_end; end++) {
-
+
// Moses doesn't include the cost of applying </s>, so force it to zero
if (begin == sentlen - 1 && end == sentlen)
setEntry(begin, end, 0.0f);
@@ -61,7 +62,7 @@ public class Future {
}
}
}
-
+
// All the phrases are in, now do minimum dynamic programming. Lengths 0 and 1 were already handled above.
for (int length = 2; length <= chart.SentenceLength(); length++) {
for (int begin = 1; begin <= chart.SentenceLength() - length; begin++) {
@@ -70,40 +71,44 @@ public class Future {
}
}
}
-
+
if (Decoder.VERBOSE >= 3) {
for (int i = 1; i < chart.SentenceLength(); i++)
for (int j = i + 1; j < chart.SentenceLength(); j++)
System.err.println(String.format("future cost from %d to %d is %.3f", i-1, j-2, getEntry(i, j)));
}
}
-
+
public float Full() {
-// System.err.println("Future::Full(): " + Entry(1, sentlen));
+ // System.err.println("Future::Full(): " + Entry(1, sentlen));
return getEntry(1, sentlen);
}
/**
* Calculate change in rest cost when the given coverage is to be covered.
- */
+ * @param coverage input {@link org.apache.joshua.decoder.phrase.Coverage} vector
+ * @param begin word at which to begin within a sentence
+ * @param end word at which to end within a sentence
+ * @return a float value representing a {@link Future} entry
+ */
public float Change(Coverage coverage, int begin, int end) {
int left = coverage.leftOpening(begin);
int right = coverage.rightOpening(end, sentlen);
-// System.err.println(String.format("Future::Change(%s, %d, %d) left %d right %d %.3f %.3f %.3f", coverage, begin, end, left, right,
-// Entry(left, begin), Entry(end, right), Entry(left, right)));
+ // System.err.println(String.format("Future::Change(%s, %d, %d) left %d right %d %.3f %.3f %.3f", coverage, begin, end, left, right,
+ // Entry(left, begin), Entry(end, right), Entry(left, right)));
return getEntry(left, begin) + getEntry(end, right) - getEntry(left, right);
}
-
+
private float getEntry(int begin, int end) {
assert end >= begin;
assert end < this.sentlen;
return entries.get(begin, end);
}
-
+
private void setEntry(int begin, int end, float value) {
assert end >= begin;
assert end < this.sentlen;
-// System.err.println(String.format("future cost from %d to %d is %.5f", begin, end, value));
+ // System.err.println(String.format("future cost from %d to %d is %.5f", begin, end, value));
entries.set(begin, end, value);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 faee2ae..71d3df9 100644
--- a/src/main/java/org/apache/joshua/decoder/phrase/Hypothesis.java
+++ b/src/main/java/org/apache/joshua/decoder/phrase/Hypothesis.java
@@ -86,7 +86,7 @@ public class Hypothesis extends HGNode implements Comparable<Hypothesis> {
* HGNodes (designed for chart parsing) maintain a span (i,j). We overload j
* here to record the index of the last translated source word.
*
- * @return
+ * @return the int 'j' which is overloaded to denote the span of the phrase being applied
*/
public int LastSourceIndex() {
return j;
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/src/main/java/org/apache/joshua/decoder/phrase/PhraseChart.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/phrase/PhraseChart.java b/src/main/java/org/apache/joshua/decoder/phrase/PhraseChart.java
index 7e194a8..676a6a8 100644
--- a/src/main/java/org/apache/joshua/decoder/phrase/PhraseChart.java
+++ b/src/main/java/org/apache/joshua/decoder/phrase/PhraseChart.java
@@ -49,8 +49,10 @@ public class PhraseChart {
* applicable against the current input sentence. These phrases are extracted
* from all available grammars.
*
- * @param tables
- * @param source
+ * @param tables input array of {@link org.apache.joshua.decoder.phrase.PhraseTable}'s
+ * @param features {@link java.util.List} of {@link org.apache.joshua.decoder.ff.FeatureFunction}'s
+ * @param source input to {@link org.apache.joshua.lattice.Lattice}
+ * @param num_options number of translation options (typically set to 20)
*/
public PhraseChart(PhraseTable[] tables, List<FeatureFunction> features, Sentence source,
int num_options) {
@@ -123,8 +125,8 @@ public class PhraseChart {
/**
* Maps two-dimensional span into a one-dimensional array.
*
- * @param i
- * @param j
+ * @param i beginning of span
+ * @param j end of span
* @return offset into private list of TargetPhrases
*/
private int offset(int i, int j) {
@@ -134,9 +136,9 @@ public class PhraseChart {
/**
* Returns phrases from all grammars that match the span.
*
- * @param begin
- * @param end
- * @return
+ * @param begin beginning of span
+ * @param end end of span
+ * @return the {@link org.apache.joshua.decoder.phrase.TargetPhrases} at the specified position in this list.
*/
public TargetPhrases getRange(int begin, int end) {
int index = offset(begin, end);
@@ -156,9 +158,9 @@ public class PhraseChart {
/**
* Add a set of phrases from a grammar to the current span.
*
- * @param begin
- * @param end
- * @param to
+ * @param begin beginning of span
+ * @param end end of span
+ * @param to a {@link org.apache.joshua.decoder.ff.tm.RuleCollection} to be used in scoring and sorting.
*/
private void addToRange(int begin, int end, RuleCollection to) {
if (to != null) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/src/main/java/org/apache/joshua/decoder/phrase/PhraseTable.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/phrase/PhraseTable.java b/src/main/java/org/apache/joshua/decoder/phrase/PhraseTable.java
index db76924..d997ec1 100644
--- a/src/main/java/org/apache/joshua/decoder/phrase/PhraseTable.java
+++ b/src/main/java/org/apache/joshua/decoder/phrase/PhraseTable.java
@@ -47,12 +47,13 @@ public class PhraseTable implements Grammar {
* Chain to the super with a number of defaults. For example, we only use a single nonterminal,
* and there is no span limit.
*
- * @param grammarFile
- * @param owner
- * @param config
- * @throws IOException
+ * @param grammarFile file path parent directory
+ * @param owner used to set phrase owners
+ * @param type the grammar specification keyword (e.g., "thrax" or "moses")
+ * @param config a populated {@link org.apache.joshua.decoder.JoshuaConfiguration}
+ * @throws IOException if there is an error reading the grammar file
*/
- public PhraseTable(String grammarFile, String owner, String type, JoshuaConfiguration config, int maxSource)
+ public PhraseTable(String grammarFile, String owner, String type, JoshuaConfiguration config)
throws IOException {
this.config = config;
int spanLimit = 0;
@@ -81,7 +82,7 @@ public class PhraseTable implements Grammar {
* since the grammar includes the nonterminal. For {@link PackedGrammar}s, the value was either
* in the packed config file (Joshua 6.0.2+) or was passed in via the TM config line.
*
- * @return
+ * @return the longest source phrase read.
*/
@Override
public int getMaxSourcePhraseLength() {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 653217b..3e9e011 100644
--- a/src/main/java/org/apache/joshua/decoder/phrase/Stack.java
+++ b/src/main/java/org/apache/joshua/decoder/phrase/Stack.java
@@ -58,9 +58,9 @@ public class Stack extends ArrayList<Hypothesis> {
/**
* Create a new stack. Stacks are organized one for each number of source words that are covered.
*
- * @param featureFunctions
- * @param sentence
- * @param config
+ * @param featureFunctions {@link java.util.List} of {@link org.apache.joshua.decoder.ff.FeatureFunction}'s
+ * @param sentence input for a {@link org.apache.joshua.lattice.Lattice}
+ * @param config populated {@link org.apache.joshua.decoder.JoshuaConfiguration}
*/
public Stack(List<FeatureFunction> featureFunctions, Sentence sentence, JoshuaConfiguration config) {
this.featureFunctions = featureFunctions;
@@ -76,6 +76,8 @@ public class Stack extends ArrayList<Hypothesis> {
/**
* A Stack is an ArrayList; here, we intercept the add so we can maintain a list of the items
* stored under each distinct coverage vector
+ * @param hyp a {@link org.apache.joshua.decoder.phrase.Hypothesis} to add to the {@link org.apache.joshua.decoder.phrase.Stack}
+ * @return true if the {@link org.apache.joshua.decoder.phrase.Hypothesis} is appended to the list
*/
@Override
public boolean add(Hypothesis hyp) {
@@ -106,6 +108,7 @@ public class Stack extends ArrayList<Hypothesis> {
/**
* Returns the set of coverages contained in this stack. This is used to iterate over them
* in the main decoding loop in Stacks.java.
+ * @return a {@link java.util.Set} of {@link org.apache.joshua.decoder.phrase.Coverage}'s
*/
public Set<Coverage> getCoverages() {
return coverages.keySet();
@@ -114,8 +117,8 @@ public class Stack extends ArrayList<Hypothesis> {
/**
* Get all items with the same coverage vector.
*
- * @param cov
- * @return
+ * @param cov the {@link org.apache.joshua.decoder.phrase.Coverage} vector to get
+ * @return an {@link java.util.ArrayList} of {@link org.apache.joshua.decoder.phrase.Hypothesis}'
*/
public ArrayList<Hypothesis> get(Coverage cov) {
ArrayList<Hypothesis> list = coverages.get(cov);
@@ -133,8 +136,7 @@ public class Stack extends ArrayList<Hypothesis> {
* adding a candidate, we ensure that the sequence of English words match the sentence. If not,
* the code extends the dot in the cube-pruning chart to the next phrase, since that one might
* be a match.
- *
- * @param cand
+ * @param cand a partially-initialized translation {@link org.apache.joshua.decoder.phrase.Candidate}
*/
public void addCandidate(Candidate cand) {
if (visitedStates.contains(cand))
@@ -194,6 +196,7 @@ public class Stack extends ArrayList<Hypothesis> {
/**
* Adds a popped candidate to the chart / main stack. This is a candidate we have decided to
* keep around.
+ * @param complete a completely-initialized translation {@link org.apache.joshua.decoder.phrase.Candidate}
*
*/
public void addHypothesis(Candidate complete) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/src/main/java/org/apache/joshua/decoder/phrase/Stacks.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/phrase/Stacks.java b/src/main/java/org/apache/joshua/decoder/phrase/Stacks.java
index 533d2fa..7d4b025 100644
--- a/src/main/java/org/apache/joshua/decoder/phrase/Stacks.java
+++ b/src/main/java/org/apache/joshua/decoder/phrase/Stacks.java
@@ -32,7 +32,7 @@ package org.apache.joshua.decoder.phrase;
* ensures that the coverage vector is consistent but the resulting hypergraph may not be projective,
* which is different from the CKY algorithm, which does produce projective derivations.
*
- * Lattice decoding is not yet supported (March 2015).
+ * TODO Lattice decoding is not yet supported (March 2015).
*/
import java.util.ArrayList;
@@ -71,10 +71,10 @@ public class Stacks {
* Entry point. Initialize everything. Create pass-through (OOV) phrase table and glue phrase
* table (with start-of-sentence and end-of-sentence rules).
*
- * @param sentence
- * @param featureFunctions
- * @param grammars
- * @param config
+ * @param sentence input to {@link org.apache.joshua.lattice.Lattice}
+ * @param featureFunctions {@link java.util.List} of {@link org.apache.joshua.decoder.ff.FeatureFunction}'s
+ * @param grammars an array of {@link org.apache.joshua.decoder.ff.tm.Grammar}'s
+ * @param config a populated {@link org.apache.joshua.decoder.JoshuaConfiguration}
*/
public Stacks(Sentence sentence, List<FeatureFunction> featureFunctions, Grammar[] grammars,
JoshuaConfiguration config) {
@@ -106,7 +106,7 @@ public class Stacks {
/**
* The main algorithm. Returns a hypergraph representing the search space.
*
- * @return
+ * @return a {@link org.apache.joshua.decoder.hypergraph.HyperGraph} representing the search space
*/
public HyperGraph search() {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/src/main/java/org/apache/joshua/decoder/phrase/TargetPhrases.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/phrase/TargetPhrases.java b/src/main/java/org/apache/joshua/decoder/phrase/TargetPhrases.java
index cf43dda..05a4b0a 100644
--- a/src/main/java/org/apache/joshua/decoder/phrase/TargetPhrases.java
+++ b/src/main/java/org/apache/joshua/decoder/phrase/TargetPhrases.java
@@ -45,7 +45,7 @@ public class TargetPhrases extends ArrayList<Rule> {
/**
* Initialize with a collection of rules.
*
- * @param list
+ * @param list a {@link java.util.List} of {@link org.apache.joshua.decoder.ff.tm.Rule}'s
*/
public TargetPhrases(List<Rule> list) {
super();
@@ -59,6 +59,9 @@ public class TargetPhrases extends ArrayList<Rule> {
* Score the rules and sort them. Scoring is necessary because rules are only scored if they
* are used, in an effort to make reading in rules more efficient. This is starting to create
* some trouble and should probably be reworked.
+ * @param features a {@link java.util.List} of {@link org.apache.joshua.decoder.ff.FeatureFunction}'s
+ * @param weights a populated {@link org.apache.joshua.decoder.ff.FeatureVector}
+ * @param num_options the number of options
*/
public void finish(List<FeatureFunction> features, FeatureVector weights, int num_options) {
for (Rule rule: this) {
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 7f8a765..5146e2c 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
@@ -58,7 +58,10 @@ public interface ConstraintRule {
RULE, LHS, RHS
};
- /** Return the type of this ConstraintRule. */
+ /**
+ * Return the type of this ConstraintRule.
+ * @return the {@link org.apache.joshua.decoder.segment_file.ConstraintRule.Type}
+ */
Type type();
@@ -66,6 +69,7 @@ public interface ConstraintRule {
* Return the left hand side of the constraint rule. If this is null, then this object is
* specifying a translation for the span, but that translation may be derived from any
* nonterminal. The nonterminal here must be one used by the regular grammar.
+ * @return the left hand side of the constraint rule
*/
String lhs();
@@ -73,6 +77,7 @@ public interface ConstraintRule {
/**
* Return the native right hand side of the constraint rule. If this is null, then the regular
* grammar will be used to fill in the derivation from the lhs.
+ * @return the native right hand side of the constraint rule
*/
String nativeRhs();
@@ -80,6 +85,7 @@ public interface ConstraintRule {
/**
* Return the foreign right hand side of the constraint rule. This must be consistent with the
* sentence for the associated span, and is provided as a convenience method.
+ * @return the foreign right hand side of the constraint rule
*/
String foreignRhs();
@@ -88,6 +94,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 org.apache.joshua.decoder.chart_parser.Chart} must throw an error if there is a mismatch.
+ * @return an array of floating feature values for the RULE
*/
float[] features();
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 7ae2ec3..9863fa6 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
@@ -49,18 +49,21 @@ public interface ConstraintSpan {
/**
* Return the starting index of the span covered by this constraint.
+ * @return the starting index of the span covered by this constraint
*/
int start();
/**
* Return the ending index of the span covered by this constraint. Clients may assume
* <code>this.end() >= 1 + this.start()</code>.
+ * @return the ending index of the span covered by this constraint
*/
int end();
/**
* Return whether this is a hard constraint which should override the grammar. This value only
* really matters for sets of <code>RULE</code> type constraints.
+ * @return true if a hard constraint exists which should override the grammar
*/
boolean isHard();
@@ -71,6 +74,7 @@ public interface ConstraintSpan {
* {@link java.util.Iterator} instead in order to reduce the coupling between this class and
* Chart. See the note above about the fact that this interface should not be used internally by
* the Chart class because it will not be performant.
+ * @return a {@link java.util.List} of {@link org.apache.joshua.decoder.segment_file.ConstraintRule}'s
*/
List<ConstraintRule> rules();
}
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 e094fec..ca95a48 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
@@ -78,8 +78,9 @@ public class Sentence {
* Constructor. Receives a string representing the input sentence. This string may be a
* string-encoded lattice or a plain text string for decoding.
*
- * @param inputString
- * @param id
+ * @param inputString representing the input sentence
+ * @param id ID to associate with the input string
+ * @param joshuaConfiguration a populated {@link org.apache.joshua.decoder.JoshuaConfiguration}
*/
public Sentence(String inputString, int id, JoshuaConfiguration joshuaConfiguration) {
@@ -262,7 +263,7 @@ public class Sentence {
* Note that this code assumes the underlying representation is a sentence, and not a lattice. Its
* behavior is undefined for lattices.
*
- * @param length
+ * @param length int representing the length to truncate the sentence to
*/
protected void adjustForLength(int length) {
int size = this.getLattice().size() - 2; // subtract off the start- and end-of-sentence tokens
@@ -293,6 +294,7 @@ public class Sentence {
/**
* Returns the raw source-side input string.
+ * @return the raw source-side input string
*/
public String rawSource() {
return source;
@@ -301,7 +303,7 @@ public class Sentence {
/**
* Returns the source-side string with annotations --- if any --- stripped off.
*
- * @return
+ * @return the source-side string with annotations --- if any --- stripped off
*/
public String source() {
StringBuilder str = new StringBuilder();
@@ -333,7 +335,7 @@ public class Sentence {
*
* If the parameter parse=true is set, parsing will be triggered, otherwise constrained decoding.
*
- * @return
+ * @return target side of sentence translation
*/
public String target() {
return target;
@@ -369,7 +371,7 @@ public class Sentence {
* Returns the sequence of tokens comprising the sentence. This assumes you've done the checking
* to makes sure the input string (the source side) isn't a PLF waiting to be parsed.
*
- * @return
+ * @return a {@link java.util.List} of {@link org.apache.joshua.decoder.segment_file.Token}'s comprising the sentence
*/
public List<Token> getTokens() {
assert isLinearChain();
@@ -383,6 +385,7 @@ public class Sentence {
/**
* Returns the sequence of word IDs comprising the input sentence. Assumes this is not a general
* lattice, but a linear chain.
+ * @return an int[] comprising all word ID's
*/
public int[] getWordIDs() {
List<Token> tokens = getTokens();
@@ -396,7 +399,7 @@ public class Sentence {
* Returns the sequence of word ids comprising the sentence. Assumes this is a sentence and
* not a lattice.
*
- * @return
+ * @return the sequence of word ids comprising the sentence
*/
public Lattice<String> stringLattice() {
assert isLinearChain();
http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/aead6209/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 a06568c..7ba13ed 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
@@ -59,7 +59,7 @@ public class Token {
* PRO -> PRO
* </pre>
*
- * <p>and the following for "voudrais":<p>
+ * <p>and the following for "voudrais":</p>
*
* <pre>
* FUT -> FUT
@@ -67,6 +67,7 @@ public class Token {
* </pre>
*
* @param rawWord A word with annotation information (possibly)
+ * @param config a populated {@link org.apache.joshua.decoder.JoshuaConfiguration}
*
*/
public Token(String rawWord, JoshuaConfiguration config) {
@@ -140,7 +141,8 @@ public class Token {
/**
* Returns the annotationID (vocab ID)
* associated with this token
- * @return int A type ID
+ * @param key A type ID
+ * @return the annotationID (vocab ID)
*/
public String getAnnotation(String key) {
if (annotations.containsKey(key)) {