jimczi commented on a change in pull request #576: LUCENE-8631: 
Longest-Matching for User words in Nori Tokenizer
URL: https://github.com/apache/lucene-solr/pull/576#discussion_r262863914
 
 

 ##########
 File path: 
lucene/analysis/nori/src/java/org/apache/lucene/analysis/ko/KoreanTokenizer.java
 ##########
 @@ -651,20 +662,37 @@ private void parse() throws IOException {
       if (userFST != null) {
         userFST.getFirstArc(arc);
         int output = 0;
+        int posAheadMax = 0;
+        int output_posAheadMax = 0;
+        int arcFinalOut_posAheadMax = 0;
+
         for(int posAhead=pos;;posAhead++) {
           final int ch = buffer.get(posAhead);
-          if (ch == -1) {
-            break;
-          }
-          if (userFST.findTargetArc(ch, arc, arc, posAhead == pos, 
userFSTReader) == null) {
-            break;
+          if (ch == -1 || userFST.findTargetArc(ch, arc, arc, posAhead == pos, 
userFSTReader) == null) {
+            if (anyMatches
+              && posAheadMax > global_posAheadMax) {
 
 Review comment:
   I also think it would be more readable if you move this code after the for 
loop with a comment explaining what it does (e.g.: add the longest matching 
user term)

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to