- Timestamp:
- 2011-04-15T13:38:25+12:00 (13 years ago)
- Location:
- gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas
- Files:
-
- 1 added
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
gs3-extensions/atlas-src/trunk/src/org/greenstone/atlas/server/GateScanner.java
r22272 r23906 4 4 import gate.AnnotationSet; 5 5 import gate.Corpus; 6 import gate.CorpusController;7 6 import gate.Document; 8 7 import gate.Factory; … … 10 9 import gate.Gate; 11 10 import gate.GateConstants; 12 import gate.ProcessingResource;13 import gate.corpora.RepositioningInfo;14 11 import gate.creole.ANNIEConstants; 15 import gate.creole.ResourceInstantiationException;16 12 import gate.creole.SerialAnalyserController; 17 13 import gate.util.GateException; … … 22 18 import java.net.URL; 23 19 import java.util.ArrayList; 24 import java.util.HashSet; 25 import java.util.Iterator; 26 import java.util.Set; 20 import java.util.HashMap; 27 21 28 22 import org.apache.log4j.BasicConfigurator; … … 37 31 { 38 32 BasicConfigurator.configure(); 39 Gate.setGateHome(new File(" /home/sam/Desktop/Research/Gate5"));40 Gate.setPluginsHome(new File(" /home/sam/Desktop/Research/Gate5/plugins"));41 Gate.setUserConfigFile(new File(" /home/sam/Desktop/Research/Gate5/gate.xml"));33 Gate.setGateHome(new File("C:\\Users\\sjm84\\Desktop\\stuff\\Gate5.2")); 34 Gate.setPluginsHome(new File("C:\\Users\\sjm84\\Desktop\\stuff\\Gate5.2\\plugins")); 35 Gate.setUserConfigFile(new File("C:\\Users\\sjm84\\Desktop\\stuff\\Gate5.2\\gate.xml")); 42 36 Gate.init(); 43 Gate.getCreoleRegister().registerDirectories(new URL("file:///home/sam/Desktop/Research/Gate5/plugins/ANNIE"));37 Gate.getCreoleRegister().registerDirectories(new File("C:\\Users\\sjm84\\Desktop\\stuff\\Gate5.2\\plugins\\ANNIE").toURI().toURL()); 44 38 Gate.getUserConfig().put(GateConstants.DOCUMENT_ADD_SPACE_ON_UNPACK_FEATURE_NAME, new Boolean(false)); 45 39 … … 70 64 } // execute() 71 65 72 public ArrayList<Word> classifyText(String originalText)66 public HashMap<String, Word> classifyText(String originalText) 73 67 { 74 ArrayList<Word> words = new ArrayList<Word>();68 HashMap<String, Word> words = new HashMap<String, Word>(); 75 69 try 76 70 { 77 // create a GATE corpus and add a document for each command-line78 // argument79 71 Corpus corpus = (Corpus) Factory.createResource("gate.corpora.CorpusImpl"); 80 72 FeatureMap params = Factory.newFeatureMap(); … … 91 83 AnnotationSet annotations = doc.getAnnotations(); 92 84 93 int index = 0;94 85 for(int j = 0; j < annotations.size(); j++) 95 86 { … … 102 93 if(currentAnnotation.getType().equals("Token")) 103 94 { 104 Word w = new Word(); 105 w.setIndex(index++); 106 w.setClassification((String)currentAnnotation.getFeatures().get("category")); 107 w.setValue((String)currentAnnotation.getFeatures().get("string")); 108 109 words.add(w); 95 Word w = null; 96 if(words.containsKey((String)currentAnnotation.getFeatures().get("string"))) 97 { 98 w = words.get((String)currentAnnotation.getFeatures().get("string")); 99 w.addClassification((String)currentAnnotation.getFeatures().get("category")); 100 w.setValue((String)currentAnnotation.getFeatures().get("string")); 101 } 102 else 103 { 104 w = new Word(); 105 w.addClassification((String)currentAnnotation.getFeatures().get("category")); 106 w.setValue((String)currentAnnotation.getFeatures().get("string")); 107 words.put(w.getValue(), w); 108 } 110 109 } 111 110 }
Note:
See TracChangeset
for help on using the changeset viewer.