Package joshua.decoder.ff.tm

Examples of joshua.decoder.ff.tm.Rule


  }

  //O(n^2) comparisons
  protected void getConfusionFromRules(List<Rule> rules){
    for(int i=0; i<rules.size(); i++){
      Rule rule1= rules.get(i);
      for(int j=0; j<rules.size(); j++){
        Rule rule2= rules.get(j);         
        processRulePair(rule1, rule2, 1.0);//TODO
      }
    }
  }
View Full Code Here


 
 
//   return true if the hyperedge should be filtered out
  // non-recursive
  private boolean filter_deduction_helper(HyperEdge dt){
    Rule rl = dt.getRule();
    if(rl!=null){//not hyperedges under goal item
      int[] en_words = dt.getRule().getEnglish();
      ArrayList<Integer> words= new ArrayList<Integer>();//a continous sequence of words due to combination; the sequence stops whenever the right-lm-state jumps in (i.e., having eclipsed words)       
      for(int c=0; c<en_words.length; c++){
          int c_id = en_words[c];
View Full Code Here

  /**assuming all the ant nodes are on,
   * now we see if the application of the rule matches a larger span
   * */
  private boolean matchTargetString(HyperEdge dt){
   
    Rule rl = dt.getRule();
    if(rl!=null){
     
      return false;
    }
   
View Full Code Here

//  get one-best string under item
  public static String extractViterbiString(SymbolTable symbolTable, HGNode node) {
    StringBuffer res = new StringBuffer();
   
    HyperEdge edge = node.bestHyperedge;
    Rule rl = edge.getRule();
   
    if (null == rl) { // deductions under "goal item" does not have rule
      if (edge.getAntNodes().size() != 1) {
        throw new RuntimeException("deduction under goal item have not equal one item");
      }
      return extractViterbiString(symbolTable, edge.getAntNodes().get(0));
    }
    int[] english = rl.getEnglish();
    for (int c = 0; c < english.length; c++) {
      if (symbolTable.isNonterminal(english[c])) {
        int id = symbolTable.getTargetNonterminalIndex(english[c]);
        HGNode child = (HGNode)edge.getAntNodes().get(id);
        res.append(extractViterbiString(symbolTable, child));
View Full Code Here

        else if (v instanceof NodeVertex) {
          String nt = vocab.getWord(((NodeVertex) v).getNode().lhs);
          return String.format("%s{%d-%d}", nt, ((NodeVertex) v).getNode().i, ((NodeVertex) v).getNode().j);
        }
        else {
          Rule r = ((HyperEdgeVertex) v).getHyperEdge().getRule();
          if (r != null) {
            String lhs = vocab.getWord(r.getLHS());
            String french = vocab.getWords(r.getFrench());
            String english = vocab.getWords(r.getEnglish());
            return String.format("%s -> { %s ; %s }", lhs, french, english);
          }
          else
            return "";
        }
View Full Code Here

  {
    this.vocab = vocab;
  }
  public Component getListCellRendererComponent(JList list, Object value,
      int index, boolean isSelected, boolean cellHasFocus) {
    Rule r = ((HyperEdge) value).getRule();
    double score = ((HyperEdge) value).bestDerivationLogP;
    String lhs = vocab.getWord(r.getLHS());
    String french = vocab.getWords(r.getFrench());
    String english = vocab.getWords(r.getEnglish());
    String rule = String.format("%f %s -> { %s ; %s }", score, lhs, french, english);
    JLabel label = new JLabel(rule);
    label.setOpaque(true);
    if (isSelected) {
      label.setBackground(Color.gray);
View Full Code Here

TOP

Related Classes of joshua.decoder.ff.tm.Rule

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.