You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2013/10/18 10:47:35 UTC

svn commit: r1533362 - in /lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko: dic/DictionaryUtil.java morph/WordEntry.java

Author: uschindler
Date: Fri Oct 18 08:47:34 2013
New Revision: 1533362

URL: http://svn.apache.org/r1533362
Log:
LUCENE-4956: Make WordEntry components final

Modified:
    lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/dic/DictionaryUtil.java
    lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/WordEntry.java

Modified: lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/dic/DictionaryUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/dic/DictionaryUtil.java?rev=1533362&r1=1533361&r2=1533362&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/dic/DictionaryUtil.java (original)
+++ lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/dic/DictionaryUtil.java Fri Oct 18 08:47:34 2013
@@ -69,13 +69,12 @@ public class DictionaryUtil {
         String[] infos = compound.split("[:]+");
         if(infos.length!=3&&infos.length!=2) continue;
         
-        WordEntry entry = null;
+        final List<CompoundEntry> c = compoundArrayToList(infos[1], infos[1].split("[,]+"));
+        final WordEntry entry;
         if(infos.length==2) 
-          entry = new WordEntry(infos[0].trim(),"20000000X".toCharArray());
+          entry = new WordEntry(infos[0].trim(),"20000000X".toCharArray(), c);
         else 
-          entry = new WordEntry(infos[0].trim(),("200"+infos[2]+"0X").toCharArray());
-        
-        entry.setCompounds(compoundArrayToList(infos[1], infos[1].split("[,]+")));
+          entry = new WordEntry(infos[0].trim(),("200"+infos[2]+"0X").toCharArray(), c);
         dictionary.add(entry.getWord(), entry);
       }
       
@@ -91,8 +90,7 @@ public class DictionaryUtil {
       for(String compound: lines) {    
         String[] infos = compound.split("[:]+");
         if(infos.length!=2) continue;
-        WordEntry entry = new WordEntry(infos[0].trim(),"90000X".toCharArray());
-        entry.setCompounds(compoundArrayToList(infos[1], infos[1].split("[,]+")));
+        WordEntry entry = new WordEntry(infos[0].trim(),"90000X".toCharArray(), compoundArrayToList(infos[1], infos[1].split("[,]+")));
         uncompounds.put(entry.getWord(), entry);
       }      
   

Modified: lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/WordEntry.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/WordEntry.java?rev=1533362&r1=1533361&r2=1533362&view=diff
==============================================================================
--- lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/WordEntry.java (original)
+++ lucene/dev/branches/lucene4956/lucene/analysis/arirang/src/java/org/apache/lucene/analysis/ko/morph/WordEntry.java Fri Oct 18 08:47:34 2013
@@ -18,6 +18,7 @@ package org.apache.lucene.analysis.ko.mo
  */
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 public class WordEntry {
@@ -36,45 +37,33 @@ public class WordEntry {
   /**
    * 단어
    */
-  private String word;
+  private final String word;
   
   /**
    * 단어특성
    */
-  private char[] features;
+  private final char[] features;
   
-  private List<CompoundEntry> compounds = new ArrayList<CompoundEntry>();
-  
-  public WordEntry() {
-    
-  }
+  private final List<CompoundEntry> compounds;
   
   public WordEntry(String word) {
-    this.word = word;
+    this(word, null);
   }
   
   public WordEntry(String word, char[] cs) {
-    this.word = word;
-    this.features = cs;
+    this(word, cs, Collections.<CompoundEntry>emptyList());
   }
   
-  public WordEntry(String word, List<CompoundEntry> c) {
+  public WordEntry(String word, char[] cs, List<CompoundEntry> compounds) {
     this.word = word;
-    this.compounds = c;
-  }
-  
-  public void setWord(String w) {
-    this.word = w;
+    this.features = cs;
+    this.compounds = Collections.unmodifiableList(compounds);
   }
   
   public String getWord() {
     return this.word;
   }
   
-  public void setFeatures(char[] cs) {
-    this.features = cs;
-  }
-  
   public char getFeature(int index) {
     if(features==null||features.length<index) return '0';    
     return features[index];
@@ -84,10 +73,6 @@ public class WordEntry {
     return this.features;
   }
   
-  public void setCompounds(List<CompoundEntry> c) {
-    this.compounds = c;
-  }
-  
   public List<CompoundEntry> getCompounds() {
     return this.compounds;
   }