Github user KellenSunderland commented on a diff in the pull request:

    https://github.com/apache/incubator-joshua/pull/65#discussion_r79553933
  
    --- Diff: 
src/main/java/org/apache/joshua/decoder/ff/lm/StateMinimizingLanguageModel.java 
---
    @@ -132,30 +138,32 @@ public DPState compute(Rule rule, List<HGNode> 
tailNodes, int i, int j, SourcePa
        * Maps given array of word/class ids to KenLM ids. For estimating cost 
and computing,
        * state retrieval differs slightly.
        */
    -  private long[] mapToKenLmIds(int[] ids, List<HGNode> tailNodes, boolean 
isOnlyEstimate) {
    +  private void writeKenLmIds(int[] ids, List<HGNode> tailNodes, boolean 
isOnlyEstimate,
    +                             KenLMPool poolWrapper) {
    +
    +    poolWrapper.getNgramBuffer().putLong(0, ids.length);
    +
         // The IDs we will to KenLM
    -    long[] kenIds = new long[ids.length];
         for (int x = 0; x < ids.length; x++) {
           int id = ids[x];
     
           if (isNonterminal(id)) {
     
             if (isOnlyEstimate) {
               // For the estimate, we can just mark negative values
    -          kenIds[x] = -1;
    +          poolWrapper.getNgramBuffer().putLong((x + 1) * 
LONG_SIZE_IN_BYTES, -1);
             } else {
               // Nonterminal: retrieve the KenLM long that records the state
               int index = -(id + 1);
               final KenLMState state = (KenLMState) 
tailNodes.get(index).getDPState(stateIndex);
    -          kenIds[x] = -state.getState();
    +          poolWrapper.getNgramBuffer().putLong((x + 1) * 
LONG_SIZE_IN_BYTES, -state.getState());
    --- End diff --
    
    Good point, I'll see if I can clean it up.  


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to