Revision: 14983
          http://gate.svn.sourceforge.net/gate/?rev=14983&view=rev
Author:   markagreenwood
Date:     2012-01-10 14:57:57 +0000 (Tue, 10 Jan 2012)
Log Message:
-----------
some generics simplification and fixed some javadoc

Modified Paths:
--------------
    gate/trunk/src/gate/creole/morph/Interpret.java
    gate/trunk/src/gate/creole/morph/Morph.java
    gate/trunk/src/gate/creole/morph/ParsingFunctions.java
    gate/trunk/src/gate/creole/morph/ReadFile.java

Modified: gate/trunk/src/gate/creole/morph/Interpret.java
===================================================================
--- gate/trunk/src/gate/creole/morph/Interpret.java     2012-01-10 13:54:49 UTC 
(rev 14982)
+++ gate/trunk/src/gate/creole/morph/Interpret.java     2012-01-10 14:57:57 UTC 
(rev 14983)
@@ -1,5 +1,7 @@
 package gate.creole.morph;
 
+import gate.creole.ResourceInstantiationException;
+
 import java.lang.reflect.Method;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -7,11 +9,12 @@
 import java.util.Comparator;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedSet;
 import java.util.TreeSet;
 import java.util.regex.Pattern;
 
-import gate.creole.ResourceInstantiationException;
-
 /**
  * <p>
  * Title: Interpret.java
@@ -49,20 +52,18 @@
 
        MorphFunctions morphInst;
 
-       ArrayList patterns = new ArrayList();
-       ArrayList fsms = new ArrayList();
+       List patterns = new ArrayList();
+       List fsms = new ArrayList();
        
        /**
         * The initial state of the FSM that backs this morpher
         */
        protected FSMState initialState;
 
-       protected HashSet lastStates;
+       protected Set lastStates;
 
        /**
         * It starts the actual program
-        * 
-        * @param ruleFileName
         */
        public void init(URL ruleFileURL) throws ResourceInstantiationException 
{
                variables = new Storage();
@@ -110,7 +111,7 @@
                        fsms.add(new ArrayList());
                }
                
