Package joshua.decoder.ff.state_maintenance

Examples of joshua.decoder.ff.state_maintenance.NgramDPState


   
    //####now calculate the BLEU score and state
    int[] left_lm_state  = null;
    int[] right_lm_state = null;
    if (!always_maintain_seperate_lm_state && lm_order >= g_bleu_order) {  //do not need to change lm state, just use orignal lm state
      NgramDPState state = (NgramDPState) parent_item.getDPState(this.lm_feat_id);
      left_lm_state = intListToArray( state.getLeftLMStateWords() );
      right_lm_state = intListToArray( state.getRightLMStateWords() );
    } else {
      left_lm_state = get_left_equiv_state(left_state_sequence, tbl_suffix);
      right_lm_state = get_right_equiv_state(right_state_sequence, tbl_prefix);
     
      //debug
View Full Code Here


    for (int c = 0; c < enWords.length; c++) {
      int curID = enWords[c];
      if (symbolTable.isNonterminal(curID)) {       
        int index = symbolTable.getTargetNonterminalIndex(curID);
     
        NgramDPState state = (NgramDPState) antNodes.get(index).getDPState(this.getStateID());
        List<Integer> leftContext = state.getLeftLMStateWords();
        List<Integer> rightContext = state.getRightLMStateWords();
        if (leftContext.size() != rightContext.size() ) {
          throw new RuntimeException("computeTransition: left and right contexts have unequal lengths");
        }
       
        //================ left context
View Full Code Here

    HashMap<Integer,DPState> dpStates = null;
   
    if (fds[1].compareTo(NULL_ITEM_STATE) != 0) {
      // Assume the only stateful feature is lm feature
      dpStates = new HashMap<Integer,DPState>();
      dpStates.put(this.LMFeatureID,  new NgramDPState(this.symbolTable, fds[1]));
    }
   
    List<HyperEdge> edges = null;
    HyperEdge         bestEdge = null;
    double bestLogP = Double.NEGATIVE_INFINITY;
View Full Code Here

          int curID = enWords[c];
          if(symbolTable.isNonterminal(curID)==true){//non-terminal words         
            //== get the left and right context
            int index = symbolTable.getTargetNonterminalIndex(curID);
            HGNode antNode =  antNodes.get(index);
            NgramDPState state     = (NgramDPState) antNode.getDPState(this.ngramStateID);
            //System.out.println("lm_feat_is: " + this.lm_feat_id + " ; state is: " + state);
            List<Integer>   leftContext = state.getLeftLMStateWords();
            List<Integer>   rightContext = state.getRightLMStateWords();
          if (leftContext.size() != rightContext.size()) {
            System.out.println("getAllNgrams: left and right contexts have unequal lengths");
            System.exit(1);
          }
         
View Full Code Here

          System.out.println("baselineLMOrder is too small");
          System.exit(0);
        }
     
      HashMap<String, Integer> res = new HashMap<String, Integer>();
      NgramDPState state     = (NgramDPState) antNode.getDPState(this.ngramStateID);
     
      List<Integer> currentNgram = new ArrayList<Integer>();
      List<Integer>   leftContext = state.getLeftLMStateWords();   
      List<Integer>   rightContext = state.getRightLMStateWords();
      if (leftContext.size() != rightContext.size()) {
        System.out.println("computeFinalTransition: left and right contexts have unequal lengths");
        System.exit(1);
      }
     
View Full Code Here

          int c_id = en_words[c];
          if(p_symbol.isNonterminal(c_id)==true){
            //## get the left and right context
            int index= p_symbol.getTargetNonterminalIndex(c_id);
            HGNode ant_item = (HGNode) dt.getAntNodes().get(index);
            NgramDPState state     = (NgramDPState) ant_item.getDPState(this.ngramStateID);
          List<Integer>   l_context = state.getLeftLMStateWords();
          List<Integer>   r_context = state.getRightLMStateWords();
          if (l_context.size() != r_context.size()) {
            System.out.println("LMModel>>lookup_words1_equv_state: left and right contexts have unequal lengths");
            System.exit(1);
          }
         
          for(int t : l_context)//always have l_context
              words.add(t);               
           
            if(r_context.size()>=baseline_lm_order-1){//the right and left are NOT overlapping
              if(match_a_span(words)==false)//no match
                return true;//filter out
                   
              words.clear();//start a new chunk; the sequence stops whenever the right-lm-state jumps in (i.e., having eclipsed words) 
              for(int t : r_context)
                words.add(t);           
            }
          }else{
            words.add(c_id);
          }
        }
      if(words.size()>0){
        if(match_a_span(words)==false)//no match
          return true;//filter out
      }
    }else{//hyperedges under goal item
      if(dt.getAntNodes().size()!=1){System.out.println("error deduction under goal item have more than one item"); System.exit(0);}
      HGNode ant_item = (HGNode) dt.getAntNodes().get(0);
      NgramDPState state     = (NgramDPState) ant_item.getDPState(this.ngramStateID);
      List<Integer>   l_context = state.getLeftLMStateWords();
      List<Integer>   r_context = state.getRightLMStateWords();
      if(matchLeftOrRightMostSpan(l_context, true)==false ||
         matchLeftOrRightMostSpan(r_context, false)==false )//the left-most or right-most word does not match
        return true;
    }
    return false;
View Full Code Here

        int c_id = enWords[c];
        if(symbolTbl.isNonterminal(c_id)==true){
          int index=symbolTbl.getTargetNonterminalIndex(c_id);
          HGNode antNode = antNodes.get(index);   
         
          NgramDPState state     = (NgramDPState) antNode.getDPState(this.ngramStateID);
          List<Integer>   l_context = state.getLeftLMStateWords();
          List<Integer>   r_context = state.getRightLMStateWords();
   
          if(contextWord!=null){
            String bigram = null;
            if(this.useIntegerString)
              bigram = contextWord +  " " + l_context.get(0);
View Full Code Here

     
      //=== now calculate the BLEU score and state
      List<Integer> leftLMState = null;
      List<Integer>  rightLMState= null;
    if(alwaysMaintainSeperateLMState==false && lmOrder>=bleuOrder){  //do not need to change lm state, just use orignal lm state
      NgramDPState state     = (NgramDPState) parentNode.getDPState(this.ngramStateID);
      leftLMState = state.getLeftLMStateWords();
      rightLMState = state.getRightLMStateWords();
    }else{
      leftLMState = getLeftEquivState(leftStateSequence, suffixTbl);
      rightLMState = getRightEquivState(rightStateSequence, prefixTbl);
     
      //debug
View Full Code Here

TOP

Related Classes of joshua.decoder.ff.state_maintenance.NgramDPState

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.