Revision: 14782
          http://gate.svn.sourceforge.net/gate/?rev=14782&view=rev
Author:   nirajaswani
Date:     2011-12-16 10:38:06 +0000 (Fri, 16 Dec 2011)
Log Message:
-----------
resetting references on the analyser being used internall for processing by the 
segment PR

Modified Paths:
--------------
    
gate/trunk/plugins/Alignment/src/gate/composite/impl/SegmentProcessingPR.java

Modified: 
gate/trunk/plugins/Alignment/src/gate/composite/impl/SegmentProcessingPR.java
===================================================================
--- 
gate/trunk/plugins/Alignment/src/gate/composite/impl/SegmentProcessingPR.java   
    2011-12-16 09:05:37 UTC (rev 14781)
+++ 
gate/trunk/plugins/Alignment/src/gate/composite/impl/SegmentProcessingPR.java   
    2011-12-16 10:38:06 UTC (rev 14782)
@@ -4,6 +4,7 @@
 import gate.AnnotationSet;
 import gate.Corpus;
 import gate.CorpusController;
+import gate.Document;
 import gate.Factory;
 import gate.FeatureMap;
 import gate.Gate;
@@ -135,6 +136,9 @@
       compoundDoc.addDocument(document.getName(), document);
     }
     Corpus tempCorpus = null;
+    Corpus oldCorpus = analyser.getCorpus();
+    Document oldDoc = analyser.getDocument();
+
     try {
       Map<String, Object> map = new HashMap<String, Object>();
       map.put(CombineFromAnnotID.INPUT_AS_NAME_FEATURE_NAME, inputASName);
@@ -181,7 +185,6 @@
           compoundDoc.setCurrentDocument(nameForCompositeDoc);
           // now run the application on the composite document
           analyser.execute();
-          compoundDoc.removeDocument(nameForCompositeDoc);
         } catch(CombiningMethodException e) {
           throw new ExecutionException(e);
         } finally {
@@ -195,8 +198,14 @@
     } catch(ResourceInstantiationException e) {
       throw new ExecutionException(e);
     } finally {
+      // make sure you are resetting the reference
+      analyser.setCorpus(oldCorpus);
+      analyser.setDocument(oldDoc);
+
       compoundDoc.removeDocument(originalDocument);
       if(tempCorpus != null) {
+        // clear the corpus before deleting it
+        tempCorpus.clear();
         gate.Factory.deleteResource(tempCorpus);
       }
     }
@@ -294,4 +303,12 @@
       String segmentAnnotationFeatureValue) {
     this.segmentAnnotationFeatureValue = segmentAnnotationFeatureValue;
   }
+
+  /**
+   * must clean up the original compound document.
+   */
+  public void cleanup() {
+    super.cleanup();
+    Factory.deleteResource(compoundDoc);
+  }
 } // class SegmentProcessingPR

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


------------------------------------------------------------------------------
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to