Revision: 14911
          http://gate.svn.sourceforge.net/gate/?rev=14911&view=rev
Author:   valyt
Date:     2012-01-06 16:04:33 +0000 (Fri, 06 Jan 2012)
Log Message:
-----------
Next release is a major version, so we can break things - yay!

Corpus now contains Documents (how novel!).

Modified Paths:
--------------
    gate/trunk/src/gate/SimpleCorpus.java
    gate/trunk/src/gate/corpora/CorpusImpl.java
    gate/trunk/src/gate/corpora/SerialCorpusImpl.java
    gate/trunk/src/gate/gui/CorpusEditor.java
    gate/trunk/src/gate/gui/NameBearerHandle.java
    gate/trunk/src/gate/util/CorpusSaver.java
    gate/trunk/src/gate/util/persistence/CorpusPersistence.java

Modified: gate/trunk/src/gate/SimpleCorpus.java
===================================================================
--- gate/trunk/src/gate/SimpleCorpus.java       2012-01-06 15:42:56 UTC (rev 
14910)
+++ gate/trunk/src/gate/SimpleCorpus.java       2012-01-06 16:04:33 UTC (rev 
14911)
@@ -28,7 +28,7 @@
 /**
  * Corpora are lists of Document. TIPSTER equivalent: Collection.
  */
-public interface SimpleCorpus extends LanguageResource, List, NameBearer {
+public interface SimpleCorpus extends LanguageResource, List<Document>, 
NameBearer {
 
   public static final String CORPUS_NAME_PARAMETER_NAME = "name";
 

Modified: gate/trunk/src/gate/corpora/CorpusImpl.java
===================================================================
--- gate/trunk/src/gate/corpora/CorpusImpl.java 2012-01-06 15:42:56 UTC (rev 
14910)
+++ gate/trunk/src/gate/corpora/CorpusImpl.java 2012-01-06 16:04:33 UTC (rev 
14911)
@@ -115,7 +115,7 @@
   /**
    * The underlying list that holds the documents in this corpus.
    */
-  protected List supportList = null;
+  protected List<Document> supportList = null;
 
   /**
    * A proxy list that stores the actual data in an internal list and
@@ -225,7 +225,7 @@
     return supportList.toArray(a);
   }
 
-  public boolean add(Object o) {
+  public boolean add(Document o) {
     return supportList.add(o);
   }
 
@@ -267,19 +267,19 @@
     return supportList.hashCode();
   }
 
-  public Object get(int index) {
+  public Document get(int index) {
     return supportList.get(index);
   }
 
-  public Object set(int index, Object element) {
+  public Document set(int index, Document element) {
     return supportList.set(index, element);
   }
 
-  public void add(int index, Object element) {
+  public void add(int index, Document element) {
     supportList.add(index, element);
   }
 
-  public Object remove(int index) {
+  public Document remove(int index) {
     return supportList.remove(index);
   }
 

Modified: gate/trunk/src/gate/corpora/SerialCorpusImpl.java
===================================================================
--- gate/trunk/src/gate/corpora/SerialCorpusImpl.java   2012-01-06 15:42:56 UTC 
(rev 14910)
+++ gate/trunk/src/gate/corpora/SerialCorpusImpl.java   2012-01-06 16:04:33 UTC 
(rev 14911)
@@ -67,13 +67,9 @@
 // always restore the doc, because it has its persistence ID.
 
 @CreoleResource(name = "GATE Serial Corpus", isPrivate = true, comment = "GATE 
persistent corpus (serialisation)", icon = "corpus", helpURL = 
"http://gate.ac.uk/userguide/sec:developer:datastores";)
-public class SerialCorpusImpl extends AbstractLanguageResource
-                                                              implements
-                                                              Corpus,
-                                                              CreoleListener,
-                                                              
DatastoreListener,
-                                                              IndexedCorpus,
-                                                              
CustomDuplication {
+public class SerialCorpusImpl extends AbstractLanguageResource 
+    implements Corpus, CreoleListener, DatastoreListener, IndexedCorpus,
+    CustomDuplication {
 
   /** Debug flag */
   private static final boolean DEBUG = false;
@@ -86,7 +82,7 @@
 
   // here I keep document index as key (same as the index in docDataList
   // which defines the document order) and Documents as value
-  protected transient List documents = null;
+  protected transient List<Document> documents = null;
 
   protected transient IndexManager indexManager = null;
 
@@ -636,8 +632,8 @@
             "toArray(Object[] a) is not implemented for SerialCorpusImpl");
   }
 
