You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2013/10/28 01:57:00 UTC

svn commit: r1536233 - in /lucene/dev/branches/lucene4956/lucene/analysis/arirang/src: java/org/apache/lucene/analysis/ko/ java/org/apache/lucene/analysis/ko/morph/ test/org/apache/lucene/analysis/ko/

Author: rmuir
Date: Mon Oct 28 00:57:00 2013
New Revision: 1536233

URL: http://svn.apache.org/r1536233
Log:
LUCENE-4956: move all the list creation out of compoundnounanalyzer

Modified:
    lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/KoreanFilter.java
    lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/AnalysisOutput.java
    lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/CompoundNounAnalyzer.java
    lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/MorphAnalyzer.java
    lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/test/org/apache/lucene/analysis/ko/TestCompoundSegment.java

Modified: lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/KoreanFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/KoreanFilter.java?rev=1536233&r1=1536232&r2=1536233&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/KoreanFilter.java (original)
+++ lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/KoreanFilter.java Mon Oct 28 00:57:00 2013
@@ -30,7 +30,6 @@ import org.apache.lucene.analysis.TokenS
 import org.apache.lucene.analysis.ko.dic.CompoundEntry;
 import org.apache.lucene.analysis.ko.dic.DictionaryUtil;
 import org.apache.lucene.analysis.ko.dic.HanjaMapper;
-import org.apache.lucene.analysis.ko.dic.WordEntry;
 import org.apache.lucene.analysis.ko.morph.AnalysisOutput;
 import org.apache.lucene.analysis.ko.morph.CompoundNounAnalyzer;
 import org.apache.lucene.analysis.ko.morph.MorphAnalyzer;
@@ -340,7 +339,7 @@ public final class KoreanFilter extends 
     
     // 추출된 명사가 복합명사인 경우 분리한다.
     for(int i=0;i<maxCandidate;i++) {
-      List<CompoundEntry> results = cnAnalyzer.analyze(candiList.get(i).toString());
+      CompoundEntry results[] = cnAnalyzer.analyze(candiList.get(i).toString());
       
       int pos = 0;
       int offset = 0;

Modified: lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/AnalysisOutput.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/AnalysisOutput.java?rev=1536233&r1=1536232&r2=1536233&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/AnalysisOutput.java (original)
+++ lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/AnalysisOutput.java Mon Oct 28 00:57:00 2013
@@ -190,7 +190,8 @@ public class AnalysisOutput implements C
   
   // nocommit
   public void setCNounList(CompoundEntry[] cnoun) {
-    compound.clear();
+    // WTF, something holds on to 'previous' cnoun list after MorphAnalyzer.confirmCnoun sets it to something new.
+    compound = new ArrayList<CompoundEntry>();
     addCNouns(cnoun);
   }
   

Modified: lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/CompoundNounAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/CompoundNounAnalyzer.java?rev=1536233&r1=1536232&r2=1536233&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/CompoundNounAnalyzer.java (original)
+++ lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/CompoundNounAnalyzer.java Mon Oct 28 00:57:00 2013
@@ -17,10 +17,6 @@ package org.apache.lucene.analysis.ko.mo
  * limitations under the License.
  */
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
 import org.apache.lucene.analysis.ko.dic.CompoundEntry;
 import org.apache.lucene.analysis.ko.dic.DictionaryUtil;
 import org.apache.lucene.analysis.ko.dic.WordEntry;
@@ -36,27 +32,16 @@ public class CompoundNounAnalyzer {
   }
 
   /** Returns decompounded list for word, or null */
-  public List<CompoundEntry> analyze(String input) {
+  public CompoundEntry[] analyze(String input) {
     if (input.length() < 3 || input.length() > 20) {
       // ignore less than 3 letters or more than 20 letters.
       return null;
     }
     WordEntry entry = DictionaryUtil.getCompoundNoun(input);
     if (entry != null) {
-      // nocommit
-      ArrayList<CompoundEntry> l = new ArrayList<CompoundEntry>();
-      l.addAll(Arrays.asList(entry.getCompounds()));
-      return l;
+      return entry.getCompounds();
     } else {
-      CompoundEntry[] compounds = analyze(input, true);
-      if (compounds == null) {
-        return null;
-      } else {
-        // nocommit
-        ArrayList<CompoundEntry> l = new ArrayList<CompoundEntry>();
-        l.addAll(Arrays.asList(compounds));
-        return l;
-      }
+      return analyze(input, true);
     }
   }
     

Modified: lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/MorphAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/MorphAnalyzer.java?rev=1536233&r1=1536232&r2=1536233&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/MorphAnalyzer.java (original)
+++ lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/MorphAnalyzer.java Mon Oct 28 00:57:00 2013
@@ -374,11 +374,11 @@ public class MorphAnalyzer {
     if(o.getStem().length()<3) return false;
      
     
-    List<CompoundEntry> results = cnAnalyzer.analyze(o.getStem());
+    CompoundEntry results[] = cnAnalyzer.analyze(o.getStem());
 
     boolean success = false;
        
-    if(results != null && results.size()>1) {       
+    if(results != null && results.length > 1) {       
       o.setCNounList(results);
       success = true;
       int maxWordLen = 0;

Modified: lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/test/org/apache/lucene/analysis/ko/TestCompoundSegment.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/test/org/apache/lucene/analysis/ko/TestCompoundSegment.java?rev=1536233&r1=1536232&r2=1536233&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/test/org/apache/lucene/analysis/ko/TestCompoundSegment.java (original)
+++ lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/test/org/apache/lucene/analysis/ko/TestCompoundSegment.java Mon Oct 28 00:57:00 2013
@@ -52,7 +52,7 @@ public class TestCompoundSegment extends
    */
   private String[] splitByUnitWord(CompoundNounAnalyzer analyzer, String input) throws Exception {
     
-    List<CompoundEntry> results = analyzer.analyze(input);
+    CompoundEntry results[] = analyzer.analyze(input);
         
     List<String> nounList = new ArrayList<String>();
     for(CompoundEntry entry : results) {