Changeset 2548

Show
Ignore:
Timestamp:
10/28/08 11:29:53 (2 months ago)
Author:
huangb
Message:

clean up the code a bit

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plugins/preprocessing/edu.iu.nwb.preprocessing.text.normalization/src/edu/iu/nwb/preprocessing/text/normalization/StandardNormalyzer.java

    r2546 r2548  
    4444        this.parameters = parameters; 
    4545        this.context = context; 
    46         try { 
    47                 String[] stopWords = getStopWords(); 
     46         
     47        String[] stopWords = null; 
     48        stopWords = getStopWords(); 
     49        if (stopWords != null) { 
    4850                this.analyzer = new SnowballAnalyzer("English", stopWords); 
    49         }catch (IOException ioe) { 
    50                 System.out.println (">>>got IOException, do not apply stopwords.txt. "+ioe.toString());        
     51        } 
     52        else { 
     53                System.out.println(">>>no stopwords. ");       
    5154                this.analyzer = new SnowballAnalyzer("English"); 
    52         } 
     55        }                
     56         
    5357    } 
    5458 
     
    7276    } 
    7377 
    74     private String[] getStopWords() throws IOException
     78    private String[] getStopWords()
    7579        String filePath = "/edu/iu/nwb/preprocessing/text/normalization/stopwords.txt"; 
    7680        InputStream is = null; 
     
    7882        String line; 
    7983        ArrayList list = new ArrayList(); 
     84        String[]stopWords = null; 
    8085 
    8186        try { 
     
    8691                 list.add(line); 
    8792            } 
     93                stopWords = new String[list.size()]; 
     94                for (int ii=0; ii<list.size(); ii++){ 
     95                        stopWords[ii] = (String) list.get(ii); 
     96                        System.out.println("index = "+ii+", value = "+stopWords[ii]); 
     97                } 
    8898        } 
    8999        catch (Exception e) { 
     
    99109            } 
    100110        } 
     111        return stopWords; 
    101112         
    102         String[]stopWords = new String[list.size()]; 
    103         for (int ii=0; ii<list.size(); ii++){ 
    104                 stopWords[ii] = (String) list.get(ii); 
    105                 System.out.println("index = "+ii+", value = "+stopWords[ii]); 
    106         }        
    107         return stopWords; 
    108113    }            
    109114