-  public boolean add(Object o) {
-    if(!(o instanceof Document) || o == null) return false;
+  public boolean add(Document o) {
+    if(o == null) return false;
     Document doc = (Document)o;
 
     // make it accept only docs from its own datastore
@@ -730,9 +726,10 @@
     return true;
   }
 
-  public boolean addAll(Collection c) {
+  @Override
+  public boolean addAll(Collection<? extends Document> c) {
     boolean allAdded = true;
-    Iterator iter = c.iterator();
+    Iterator<? extends Document> iter = c.iterator();
     while(iter.hasNext()) {
       if(!add(iter.next())) allAdded = false;
     }
@@ -780,10 +777,10 @@
     return docDataList.hashCode();
   }
 
-  public Object get(int index) {
+  public Document get(int index) {
     if(index >= docDataList.size()) return null;
 
-    Object res = documents.get(index);
+    Document res = documents.get(index);
 
     if(DEBUG)
       Out.prln("SerialCorpusImpl: get(): index " + index + "result: " + res);
@@ -795,7 +792,7 @@
       try {
         parameters.put(DataStore.LR_ID_FEATURE_NAME, ((DocumentData)docDataList
                 .get(index)).getPersistentID());
-        Resource lr = Factory.createResource(((DocumentData)docDataList
+        Document lr = (Document) 
Factory.createResource(((DocumentData)docDataList
                 .get(index)).getClassType(), parameters);
         if(DEBUG) Out.prln("Loaded document :" + lr.getName());
         // change the result to the newly loaded doc
@@ -813,7 +810,7 @@
     return res;
   }
 
-  public Object set(int index, Object element) {
+  public Document set(int index, Document element) {
     throw new gate.util.MethodNotImplementedException();
     // fire the 2 events
     /*
@@ -825,7 +822,7 @@
      */
   }
 
-  public void add(int index, Object o) {
+  public void add(int index, Document o) {
     if(!(o instanceof Document) || o == null) return;
     Document doc = (Document)o;
 
@@ -840,7 +837,7 @@
 
   }
 
-  public Object remove(int index) {
+  public Document remove(int index) {
     if(DEBUG) Out.prln("Remove index called");
     // try to get the actual document if it was loaded
     Document res = isDocumentLoaded(index) ? (Document)get(index) : null;

Modified: gate/trunk/src/gate/gui/CorpusEditor.java
===================================================================
--- gate/trunk/src/gate/gui/CorpusEditor.java   2012-01-06 15:42:56 UTC (rev 
14910)
+++ gate/trunk/src/gate/gui/CorpusEditor.java   2012-01-06 16:04:33 UTC (rev 
14911)
@@ -609,7 +609,7 @@
       if(optionPane.getValue().equals(JOptionPane.OK_OPTION)){
         int[] selectedIndices = docList.getSelectedIndices();
         for (int selectedIndice : selectedIndices) {
-          corpus.add(loadedDocuments.get(selectedIndice));
+          corpus.add((Document)loadedDocuments.get(selectedIndice));
         }
       }
       changeMessage();

Modified: gate/trunk/src/gate/gui/NameBearerHandle.java
===================================================================
--- gate/trunk/src/gate/gui/NameBearerHandle.java       2012-01-06 15:42:56 UTC 
(rev 14910)
+++ gate/trunk/src/gate/gui/NameBearerHandle.java       2012-01-06 16:04:33 UTC 
(rev 14911)
@@ -1998,7 +1998,7 @@
     public void actionPerformed(ActionEvent e) {
       try {
         Corpus corpus = Factory.newCorpus("Corpus for " + target.getName());
-        corpus.add(target);
+        corpus.add((Document)target);
       }
       catch(ResourceInstantiationException rie) {
         Err.println("Exception creating corpus");

Modified: gate/trunk/src/gate/util/CorpusSaver.java
===================================================================
--- gate/trunk/src/gate/util/CorpusSaver.java   2012-01-06 15:42:56 UTC (rev 
14910)
+++ gate/trunk/src/gate/util/CorpusSaver.java   2012-01-06 16:04:33 UTC (rev 
14911)
@@ -233,7 +233,7 @@
 
         //then store it in the DS and add to corpus
         if (saveMode) {
-          LanguageResource lr = ds.adopt(doc, null);
+          Document lr = (Document)ds.adopt(doc, null);
           theCorpus.add(lr);
           theCorpus.unloadDocument( (Document) lr);
 

Modified: gate/trunk/src/gate/util/persistence/CorpusPersistence.java
===================================================================
--- gate/trunk/src/gate/util/persistence/CorpusPersistence.java 2012-01-06 
15:42:56 UTC (rev 14910)
+++ gate/trunk/src/gate/util/persistence/CorpusPersistence.java 2012-01-06 
16:04:33 UTC (rev 14911)
@@ -20,6 +20,7 @@
 import java.util.Iterator;
 
 import gate.Corpus;
+import gate.Document;
 import gate.creole.ResourceInstantiationException;
 import gate.persist.PersistenceException;
 
@@ -69,7 +70,7 @@
       if(!docList.isEmpty() && corpus.isEmpty()){
         Iterator docIter = docList.iterator();
         while(docIter.hasNext()){
-          corpus.add(PersistenceManager.
+          corpus.add((Document) PersistenceManager.
                      getTransientRepresentation(docIter.next()));
         }
 

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


------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to