You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@joshua.apache.org by mj...@apache.org on 2016/06/01 02:52:24 UTC

[89/94] [abbrv] incubator-joshua git commit: removed useless functions from FeatureFunction class

removed useless functions from FeatureFunction class

These were removed once a while ago, not sure how they crept back in


Project: http://git-wip-us.apache.org/repos/asf/incubator-joshua/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-joshua/commit/04428ffc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-joshua/tree/04428ffc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-joshua/diff/04428ffc

Branch: refs/heads/JOSHUA-252
Commit: 04428ffcea7e81c0a48e62b48b7c0071d023650a
Parents: e57320f
Author: Matt Post <po...@cs.jhu.edu>
Authored: Tue May 31 22:07:36 2016 -0400
Committer: Matt Post <po...@cs.jhu.edu>
Committed: Tue May 31 22:07:36 2016 -0400

----------------------------------------------------------------------
 .../joshua/decoder/ff/ArityPhrasePenalty.java   |  12 -
 .../joshua/decoder/ff/FeatureFunction.java      |  13 -
 .../joshua/decoder/ff/LabelCombinationFF.java   |  13 -
 .../joshua/decoder/ff/LabelSubstitutionFF.java  |  13 -
 .../joshua/decoder/ff/LexicalFeatures.java      |  21 +-
 .../apache/joshua/decoder/ff/OOVPenalty.java    |  12 -
 .../apache/joshua/decoder/ff/PhraseModel.java   |  12 -
 .../apache/joshua/decoder/ff/PhrasePenalty.java |  12 -
 .../apache/joshua/decoder/ff/RuleCountBin.java  |  12 -
 .../org/apache/joshua/decoder/ff/RuleFF.java    |  12 -
 .../org/apache/joshua/decoder/ff/RuleShape.java |  12 -
 .../apache/joshua/decoder/ff/SourcePathFF.java  |  12 -
 .../apache/joshua/decoder/ff/TargetBigram.java  |  12 -
 .../apache/joshua/decoder/ff/WordPenalty.java   |  12 -
 .../decoder/ff/fragmentlm/FragmentLMFF.java     |  13 -
 .../joshua/decoder/ff/lm/LanguageModelFF.java   |  12 -
 .../joshua/decoder/ff/phrase/Distortion.java    |  12 -
 .../ff/similarity/EdgePhraseSimilarityFF.java   |  13 -
 .../joshua/decoder/ff/tm/BilingualRule.java     | 167 ----------
 .../joshua/decoder/ff/tm/MonolingualRule.java   | 315 -------------------
 20 files changed, 11 insertions(+), 701 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/ArityPhrasePenalty.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/ArityPhrasePenalty.java b/src/main/java/org/apache/joshua/decoder/ff/ArityPhrasePenalty.java
index d4f9534..ae273b7 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/ArityPhrasePenalty.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/ArityPhrasePenalty.java
@@ -69,16 +69,4 @@ public class ArityPhrasePenalty extends StatelessFF {
     
     return null;
   }
