mocobeta commented on code in PR #846:
URL: https://github.com/apache/lucene/pull/846#discussion_r859684144


##########
lucene/analysis/kuromoji/src/java/org/apache/lucene/analysis/ja/ViterbiNBest.java:
##########
@@ -639,76 +622,35 @@ private void pruneAndRescore(int startPos, int endPos, 
int bestStartIDX) throws
               posData,
               pos,
               toPos,
-              posData.forwardID[forwardArcIDX],
+              posData.getForwardID(forwardArcIDX),
               forwardType,
               true);
         }
       }
-      posData.forwardCount = 0;
+      posData.setForwardCount(0);
     }
   }
 
   @Override
-  protected void backtraceNBest(final Position endPosData, final boolean 
useEOS)
-      throws IOException {
-    if (lattice == null) {
-      lattice = new Lattice();
-    }
-
-    final int endPos = endPosData.getPos();
-    char[] fragment = buffer.get(lastBackTracePos, endPos - lastBackTracePos);
-    lattice.setup(fragment, dictionaryMap, positions, lastBackTracePos, 
endPos, useEOS);
-    lattice.markUnreachable();
-    lattice.calcLeftCost(costs);
-    lattice.calcRightCost(costs);
-
-    int bestCost = lattice.bestCost();
-    if (VERBOSE) {
-      System.out.printf("DEBUG: 1-BEST COST: %d\n", bestCost);
-    }
-    for (int node : lattice.bestPathNodeList()) {
-      registerNode(node, fragment);
-    }
-
-    for (int n = 2; ; ++n) {
-      List<Integer> nbest = lattice.nBestNodeList(n);
-      if (nbest.isEmpty()) {
-        break;
-      }
-      int cost = lattice.cost(nbest.get(0));
-      if (VERBOSE) {
-        System.out.printf("DEBUG: %d-BEST COST: %d\n", n, cost);
-      }
-      if (bestCost + nBestCost < cost) {
-        break;
-      }
-      for (int node : nbest) {
-        registerNode(node, fragment);
-      }
-    }
-    if (VERBOSE) {
-      lattice.debugPrint();
-    }
-  }
-
-  private void registerNode(int node, char[] fragment) {
-    int left = lattice.nodeLeft[node];
-    int right = lattice.nodeRight[node];
-    TokenType type = lattice.nodeDicType[node];
+  protected void registerNode(int node, char[] fragment) {

Review Comment:
   This has to remain in kuromoji for a similar reason as Viterbi's 
`backtrace()` has to remain in kuromoji and nori; in order to add a node to the 
graph, this relies on dictionary-specific features.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to