Revision: 19516 http://sourceforge.net/p/gate/code/19516 Author: markagreenwood Date: 2016-08-19 10:54:30 +0000 (Fri, 19 Aug 2016) Log Message: ----------- started to clean up the javadoc so that the build will pass
Modified Paths: -------------- gate/branches/sawdust2/plugins/ANNIE/pom.xml gate/branches/sawdust2/plugins/ANNIE/src/main/java/com/ontotext/gate/gazetteer/HashGazetteer.java gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/Gazetteer.java gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/fsm/FSM.java gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/fsm/FSMInstance.java Modified: gate/branches/sawdust2/plugins/ANNIE/pom.xml =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/pom.xml 2016-08-19 10:39:39 UTC (rev 19515) +++ gate/branches/sawdust2/plugins/ANNIE/pom.xml 2016-08-19 10:54:30 UTC (rev 19516) @@ -9,7 +9,6 @@ <artifactId>base-plugin</artifactId> <!-- this should be the version of GATE you wish to build against --> <version>9.0-SNAPSHOT</version> - <relativePath>../../build/Plugin_Base</relativePath> </parent> <!-- this is the description of this plugin --> Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/com/ontotext/gate/gazetteer/HashGazetteer.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/com/ontotext/gate/gazetteer/HashGazetteer.java 2016-08-19 10:39:39 UTC (rev 19515) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/com/ontotext/gate/gazetteer/HashGazetteer.java 2016-08-19 10:54:30 UTC (rev 19516) @@ -1,7 +1,6 @@ /** * (c) Copyright Ontotext Lab, Sirma Group Corp 2004 */ - package com.ontotext.gate.gazetteer; import gate.AnnotationSet; @@ -32,7 +31,7 @@ import java.util.Map; import java.util.Set; -@CreoleResource(name="Hash Gazetteer", icon="gazetteer", comment="A list lookup component implemented by OntoText Lab. The licence information is also available in licence.ontotext.html in the lib folder of GATE", helpURL="http://www.ontotext.com/downloads/index.html#gazetteer") +@CreoleResource(name = "Hash Gazetteer", icon = "gazetteer", comment = "A list lookup component implemented by OntoText Lab. The licence information is also available in licence.ontotext.html in the lib folder of GATE", helpURL = "http://www.ontotext.com/downloads/index.html#gazetteer") public class HashGazetteer extends AbstractGazetteer { private static final long serialVersionUID = -4603155688378104052L; @@ -45,15 +44,14 @@ private AnnotationSet annotationSet = null; @Override - @SuppressWarnings({"unchecked","rawtypes"}) + @SuppressWarnings({"unchecked", "rawtypes"}) public Resource init() throws ResourceInstantiationException { if(mapsList != null) { // this is a duplicate - nothing to do } else { if(listsURL == null) throw new ResourceInstantiationException( - "No URL provided for gazetteer creation!"); - + "No URL provided for gazetteer creation!"); try { mapsList = new HashMap[1000]; definition = new LinearDefinition(); @@ -70,10 +68,8 @@ fireStatusChanged("Reading " + linearnode.toString()); fireProgressChanged((++j * 100) / i); } - fireProcessFinished(); - } - catch(Exception exception) { + } catch(Exception exception) { throw new ResourceInstantiationException(exception); } } @@ -94,28 +90,22 @@ public void execute() throws ExecutionException { if(document == null) throw new ExecutionException("Document is null!"); annotationSet = document.getAnnotations(annotationSetName); - String s = document.getContent().toString() + " "; if(!super.caseSensitive.booleanValue()) { s = s.toUpperCase(); } - int documentLength = s.length(); int j = 0; int k = 0; - StringBuffer stringbuffer = new StringBuffer(); boolean prevIsSymbol = false; boolean prevIsDigit = false; boolean prevIsLetter = false; - // TODO what does this do, as it is only ever set to false boolean flag11 = false; - String s3 = ""; int i1 = 0; int j1 = 0; - for(int position = 0; position < documentLength; position++) { char c = s.charAt(position); boolean currIsWhitespace = Character.isWhitespace(c); @@ -135,11 +125,10 @@ boolean currIsSymbol = !currIsWhitespace && !currIsLetter && !currIsDigit; boolean currIsLowerCase = Character.isLowerCase(c); if(k <= j - && (currIsWhitespace || currIsSymbol || flag11 - && !currIsLowerCase || !prevIsLetter && currIsLetter)) - k = position; - boolean flag13 = prevIsLetter - && (currIsDigit || currIsSymbol || currIsWhitespace) + && (currIsWhitespace || currIsSymbol || flag11 && !currIsLowerCase || !prevIsLetter + && currIsLetter)) k = position; + boolean flag13 = + prevIsLetter && (currIsDigit || currIsSymbol || currIsWhitespace) || prevIsLetter && currIsLetter && flag11 && !currIsLowerCase || prevIsDigit && (currIsLetter || currIsSymbol || currIsWhitespace) @@ -175,7 +164,6 @@ prevIsLetter = currIsLetter; prevIsSymbol = currIsSymbol; } - fireProcessFinished(); fireStatusChanged("Hash Gazetteer processing finished!"); } @@ -185,18 +173,14 @@ if(!super.caseSensitive.booleanValue()) { word = word.toUpperCase(); } - String s2 = removeTrailingSymbols(word); if(!s2.equals(word)) add(s2, lookup1); String s3 = word + " "; - List<Lookup> arraylist = null; int j = s3.length(); - boolean prevIsLetter = false; boolean prevIsDigit = false; boolean prevIsLowercase = false; - String s4 = ""; Map<String, List<Lookup>> hashmap = null; for(int k = 0; k < j; k++) { @@ -206,40 +190,33 @@ boolean currIsLetter = Character.isLetter(c); boolean currIsSymbol = !currIsWhitespace && !currIsDigit && !currIsLetter; boolean currIsLowercase = Character.isLowerCase(c); - boolean flag18 = prevIsLetter - && (currIsDigit || currIsSymbol || currIsWhitespace) + boolean flag18 = + prevIsLetter && (currIsDigit || currIsSymbol || currIsWhitespace) || prevIsLetter && currIsLetter && prevIsLowercase && !currIsLowercase || prevIsDigit && (currIsLetter || currIsSymbol || currIsWhitespace); - - //if we are on the last character + // if we are on the last character if(k + 1 == j) flag18 = true; - if(flag18) { s4 = normalizeWhitespace(s3.substring(0, k)); int i = s4.length(); if(mapsList[i] == null) { hashmap = new HashMap<String, List<Lookup>>(); mapsList[i] = hashmap; - } - else { + } else { hashmap = mapsList[i]; } if(!hashmap.containsKey(s4)) hashmap.put(s4, null); } prevIsDigit = currIsDigit; prevIsLetter = currIsLetter; - prevIsLowercase = currIsLowercase; - } - arraylist = hashmap.get(s4); if(null == arraylist) { arraylist = new ArrayList<Lookup>(1); arraylist.add(lookup1); - } - else if(!arraylist.contains(lookup1)) arraylist.add(lookup1); + } else if(!arraylist.contains(lookup1)) arraylist.add(lookup1); hashmap.put(s4, arraylist); return true; } @@ -253,22 +230,20 @@ Map<String, List<Lookup>> hashmap = mapsList[i]; if(hashmap == null) { return set; - } - else { + } else { Set<Lookup> hashset = new HashSet<Lookup>(hashmap.get(s1)); return hashset; } } - private boolean annotate(String word, int i, int documentPosition, int wordLength) { + private boolean annotate(String word, int i, int documentPosition, + int wordLength) { if(wordLength >= mapsList.length) return false; Map<String, List<Lookup>> hashmap = mapsList[wordLength]; if(hashmap == null) return false; if(!hashmap.containsKey(word)) return false; List<Lookup> arraylist = hashmap.get(word); - // TODO shouldn't this return false if arraylist is null? - if(null != arraylist) { for(Iterator<Lookup> iterator = arraylist.iterator(); iterator.hasNext();) { Lookup lookup1 = iterator.next(); @@ -284,27 +259,25 @@ featuremap.put("language", lookup1.languages); } try { - annotationSet.add(new Long(i), new Long(documentPosition), "Lookup", featuremap); - } - catch(InvalidOffsetException invalidoffsetexception) { + annotationSet.add(new Long(i), new Long(documentPosition), "Lookup", + featuremap); + } catch(InvalidOffsetException invalidoffsetexception) { throw new LuckyException(invalidoffsetexception.toString()); } } - } - return true; } /** * Removes a string from the gazetteer * - * @param s the item to remove + * @param s + * the item to remove * @return true if the operation was successful */ @Override public boolean remove(String s) { - String s1 = a(s); int i = s1.length(); if(i > mapsList.length) return false; @@ -318,11 +291,12 @@ } /** - * Works backwards through the String parameter removing each - * character until it encounters a letter, digit, or whitespace at - * which point it returns the truncated string. + * Works backwards through the String parameter removing each character until + * it encounters a letter, digit, or whitespace at which point it returns the + * truncated string. * - * @param s the String you wish to remove trailing symbols from + * @param s + * the String you wish to remove trailing symbols from * @return the truncated String that now ends in a letter, digit, or * whitespace character */ @@ -330,26 +304,24 @@ for(int i = s.length() - 1; i >= 0; i--) { char c = s.charAt(i); if(!Character.isLetter(c) && !Character.isDigit(c) - && !Character.isWhitespace(c)) + && !Character.isWhitespace(c)) s = s.substring(0, i); else return s; } - return s; } /** - * Normalizes the whitespace within the String instance by replacing - * any sequence of one or more whitespace characters with a single - * space. Not that any leading/trailing whitespace is also removed. + * Normalizes the whitespace within the String instance by replacing any + * sequence of one or more whitespace characters with a single space. Not that + * any leading/trailing whitespace is also removed. * - * @param s the String to normalize + * @param s + * the String to normalize * @return the normalized String */ private String normalizeWhitespace(String s) { - // this seems to be the same as String.replaceAll("\\s+", " ") - StringBuffer stringbuffer = new StringBuffer(); s = s.trim(); char ac[] = s.toCharArray(); @@ -357,16 +329,12 @@ boolean prevWasWhitespace = false; for(int j = 0; j < i; j++) { char c = ac[j]; - boolean currIsWhitespace = Character.isWhitespace(c); - if(currIsWhitespace && !prevWasWhitespace) stringbuffer.append(' '); else if(!currIsWhitespace) stringbuffer.append(c); - prevWasWhitespace = currIsWhitespace; } - return stringbuffer.toString(); } @@ -377,26 +345,24 @@ char ac[] = s.toCharArray(); int i = s.length(); if(i <= 1) return s; - char firstCharacter = ac[0]; stringbuffer.append(firstCharacter); boolean flag2 = true; boolean prevIsLetter = Character.isLetter(firstCharacter); boolean prevNotLetterOrDigit = !Character.isLetterOrDigit(firstCharacter); - boolean flag10 = true; char c2 = 'p'; - for(int j = 1; j < i; j++) { char currentCharacter = ac[j]; - boolean currNotLetterOrDigit = !Character.isLetterOrDigit(currentCharacter); + boolean currNotLetterOrDigit = + !Character.isLetterOrDigit(currentCharacter); boolean currIsWhitespace = Character.isWhitespace(currentCharacter); boolean currIsLetter = Character.isLetter(currentCharacter); boolean currIsDigit = Character.isDigit(currentCharacter); - if(flag2) { if(prevNotLetterOrDigit && currIsWhitespace) continue; - flag2 = prevIsLetter && currNotLetterOrDigit || prevNotLetterOrDigit + flag2 = + prevIsLetter && currNotLetterOrDigit || prevNotLetterOrDigit && currIsLetter; if(currNotLetterOrDigit) { if(c2 == 'p') c2 = currentCharacter; @@ -408,39 +374,31 @@ stringbuffer.append(Character.toLowerCase(c3)); } } - if(currIsLetter || currIsDigit) { - if(currIsLetter) allLettersUppercase &= Character.isUpperCase(currentCharacter); + if(currIsLetter) + allLettersUppercase &= Character.isUpperCase(currentCharacter); if(!flag10) currentCharacter = Character.toLowerCase(currentCharacter); stringbuffer.append(currentCharacter); - } - else if(!flag2) flag10 = false; - + } else if(!flag2) flag10 = false; prevIsLetter = currIsLetter; prevNotLetterOrDigit = currNotLetterOrDigit; } - String s1 = stringbuffer.toString(); if(allLettersUppercase) s1 = s1.toUpperCase(); return s1; } private void readList(LinearNode linearnode) throws GazetteerException { - if(linearnode == null) throw new GazetteerException("LinearNode node is null"); - GazetteerList gazetteerlist = listsByNode.get(linearnode); if(gazetteerlist == null) throw new GazetteerException("gazetteer list not found by node"); - String s = linearnode.getList(); String majorType = linearnode.getMajorType(); String minorType = linearnode.getMinorType(); String language = linearnode.getLanguage(); - Lookup lookup1 = new Lookup(s, majorType, minorType, language); - if(mappingDefinition != null) { MappingNode mappingnode = mappingDefinition.getNodeByList(s); if(null != mappingnode) { @@ -448,62 +406,48 @@ lookup1.ontology = mappingnode.getOntologyID(); } } - lookup1.list = s; categoryList.add(lookup1); - Iterator<GazetteerNode> iterator = gazetteerlist.iterator(); String normalisedWord = null; - for(; iterator.hasNext(); add(normalisedWord, lookup1)) { String word = iterator.next().toString(); int wordLength = word.length(); for(int j = 0; j < wordLength; j++) { - if(j + 1 != wordLength && !Character.isWhitespace(word.charAt(j))) continue; + if(j + 1 != wordLength && !Character.isWhitespace(word.charAt(j))) + continue; if(j + 1 == wordLength) j = wordLength; normalisedWord = word.substring(0, j).trim(); } } } - + @Override @HiddenCreoleParameter public void setWholeWordsOnly(Boolean wholeWordsOnly) { super.setWholeWordsOnly(wholeWordsOnly); } - + @Override @HiddenCreoleParameter public void setLongestMatchOnly(Boolean longestMatchOnly) { super.setLongestMatchOnly(longestMatchOnly); } - - /** - * For internal use by the duplication mechanism. - */ + @Sharable public void setMapsList(Map<String, List<Lookup>> mapsList[]) { this.mapsList = mapsList; } - /** - * For internal use by the duplication mechanism. - */ public Map<String, List<Lookup>>[] getMapsList() { return mapsList; } - /** - * For internal use by the duplication mechanism. - */ @Sharable public void setCategoryList(ArrayList<Lookup> categoryList) { this.categoryList = categoryList; } - /** - * For internal use by the duplication mechanism. - */ public ArrayList<Lookup> getCategoryList() { return categoryList; } Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/Gazetteer.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/Gazetteer.java 2016-08-19 10:39:39 UTC (rev 19515) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/creole/gazetteer/Gazetteer.java 2016-08-19 10:54:30 UTC (rev 19516) @@ -89,7 +89,7 @@ /** * Adds a new string to the gazetteer - * @param singleItem + * @param singleItem the text of the lookup to add * @param lookup the lookup to be associated with the new string * @return true if the operation was successful */ @@ -97,7 +97,7 @@ /** * Removes a string from the gazetteer - * @param singleItem + * @param singleItem the text of the lookup to remove * @return true if the operation was successful */ boolean remove(String singleItem); Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/fsm/FSM.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/fsm/FSM.java 2016-08-19 10:39:39 UTC (rev 19515) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/fsm/FSM.java 2016-08-19 10:54:30 UTC (rev 19516) @@ -75,6 +75,7 @@ /** * Do the work involved in creating an FSM from a PrioritisedRuleList. + * @param rules the rules list from which the FSM is to be built */ protected void addRules(PrioritisedRuleList rules) { Iterator<Rule> rulesEnum = rules.iterator(); @@ -108,6 +109,7 @@ /** * Do the work involved in creating an FSM from a Rule. + * @param rule the rule to builf the FSM from */ protected void setRule(Rule rule) { @@ -211,6 +213,8 @@ /** * A factory method for new FSMs like this one, given a Rule object. + * @param r create a new FSM from this rule + * @return the new FSM */ protected FSM spawn(Rule r) { return new FSM(r); @@ -219,6 +223,8 @@ /** * A factory method for new FSMs like this one, given a ComplexPatternElement * object. + * @param currentPattern create a new FSM from this pattern + * @return the new FSM */ protected FSM spawn(ComplexPatternElement currentPattern) { return new FSM(currentPattern); @@ -579,6 +585,7 @@ /** * Iterates over all the states in this FSM, setting currentState and * currentTransition, then calling the given Runnable callback. + * @param r the runnable to call */ protected void forEachState (java.lang.Runnable r) { Set<State> stackToProcess = new HashSet<State>(); @@ -649,6 +656,7 @@ * @param includeConstraints * whether to include a stringified representation of each transition * object as part of its label. The default is false. + * @return the GraphViz representation of this FSM */ public String asGraphViz(boolean includeConstraints) { StringBuffer result = new StringBuffer(); @@ -712,6 +720,7 @@ /** * Returns a GML (Graph Modelling Language) representation of the transition * graph of this FSM. + * @return the GML representation of this FSM */ public String getGML() { Modified: gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/fsm/FSMInstance.java =================================================================== --- gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/fsm/FSMInstance.java 2016-08-19 10:39:39 UTC (rev 19515) +++ gate/branches/sawdust2/plugins/ANNIE/src/main/java/gate/fsm/FSMInstance.java 2016-08-19 10:54:30 UTC (rev 19516) @@ -82,6 +82,7 @@ /** Sets the position in the support transition graph for this FSM instance * Convenience method for when the state is not known at construction time. + * @param the state to use */ public void setFSMPosition(State newFSMPos) { FSMPosition = newFSMPos; @@ -295,6 +296,19 @@ * basic object pooling in order to reuse the FSMInstance objects. * This is considered to be a good idea because during jape transducing * a large number of FSMIntances are needed for short periods. + * @param supportGraph the transition graph of the FSM + * @param FSMPosition the state this instance will be in + * @param startNode the node in the AnnotationSet where this FSM instance + * started the matching + * @param AGPosition the node in the AnnotationSet up to which this FSM Instance + * advanced during the matching. + * @param bindings a HashMap that maps from labels (objects of type String) + * to sets of annotations (objects of type AnnotationSet). This map stores + * all the bindings that took place during the matching process. + * This FSMInstance started the matching on an AnnotationSet from "startNode" + * and advanced to "AGPosition"; during this process it traversed the path in + * the transition graph "supportGraph" from the initial state to + * "FSMPosition" and made the bindings stored in "bindings". */ public static FSMInstance getNewInstance(FSM supportGraph, State FSMPosition, Node startNode, Node AGPosition, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ _______________________________________________ GATE-cvs mailing list GATE-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gate-cvs