-
-  @Override
-  public double estimateLogP(Rule rule, int sentID) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double getWeight() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/FeatureFunction.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/FeatureFunction.java b/src/main/java/org/apache/joshua/decoder/ff/FeatureFunction.java
index e5f0baa..6f231ae 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/FeatureFunction.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/FeatureFunction.java
@@ -308,19 +308,6 @@ public abstract class FeatureFunction {
   }
 
   /**
-   * It is used when initializing translation grammars (for 
-   * pruning purpose, and to get stateless logP for each rule). 
-   * This is also required to sort the rules (required by Cube-pruning).
-   * 
-   * @param rule {@link org.apache.joshua.decoder.ff.tm.Rule} to be utilized within computation
-   * @param sentID associated ID
-   * @return double value representing LogP
-   */ 
-  public abstract double estimateLogP(Rule rule, int sentID);
-  
-  public abstract double  getWeight(); 
-
-  /**
    * Accumulator objects allow us to generalize feature computation.
    * ScoreAccumulator takes (feature,value) pairs and simple stores the weighted
    * sum (for decoding). FeatureAccumulator records the named feature values

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/LabelCombinationFF.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/LabelCombinationFF.java b/src/main/java/org/apache/joshua/decoder/ff/LabelCombinationFF.java
index f80e0b7..bfebaa5 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/LabelCombinationFF.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/LabelCombinationFF.java
@@ -59,17 +59,4 @@ public class LabelCombinationFF extends StatelessFF {
 
     return null;
   }
-
-  @Override
-  public double estimateLogP(Rule rule, int sentID) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double getWeight() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/LabelSubstitutionFF.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/LabelSubstitutionFF.java b/src/main/java/org/apache/joshua/decoder/ff/LabelSubstitutionFF.java
index 2c247fe..8735be6 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/LabelSubstitutionFF.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/LabelSubstitutionFF.java
@@ -128,17 +128,4 @@ public class LabelSubstitutionFF extends StatelessFF {
     }
     return null;
   }
-
-  @Override
-  public double estimateLogP(Rule rule, int sentID) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double getWeight() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/LexicalFeatures.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/LexicalFeatures.java b/src/main/java/org/apache/joshua/decoder/ff/LexicalFeatures.java
index 128df87..31de48e 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/LexicalFeatures.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/LexicalFeatures.java
@@ -1,17 +1,18 @@
-package joshua.decoder.ff;
+package org.apache.joshua.decoder.ff;
 
 import static com.google.common.cache.CacheBuilder.newBuilder;
 
 import java.util.ArrayList;
 import java.util.List;
 
-import joshua.corpus.Vocabulary;
-import joshua.decoder.JoshuaConfiguration;
-import joshua.decoder.chart_parser.SourcePath;
-import joshua.decoder.ff.state_maintenance.DPState;
-import joshua.decoder.ff.tm.Rule;
-import joshua.decoder.hypergraph.HGNode;
-import joshua.decoder.segment_file.Sentence;
+import org.apache.joshua.corpus.Vocabulary;
+import org.apache.joshua.decoder.JoshuaConfiguration;
+import org.apache.joshua.decoder.chart_parser.SourcePath;
+import org.apache.joshua.decoder.ff.state_maintenance.DPState;
+import org.apache.joshua.decoder.ff.tm.Rule;
+import org.apache.joshua.decoder.hypergraph.HGNode;
+import org.apache.joshua.decoder.segment_file.Sentence;
+import org.apache.joshua.util.FormatUtils;
 
 import com.google.common.cache.Cache;
 
@@ -111,7 +112,7 @@ public class LexicalFeatures extends StatelessFF {
     // deletions: unaligned source words
     if (useDeletions) {
       for (int i = 0; i < sourceAligned.length; i++) {
-        if (!sourceAligned[i] && !Vocabulary.nt(sourceWords[i])) {
+        if (!sourceAligned[i] && ! FormatUtils.isNonterminal(sourceWords[i])) {
           result.add("D:" + Vocabulary.word(sourceWords[i]));
         }
       }
@@ -120,7 +121,7 @@ public class LexicalFeatures extends StatelessFF {
     // insertions: unaligned target words
     if (useInsertions) {
       for (int i = 0; i < targetAligned.length; i++) {
-        if (useInsertions && !targetAligned[i] && !Vocabulary.nt(targetWords[i])) {
+        if (useInsertions && !targetAligned[i] && ! FormatUtils.isNonterminal(targetWords[i])) {
           result.add("I:" + Vocabulary.word(targetWords[i]));
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/OOVPenalty.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/OOVPenalty.java b/src/main/java/org/apache/joshua/decoder/ff/OOVPenalty.java
index e53e19f..5278172 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/OOVPenalty.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/OOVPenalty.java
@@ -103,16 +103,4 @@ public class OOVPenalty extends StatelessFF {
   private float getValue(int lhs) {
     return oovWeights.containsKey(lhs) ? oovWeights.get(lhs) : defaultValue;
   }
-
-  @Override
-  public double estimateLogP(Rule rule, int sentID) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double getWeight() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/PhraseModel.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/PhraseModel.java b/src/main/java/org/apache/joshua/decoder/ff/PhraseModel.java
index 3eb0c2e..2324292 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/PhraseModel.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/PhraseModel.java
@@ -132,16 +132,4 @@ public class PhraseModel extends StatelessFF {
   public String toString() {
     return name + " " + Vocabulary.word(ownerID);
   }
-
-  @Override
-  public double estimateLogP(Rule rule, int sentID) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double getWeight() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/PhrasePenalty.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/PhrasePenalty.java b/src/main/java/org/apache/joshua/decoder/ff/PhrasePenalty.java
index a185286..3c38e60 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/PhrasePenalty.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/PhrasePenalty.java
@@ -83,16 +83,4 @@ public class PhrasePenalty extends StatelessFF {
       return weights.getDense(denseFeatureIndex) * value;
     return 0.0f;
   }
-
-  @Override
-  public double estimateLogP(Rule rule, int sentID) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double getWeight() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/RuleCountBin.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/RuleCountBin.java b/src/main/java/org/apache/joshua/decoder/ff/RuleCountBin.java
index 55abd51..5ba0c66 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/RuleCountBin.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/RuleCountBin.java
@@ -71,16 +71,4 @@ public class RuleCountBin extends StatelessFF {
 
     return null;
   }
-
-  @Override
-  public double estimateLogP(Rule rule, int sentID) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double getWeight() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/RuleFF.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/RuleFF.java b/src/main/java/org/apache/joshua/decoder/ff/RuleFF.java
index 20f91ee..909e481 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/RuleFF.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/RuleFF.java
@@ -120,16 +120,4 @@ public class RuleFF extends StatelessFF {
     }
     return sb.toString();
   }
-
-  @Override
-  public double estimateLogP(Rule rule, int sentID) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double getWeight() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/RuleShape.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/RuleShape.java b/src/main/java/org/apache/joshua/decoder/ff/RuleShape.java
index 6333701..89fa2f4 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/RuleShape.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/RuleShape.java
@@ -97,16 +97,4 @@ public class RuleShape extends StatelessFF {
     acc.add(name + "_sourceTarget_" + sourceShape + "_" + targetShape, 1);
     return null;
   }
-
-  @Override
-  public double estimateLogP(Rule rule, int sentID) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double getWeight() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/SourcePathFF.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/SourcePathFF.java b/src/main/java/org/apache/joshua/decoder/ff/SourcePathFF.java
index d529559..b138426 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/SourcePathFF.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/SourcePathFF.java
@@ -60,16 +60,4 @@ public final class SourcePathFF extends StatelessFF {
     acc.add(denseFeatureIndex,  sourcePath.getPathCost());
     return null;
   }
-
-  @Override
-  public double estimateLogP(Rule rule, int sentID) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double getWeight() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/TargetBigram.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/TargetBigram.java b/src/main/java/org/apache/joshua/decoder/ff/TargetBigram.java
index a8cd161..e7de1f8 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/TargetBigram.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/TargetBigram.java
@@ -213,16 +213,4 @@ public class TargetBigram extends StatefulFF {
 
     return sb.substring(0, sb.length() - 1);
   }
-
-  @Override
-  public double estimateLogP(Rule rule, int sentID) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double getWeight() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/WordPenalty.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/WordPenalty.java b/src/main/java/org/apache/joshua/decoder/ff/WordPenalty.java
index e1f74c2..da315ec 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/WordPenalty.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/WordPenalty.java
@@ -77,16 +77,4 @@ public final class WordPenalty extends StatelessFF {
       return weights.getDense(denseFeatureIndex) * OMEGA * (rule.getEnglish().length - rule.getArity());
     return 0.0f;
   }
-
-  @Override
-  public double estimateLogP(Rule rule, int sentID) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double getWeight() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/FragmentLMFF.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/FragmentLMFF.java b/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/FragmentLMFF.java
index b191c2f..fa4c4af 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/FragmentLMFF.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/fragmentlm/FragmentLMFF.java
@@ -362,17 +362,4 @@ public class FragmentLMFF extends StatefulFF {
       return String.format("[FragmentState %s]", tree);
     }
   }
-
-  @Override
-  public double estimateLogP(Rule rule, int sentID) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double getWeight() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/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 3d636d9..3fea410 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
@@ -524,16 +524,4 @@ public class LanguageModelFF extends StatefulFF {
   public static void resetLmIndex() {
     LM_INDEX = 0;
   }
-
-  @Override
-  public double estimateLogP(Rule rule, int sentID) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double getWeight() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/phrase/Distortion.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/phrase/Distortion.java b/src/main/java/org/apache/joshua/decoder/ff/phrase/Distortion.java
index abe115c..f9e6a29 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/phrase/Distortion.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/phrase/Distortion.java
@@ -68,16 +68,4 @@ public class Distortion extends StatelessFF {
 
     return null;
   }
-
-  @Override
-  public double estimateLogP(Rule rule, int sentID) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double getWeight() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/similarity/EdgePhraseSimilarityFF.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/similarity/EdgePhraseSimilarityFF.java b/src/main/java/org/apache/joshua/decoder/ff/similarity/EdgePhraseSimilarityFF.java
index 476ecac..91af58b 100644
--- a/src/main/java/org/apache/joshua/decoder/ff/similarity/EdgePhraseSimilarityFF.java
+++ b/src/main/java/org/apache/joshua/decoder/ff/similarity/EdgePhraseSimilarityFF.java
@@ -276,17 +276,4 @@ public class EdgePhraseSimilarityFF extends StatefulFF implements SourceDependen
     }
     return (count == 0 ? 0 : similarity / count);
   }
-
-  @Override
-  public double estimateLogP(Rule rule, int sentID) {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
-  @Override
-  public double getWeight() {
-    // TODO Auto-generated method stub
-    return 0;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/tm/BilingualRule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/BilingualRule.java b/src/main/java/org/apache/joshua/decoder/ff/tm/BilingualRule.java
deleted file mode 100644
index b2299ba..0000000
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/BilingualRule.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.joshua.decoder.ff.tm; 
-
-import java.util.Arrays; 
-import java.util.Map; 
-
-import org.apache.joshua.corpus.SymbolTable; 
-
-
-/**
- * Normally, the feature score in the rule should be *cost* (i.e., 
- * -LogP), so that the feature weight should be positive 
- * 
- * @author Zhifei Li, zhifei.work@gmail.com
- * @version $LastChangedDate: 2010-01-20 19:46:54 -0600 (Wed, 20 Jan 2010) $ 
- */ 
-public class BilingualRule extends MonolingualRule { 
-
-  private int[] english; 
-
-  //=============================================================== 
-  // Constructors 
-  //=============================================================== 
-
-  /**
-   * Constructs a new rule using the provided parameters. The 
-   * owner and rule id for this rule are undefined. 
-   *  
-   * @param lhs Left-hand side of the rule. 
-   * @param sourceRhs Source language right-hand side of the rule. 
-   * @param targetRhs Target language right-hand side of the rule. 
-   * @param featureScores Feature value scores for the rule. 
-   * @param arity Number of nonterminals in the source language 
-   *              right-hand side. 
-   * @param owner todo
-   * @param latticeCost todo
-   * @param ruleID todo
-   */ 
-  public BilingualRule(int lhs, int[] sourceRhs, int[] targetRhs, float[] featureScores, int arity, int owner, float latticeCost, int ruleID) { 
-    super(lhs, sourceRhs, featureScores, arity, owner, latticeCost, ruleID); 
-    this.english = targetRhs;   
-  } 
-
-  //called by class who does not care about lattice_cost, rule_id, and owner 
-  public BilingualRule(int lhs, int[] sourceRhs, int[] targetRhs, float[] featureScores, int arity) { 
-    super(lhs, sourceRhs, featureScores, arity); 
-    this.english = targetRhs; 
-  } 
-
-
-  //=============================================================== 
-  // Attributes 
-  //=============================================================== 
-
-  public final void setEnglish(int[] eng) { 
-    this.english = eng; 
-  } 
-
-  public final int[] getEnglish() { 
-    return this.english; 
-  } 
-
-
-  //=============================================================== 
-  // Serialization Methods 
-  //=============================================================== 
-  // TODO: remove these methods 
-
-  // Caching this method significantly improves performance 
-  // We mark it transient because it is, though cf java.io.Serializable 
-  private transient String cachedToString = null; 
-
-  public String toString(Map<Integer,String> ntVocab, SymbolTable sourceVocab, SymbolTable targetVocab) { 
-    if (null == this.cachedToString) { 
-      StringBuffer sb = new StringBuffer("["); 
-      sb.append(ntVocab.get(this.getLHS())); 
-      sb.append("] ||| "); 
-      sb.append(sourceVocab.getWords(this.getFrench(),true)); 
-      sb.append(" ||| "); 
-      sb.append(targetVocab.getWords(this.english,false)); 
-      //sb.append(java.util.Arrays.toString(this.english)); 
-      sb.append(" |||"); 
-      for (int i = 0; i < this.getFeatureScores().length; i++) { 
-        //    sb.append(String.format(" %.12f", this.getFeatureScores()[i])); 
-        sb.append(' '); 
-        sb.append(Float.toString(this.getFeatureScores()[i])); 
-      } 
-      this.cachedToString = sb.toString(); 
-    } 
-    return this.cachedToString; 
-  } 
-
-
-  //print the rule in terms of Integers 
-  public String toString() { 
-    if (null == this.cachedToString) { 
-      StringBuffer sb = new StringBuffer(); 
-      sb.append(this.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(this))); 
-      sb.append("~~~"); 
-      sb.append(this.getLHS()); 
-      sb.append(" ||| "); 
-      sb.append(Arrays.toString(this.getFrench())); 
-      sb.append(" ||| "); 
-      sb.append(Arrays.toString(this.english)); 
-      sb.append(" |||"); 
-      for (int i = 0; i < this.getFeatureScores().length; i++) { 
-        sb.append(String.format(" %.4f", this.getFeatureScores()[i])); 
-      } 
-      this.cachedToString = sb.toString(); 
-    } 
-    return this.cachedToString; 
-  } 
-
-
-  public String toString(SymbolTable symbolTable) { 
-    if (null == this.cachedToString) { 
-      StringBuffer sb = new StringBuffer(); 
-      sb.append(symbolTable.getWord(this.getLHS())); 
-      sb.append(" ||| "); 
-      sb.append(symbolTable.getWords(this.getFrench())); 
-      sb.append(" ||| "); 
-      sb.append(symbolTable.getWords(this.english)); 
-      sb.append(" |||"); 
-      for (int i = 0; i < this.getFeatureScores().length; i++) { 
-        sb.append(String.format(" %.4f", this.getFeatureScores()[i])); 
-      } 
-      this.cachedToString = sb.toString(); 
-    } 
-    return this.cachedToString; 
-  } 
-
-  public String toStringWithoutFeatScores(SymbolTable symbolTable) { 
-    StringBuffer sb = new StringBuffer(); 
-    if(symbolTable==null) 
-      sb.append(this.getLHS()); 
-    else 
-      sb.append(symbolTable.getWord(this.getLHS())); 
-
-    return sb.append(" ||| ") 
-        .append(convertToString(this.getFrench(), symbolTable)) 
-        .append(" ||| ") 
-        .append(convertToString(this.getEnglish(), symbolTable)) 
-        .toString(); 
-  } 
-
-
-
-
-
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-joshua/blob/04428ffc/src/main/java/org/apache/joshua/decoder/ff/tm/MonolingualRule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/joshua/decoder/ff/tm/MonolingualRule.java b/src/main/java/org/apache/joshua/decoder/ff/tm/MonolingualRule.java
deleted file mode 100644
index 26cd50c..0000000
--- a/src/main/java/org/apache/joshua/decoder/ff/tm/MonolingualRule.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.joshua.decoder.ff.tm; 
-
-import java.util.Arrays; 
-import java.util.List; 
-import java.util.Map; 
-
-import org.apache.joshua.corpus.SymbolTable; 
-import org.apache.joshua.decoder.ff.FeatureFunction;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * this class implements MonolingualRule 
- * 
- * @author Zhifei Li, zhifei.work@gmail.com
- * @version $LastChangedDate: 2010-02-10 09:59:38 -0600 (Wed, 10 Feb 2010) $ 
- */ 
-public class MonolingualRule extends Rule { 
-
-  private static final Logger LOG = LoggerFactory.getLogger(MonolingualRule.class);
-
-  //=============================================================== 
-  // Instance Fields 
-  //=============================================================== 
-
-  /* The string format of Rule is:
-   * [Phrase] ||| french ||| english ||| feature scores 
-   */ 
-  private int ruleID; 
-  private int lhs; // tag of this rule 
-  private int[] pFrench; //pointer to the RuleCollection, as all the rules under it share the same Source side 
-  private int arity; 
-  private float[] featScores; // the feature scores for this rule 
-
-  /* a feature function will be fired for this rule
-   * only if the owner of the rule matches the owner of the feature function 
-   */ 
-  private int owner; 
-
-  // TODO: consider remove this from the general class, and 
-  // create a new specific Rule class 
-  private float latticeCost;  
-
-  /**
-   * estimate_cost depends on rule itself: statelesscost + 
-   * transition_cost(non-stateless/non-contexual* models), 
-   * we need this variable in order to provide sorting for 
-   * cube-pruning 
-   */ 
-  private float est_cost = 0; 
-
-  //=============================================================== 
-  // Static Fields 
-  //=============================================================== 
-
-  // TODO: Ideally, we shouldn't have to have dummy rule IDs 
-  // and dummy owners. How can this need be eliminated? 
-  public static final int DUMMY_RULE_ID = 1; 
-  public static final int DUMMY_OWNER = 1; 
-
-
-  //=============================================================== 
-  // Constructors 
-  //=============================================================== 
-
-  /**
-   * Constructs a new rule using the provided parameters. The 
-   * owner and rule id for this rule are undefined. 
-   *  
-   * @param lhs Left-hand side of the rule. 
-   * @param sourceRhs Source language right-hand side of the rule. 
-   * @param featureScores Feature value scores for the rule. 
-   * @param arity Number of nonterminals in the source language 
-   *              right-hand side. 
-   * @param owner todo
-   * @param latticeCost todo
-   * @param ruleID todo
-   */ 
-  public MonolingualRule(int lhs, int[] sourceRhs, float[] featureScores, int arity, int owner, float latticeCost, int ruleID) { 
-    this.lhs          = lhs; 
-    this.pFrench     = sourceRhs; 
-    this.featScores  = featureScores; 
-    this.arity        = arity; 
-    this.latticeCost = latticeCost; 
-    this.ruleID      = ruleID; 
-    this.owner        = owner; 
-  } 
-
-
-  // called by class who does not care about lattice_cost, 
-  // rule_id, and owner 
-  public MonolingualRule(int lhs_, int[] source_rhs, float[] feature_scores, int arity_) { 
-    this.lhs         = lhs_; 
-    this.pFrench    = source_rhs; 
-    this.featScores = feature_scores; 
-    this.arity       = arity_; 
-
-    //==== dummy values 
-    this.latticeCost = 0; 
-    this.ruleID      = DUMMY_RULE_ID; 
-    this.owner        = DUMMY_OWNER; 
-  } 
-
-
-  //=============================================================== 
-  // Attributes 
-  //=============================================================== 
-
-  public final void setRuleID(int id) { this.ruleID = id; } 
-
-  public final int getRuleID() { return this.ruleID; } 
-
-
-  public final void setArity(int arity) { this.arity = arity; } 
-
-  public final int getArity() { return this.arity; } 
-
-
-  public final void setOwner(int owner) { this.owner = owner; } 
-
-  public final int getOwner() { return this.owner; } 
-
-
-  public final void setLHS(int lhs) { this.lhs = lhs; } 
-
-  public final int getLHS() { return this.lhs; } 
-
-
-  public void setEnglish(int[] eng) { 
-    //TODO: do nothing 
-  } 
-
-  public int[] getEnglish() { 
-    //TODO 
-    return null; 
-  } 
-
-
-  public final void setFrench(int[] french) { this.pFrench = french; } 
-
-  public final int[] getFrench() { return this.pFrench; } 
-
-
-  public final void setFeatureScores(float[] scores) { 
-    this.featScores = scores; 
-  } 
-
-  public final float[] getFeatureScores() { 
-    return this.featScores; 
-  } 
-
-
-  public final void setLatticeCost(float cost) { this.latticeCost = cost; } 
-
-  public final float getLatticeCost() { return this.latticeCost; } 
-
-
-  public final float getEstCost() { 
-    if (est_cost <= Double.NEGATIVE_INFINITY) { 
-      LOG.warn("The est cost is neg infinity; must be bad rule; rule is:\n {}", this);
-    } 
-    return est_cost; 
-  } 
-
-
-  /** 
-   * Set a lower-bound estimate inside the rule returns full 
-   * estimate. 
-   */ 
-  public final float estimateRuleCost(List<FeatureFunction> featureFunctions) { 
-    if (null == featureFunctions) { 
-      return 0; 
-    } else { 
-      float estcost = 0.0f; 
-      for (FeatureFunction ff : featureFunctions) { 
-        double mdcost = - ff.estimateLogP(this, -1) * ff.getWeight(); 
-        estcost += mdcost; 
-      } 
-
-      this.est_cost = estcost; 
-      return estcost; 
-    } 
-  } 
-
-  //=============================================================== 
-  // Methods 
-  //=============================================================== 
-
-  public float incrementFeatureScore(int column, double score) { 
-    synchronized(this) { 
-      featScores[column] += score; 
-      return featScores[column]; 
-    } 
-  } 
-
-
-  public void setFeatureCost(int column, float score) { 
-    synchronized(this) { 
-      featScores[column] = score; 
-    } 
-  } 
-
-
-  public float getFeatureCost(int column) { 
-    synchronized(this) { 
-      return featScores[column]; 
-    } 
-  } 
-
-  //=============================================================== 
-  // Serialization Methods 
-  //=============================================================== 
-  // BUG: These are all far too redundant. Should be refactored to share. 
-
-  // Caching this method significantly improves performance 
-  // We mark it transient because it is, though cf 
-  // java.io.Serializable 
-  private transient String cachedToString = null; 
-
-  @Deprecated 
-  public String toString(Map<Integer,String> ntVocab, SymbolTable sourceVocab, SymbolTable targetVocab) { 
-    if (null == this.cachedToString) { 
-      StringBuffer sb = new StringBuffer(); 
-      sb.append(ntVocab.get(this.lhs)); 
-      sb.append(" ||| "); 
-      sb.append(sourceVocab.getWords(this.pFrench,true)); 
-      sb.append(" |||"); 
-      for (int i = 0; i < this.featScores.length; i++) { 
-        //sb.append(String.format(" %.4f", this.feat_scores[i])); 
-        sb.append(' ').append(Float.toString(this.featScores[i])); 
-      } 
-      this.cachedToString = sb.toString(); 
-    } 
-    return this.cachedToString; 
-  } 
-
-
-  //print the rule in terms of Ingeters 
-  @Deprecated 
-  public String toString() { 
-    if (null == this.cachedToString) { 
-      StringBuffer sb = new StringBuffer(); 
-      sb.append(this.lhs); 
-      sb.append(" ||| "); 
-      sb.append(Arrays.toString(this.pFrench)); 
-      sb.append(" |||"); 
-      for (int i = 0; i < this.featScores.length; i++) { 
-        sb.append(String.format(" %.4f", this.featScores[i])); 
-      } 
-      this.cachedToString = sb.toString(); 
-    } 
-    return this.cachedToString; 
-  } 
-
-
-  //do not use cachedToString 
-  @Deprecated 
-  public String toString(SymbolTable symbolTable) { 
-    StringBuffer sb = new StringBuffer(); 
-    sb.append(symbolTable.getWord(this.lhs)); 
-    sb.append(" ||| "); 
-    sb.append(symbolTable.getWords(this.pFrench)); 
-    sb.append(" |||"); 
-    for (int i = 0; i < this.featScores.length; i++) { 
-      sb.append(String.format(" %.4f", this.featScores[i])); 
-    } 
-    return sb.toString(); 
-  } 
-
-
-  @Deprecated 
-  public String toStringWithoutFeatScores(SymbolTable symbolTable) { 
-    StringBuffer sb = new StringBuffer(); 
-    if(symbolTable==null) 
-      sb.append(this.getLHS()); 
-    else 
-      sb.append(symbolTable.getWord(this.getLHS())); 
-
-    return sb.append(" ||| ") 
-        .append(convertToString(this.getFrench(), symbolTable)) 
-        .toString(); 
-  } 
-
-  public String convertToString(int[] words, SymbolTable symbolTable){   
-    StringBuffer sb = new StringBuffer(); 
-    for (int i = 0; i < words.length; i++) { 
-      if(symbolTable!=null) 
-        sb.append( symbolTable.getWord(words[i]) ); 
-      else 
-        sb.append(words[i]); 
-
-      if(i<words.length-1) 
-        sb.append(" "); 
-    } 
-    return sb.toString(); 
-  } 
-}
\ No newline at end of file