-               ArrayList fs = (ArrayList) fsms.get(index);
+               List fs = (List) fsms.get(index);
                for(int i=0;i<fs.size();i++) {
                        CharClass cc = (CharClass) fs.get(i);
                        if(cc.ch == ch)
@@ -126,7 +127,7 @@
        
        public FSMState getState(char ch, int index) {
                if(index >= fsms.size()) return null;
-               ArrayList fs = (ArrayList) fsms.get(index);
+               List fs = (List) fsms.get(index);
                for(int i=0;i<fs.size();i++) {
                        CharClass cc = (CharClass) fs.get(i);
                        if(cc.ch == ch)
@@ -135,8 +136,8 @@
                return null;
        }
        
-       private HashSet getStates(char ch, HashSet states) {
-               HashSet newStates = new HashSet();
+       private Set getStates(char ch, Set states) {
+               Set newStates = new HashSet();
                Iterator iter = states.iterator();
                while (iter.hasNext()) {
                        FSMState st = (FSMState) iter.next();
@@ -165,10 +166,6 @@
        }
        
        /**
-        * lookup <br>
-        * 
-        * @param singleItem
-        *            a single string to be looked up by the gazetteer
         * @return set of the Lookups associated with the parameter
         */
        public String runMorpher(String word, String category) {
@@ -178,7 +175,7 @@
                }
                
                foundRule = false;
-               HashSet states = new HashSet();
+               Set states = new HashSet();
                states.add(initialState);
                for (int i = 0; i < word.length(); i++) {
                        char ch = word.charAt(i);
@@ -191,10 +188,8 @@
 
                // we have all states here
                // we obtain all RHSes
-               TreeSet rhses = new TreeSet(new Comparator() {
-      public int compare(Object o1, Object o2) {
-        RHS r1 = (RHS) o1;
-        RHS r2 = (RHS) o2;
+               SortedSet<RHS> rhses = new TreeSet<RHS>(new Comparator<RHS>() {
+      public int compare(RHS r1, RHS r2) {
         return r1.getPatternIndex() - r2.getPatternIndex();
       }
     });
@@ -217,7 +212,7 @@
          return patternIndex;
        }
        
-       protected String executeRHSes(TreeSet rhses, String word, String 
category) {
+       protected String executeRHSes(SortedSet rhses, String word, String 
category) {
     foundRule = false;
     // rhses are in sorted order
     // we need to check if the word is compatible with pattern
@@ -529,9 +524,9 @@
                patterns.add(Pattern.compile(regExp));
                String[] rules = ParsingFunctions.normlizePattern(regExp);
                for (int m = 0; m < rules.length; m++) {
-                       HashSet lss = new HashSet();
+                       Set lss = new HashSet();
                        lss.clear();
-                       HashSet newSet = new HashSet();
+                       Set newSet = new HashSet();
                        newSet.add(initialState);
                        lss.add(newSet);
                        PatternPart parts[] = ParsingFunctions
@@ -541,7 +536,7 @@
                        }
                        Iterator iter = lss.iterator();
                        while (iter.hasNext()) {
-                               HashSet set = (HashSet) iter.next();
+                               Set set = (HashSet) iter.next();
                                Iterator subIter = set.iterator();
                                while (subIter.hasNext()) {
                                        FSMState st = (FSMState) subIter.next();
@@ -552,8 +547,8 @@
                //drawFSM();
        }
 
-       private HashSet intersect(HashSet a, HashSet b) {
-               HashSet result = new HashSet();
+       private Set intersect(Set a, Set b) {
+               Set result = new HashSet();
                Iterator iter = a.iterator();
                while (iter.hasNext()) {
                        FSMState st = (FSMState) iter.next();

Modified: gate/trunk/src/gate/creole/morph/Morph.java
===================================================================
--- gate/trunk/src/gate/creole/morph/Morph.java 2012-01-10 13:54:49 UTC (rev 
14982)
+++ gate/trunk/src/gate/creole/morph/Morph.java 2012-01-10 14:57:57 UTC (rev 
14983)
@@ -19,18 +19,30 @@
  */
 
 
+import gate.Annotation;
+import gate.AnnotationSet;
+import gate.Factory;
+import gate.Factory.DuplicationContext;
+import gate.FeatureMap;
+import gate.ProcessingResource;
+import gate.Resource;
+import gate.Utils;
+import gate.creole.AbstractLanguageAnalyser;
+import gate.creole.CustomDuplication;
+import gate.creole.ExecutionException;
+import gate.creole.ResourceInstantiationException;
+import gate.creole.metadata.CreoleParameter;
+import gate.creole.metadata.CreoleResource;
+import gate.creole.metadata.Optional;
+import gate.creole.metadata.RunTime;
+import gate.util.GateRuntimeException;
+
 import java.net.URL;
 import java.util.Iterator;
 
+import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
-import org.apache.log4j.Level;
 
-import gate.*;
-import gate.Factory.DuplicationContext;
-import gate.creole.*;
-import gate.creole.metadata.*;
-import gate.util.GateRuntimeException;
-
 /**
  * Description: This class is a wrapper for {@link 
gate.creole.morph.Interpret},
  * the Morphological Analyzer.
@@ -240,7 +252,7 @@
 
   /**
    * Sets the rule file to be processed
-   * @param rulesFileURL - rule File name to be processed
+   * @param rulesFile - rule File name to be processed
    */
   public void setRulesFile(URL rulesFile) {
     this.rulesFile = rulesFile;

Modified: gate/trunk/src/gate/creole/morph/ParsingFunctions.java
===================================================================
--- gate/trunk/src/gate/creole/morph/ParsingFunctions.java      2012-01-10 
13:54:49 UTC (rev 14982)
+++ gate/trunk/src/gate/creole/morph/ParsingFunctions.java      2012-01-10 
14:57:57 UTC (rev 14983)
@@ -1,10 +1,9 @@
 package gate.creole.morph;
 
 import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.Set;
 import java.util.Stack;
 
 /**
@@ -380,16 +379,8 @@
                return parameters;
        }
        
-       
-       /**
-        * 
-        * @param string
-        * @param type
-        * @param initState
-        * @return
-        */
-       public static HashSet createFSMs(String string, int type, HashSet 
initStates, Interpret owner) {
-               HashSet result = new HashSet();
+       public static Set createFSMs(String string, int type, Set initStates, 
Interpret owner) {
+               Set result = new HashSet();
                // we create different groups for states 
                Iterator iter = initStates.iterator();
                while(iter.hasNext()) {
@@ -443,10 +434,6 @@
        
        /**
         * (abc) -> a -> b -> c ->
-        * 
-        * @param line
-        * @param initState
-        * @return
         */
        public static ArrayList andFSMs(String line, HashSet initStates, 
Interpret owner) {
                // for the first inital State
@@ -498,9 +485,6 @@
         * [abc] -> a, 
         *               -> b, 
         *               -> c
-        * @param line
-        * @param initState
-        * @return
         */ 
        public static ArrayList orFSMs(String line, HashSet initStates, 
Interpret owner) {
                // for each character in the line
@@ -540,10 +524,6 @@
        /**
         * [abc]+ 
         * each element can travel to itself and can travel to next one
-        * 
-        * @param line
-        * @param initState
-        * @return
         */
        public static ArrayList orPlusFSMs(String line, HashSet initStates, 
Interpret owner) {
                // for each character in the line
@@ -595,9 +575,6 @@
         * (abc)+ 
         * -> a -> b -> c -> null 
         * -> a -> b -> c -> a
-        * @param line
-        * @param initState
-        * @return
         */
        public static ArrayList andPlusFSMs(String line, HashSet initStates, 
Interpret owner) {
                // for the first inital State
@@ -651,10 +628,6 @@
        /**
         * [abc]* 
         * each element can have reference to adjecent ones and to itself
-        * 
-        * @param line
-        * @param initState
-        * @return
         */
        public static ArrayList orStarFSMs(String line, HashSet initStates, 
Interpret owner) {
                // for each character in the line
@@ -706,10 +679,6 @@
 
        /**
         * (abc)*
-        * 
-        * @param line
-        * @param initState
-        * @return
         */
        public static ArrayList andStarFSMs(String line, HashSet initStates, 
Interpret owner) {
                // for the first inital State

Modified: gate/trunk/src/gate/creole/morph/ReadFile.java
===================================================================
--- gate/trunk/src/gate/creole/morph/ReadFile.java      2012-01-10 13:54:49 UTC 
(rev 14982)
+++ gate/trunk/src/gate/creole/morph/ReadFile.java      2012-01-10 14:57:57 UTC 
(rev 14983)
@@ -2,9 +2,12 @@
 
 import gate.util.BomStrippingInputStreamReader;
 
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.List;
 
 /**
  * <p>Title: ReadFile.java </p>
@@ -20,11 +23,11 @@
   private int pointer = 0;
 
   /** Stores each line of the file as a separate String in the ArrayList */
-  private ArrayList data;
+  private List data;
 
   /**
    * Constructor - Initialise the buffered Reader instance
-   * @param fileName Name of the file to be read
+   * @param fileURL URL of the file to be read
    */
   public ReadFile(URL fileURL) {
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to