Revision: 16775
          http://sourceforge.net/p/gate/code/16775
Author:   markagreenwood
Date:     2013-08-09 10:30:09 +0000 (Fri, 09 Aug 2013)
Log Message:
-----------
added an ANT build file as well as a compiled copy and a README detailing how 
to rebuild the jar should you need to

Added Paths:
-----------
    gate/trunk/plugins/Format_FastInfoset/gcp/README
    gate/trunk/plugins/Format_FastInfoset/gcp/build.xml
    gate/trunk/plugins/Format_FastInfoset/gcp/fastinfoset4gcp.jar
    gate/trunk/plugins/Format_FastInfoset/gcp/src/gate/
    gate/trunk/plugins/Format_FastInfoset/gcp/src/gate/cloud/
    gate/trunk/plugins/Format_FastInfoset/gcp/src/gate/cloud/io/
    gate/trunk/plugins/Format_FastInfoset/gcp/src/gate/cloud/io/file/
    
gate/trunk/plugins/Format_FastInfoset/gcp/src/gate/cloud/io/file/FastInfosetOutputHandler.java

Property Changed:
----------------
    gate/trunk/plugins/Format_FastInfoset/gcp/

Index: gate/trunk/plugins/Format_FastInfoset/gcp
===================================================================
--- gate/trunk/plugins/Format_FastInfoset/gcp   2013-08-09 09:31:18 UTC (rev 
16774)
+++ gate/trunk/plugins/Format_FastInfoset/gcp   2013-08-09 10:30:09 UTC (rev 
16775)

Property changes on: gate/trunk/plugins/Format_FastInfoset/gcp
___________________________________________________________________
Added: svn:ignore
## -0,0 +1 ##
+classes
Added: gate/trunk/plugins/Format_FastInfoset/gcp/README
===================================================================
--- gate/trunk/plugins/Format_FastInfoset/gcp/README                            
(rev 0)
+++ gate/trunk/plugins/Format_FastInfoset/gcp/README    2013-08-09 10:30:09 UTC 
(rev 16775)
@@ -0,0 +1,7 @@
+The code in this folder adds support for saving GCP output as FastInfoset XML
+files. It was compiled against version 2.4-SNAPSHOT of GCP.
+
+To recompile this code you need to specify the location of a GCP distribution
+(not an SVN checkout). For example
+
+ant -Dgcp.home=/home/mark/gcp-2.4-SNAPSHOT/

Added: gate/trunk/plugins/Format_FastInfoset/gcp/build.xml
===================================================================
--- gate/trunk/plugins/Format_FastInfoset/gcp/build.xml                         
(rev 0)
+++ gate/trunk/plugins/Format_FastInfoset/gcp/build.xml 2013-08-09 10:30:09 UTC 
(rev 16775)
@@ -0,0 +1,58 @@
+<project name="FastInfoset4GCP" basedir="." default="jar">
+  <!-- Prevent Ant from warning about includeantruntime not being set -->
+  <property name="build.sysclasspath" value="ignore" />
+  
+       <property file="build.properties" />
+
+       <fail unless="gcp.home">"gcp.home" property must be set before 
FastInfoset support for GCP can be compiled</fail>
+
+       <property name="gcp.lib" location="${gcp.home}/lib" />
+       <property name="src.dir" location="src" />
+       <property name="classes.dir" location="classes" />
+       <property name="jar.location" location="fastinfoset4gcp.jar" />
+       <property name="lib" location="../lib" />
+
+       <!-- Path to compile - includes gcp/lib/*.jar -->
+       <path id="compile.classpath">
+               <fileset dir="${lib}">
+                       <include name="**/*.jar" />
+               </fileset>
+               <fileset dir="${gcp.lib}">
+                       <include name="**/*.jar" />
+                       <include name="**/*.zip" />
+               </fileset>
+       </path>
+
+       <!-- create build directory structure -->
+       <target name="prepare">
+               <mkdir dir="${classes.dir}" />
+       </target>
+
+       <target name="resources" depends="prepare">
+               <!-- <copy todir="${classes.dir}/gate/resources" 
includeEmptyDirs="true">
+                       <fileset dir="${src.dir}/gate/resources" />
+               </copy> -->
+       </target>
+
+       <!-- compile the source -->
+       <target name="compile" depends="prepare, resources">
+               <javac classpathref="compile.classpath" srcdir="${src.dir}" 
destdir="${classes.dir}" debug="true" debuglevel="lines,source" source="1.5" 
target="1.5">
+               </javac>
+       </target>
+
+       <!-- create the JAR file -->
+       <target name="jar" depends="compile">
+               <jar destfile="${jar.location}" update="false" 
basedir="${classes.dir}" />
+       </target>
+
+       <!-- remove the generated .class files -->
+       <target name="clean.classes">
+               <delete dir="${classes.dir}" />
+       </target>
+
+       <!-- Clean up - remove .class and .jar files -->
+       <target name="clean" depends="clean.classes">
+               <delete file="${jar.location}" />
+       </target>
+
+</project>

Added: gate/trunk/plugins/Format_FastInfoset/gcp/fastinfoset4gcp.jar
===================================================================
(Binary files differ)

Index: gate/trunk/plugins/Format_FastInfoset/gcp/fastinfoset4gcp.jar
===================================================================
--- gate/trunk/plugins/Format_FastInfoset/gcp/fastinfoset4gcp.jar       
2013-08-09 09:31:18 UTC (rev 16774)
+++ gate/trunk/plugins/Format_FastInfoset/gcp/fastinfoset4gcp.jar       
2013-08-09 10:30:09 UTC (rev 16775)

Property changes on: 
gate/trunk/plugins/Format_FastInfoset/gcp/fastinfoset4gcp.jar
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: 
gate/trunk/plugins/Format_FastInfoset/gcp/src/gate/cloud/io/file/FastInfosetOutputHandler.java
===================================================================
--- 
gate/trunk/plugins/Format_FastInfoset/gcp/src/gate/cloud/io/file/FastInfosetOutputHandler.java
                              (rev 0)
+++ 
gate/trunk/plugins/Format_FastInfoset/gcp/src/gate/cloud/io/file/FastInfosetOutputHandler.java
      2013-08-09 10:30:09 UTC (rev 16775)
@@ -0,0 +1,86 @@
+/*
+ * FastInfosetOutputHandler.java
+ * 
+ * Copyright (c) 2007-2013, The University of Sheffield. See the file
+ * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
+ * 
+ * This file is part of GATE (see http://gate.ac.uk/), and is free software,
+ * licenced under the GNU Library General Public License, Version 2, June 1991
+ * (in the distribution as file licence.html, and also available at
+ * http://gate.ac.uk/gate/licence.html).
+ * 
+ * Mark A. Greenwood, 09/08/2013
+ */
+
+package gate.cloud.io.file;
+
+import static gate.cloud.io.IOConstants.PARAM_FILE_EXTENSION;
+import gate.Annotation;
+import gate.Document;
+import gate.cloud.batch.DocumentID;
+import gate.cloud.io.OutputHandler;
+import gate.corpora.DocumentStaxUtils;
+import gate.util.Benchmark;
+import gate.util.GateException;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.xml.stream.XMLStreamException;
+
+import com.sun.xml.fastinfoset.stax.StAXDocumentSerializer;
+
+/**
+ * An {@link OutputHandler} that writes to files, in GATE Stand-off format 
using
+ * the FastInfoset XML encoding.
+ */
+public class FastInfosetOutputHandler extends AbstractFileOutputHandler {
+
+  @Override
+  protected void configImpl(Map<String, String> configData) throws IOException,
+    GateException {
+    // make sure we default to .finf as the extension
+    if(!configData.containsKey(PARAM_FILE_EXTENSION)) {
+      configData.put(PARAM_FILE_EXTENSION, ".finf");
+    }
+    super.configImpl(configData);
+  }
+
+  @Override
+  protected void outputDocumentImpl(Document document, DocumentID documentId)
+    throws IOException, GateException {
+    
+    //get the relevant annotations we want to save
+    Map<String, Collection<Annotation>> annotationSetsMap =
+      collectAnnotations(document);
+
+    // 
+    OutputStream outputStream = getFileOutputStream(documentId);
+    try {
+
+      // start the document and write the XML decl
+      StAXDocumentSerializer xsw = new StAXDocumentSerializer(outputStream);
+      xsw.writeStartDocument("1.0");
+
+      // write the document (wrapped in some benchmarking stuff)
+      String saveStandoffBID =
+        Benchmark.createBenchmarkId("saveFastInfoset", document.getName());
+      long startTime = Benchmark.startPoint();
+      DocumentStaxUtils.writeDocument(document, annotationSetsMap, xsw, "");
+      xsw.writeEndDocument();
+      Benchmark.checkPoint(startTime, saveStandoffBID, this, null);
+
+      // flush and close the XSW just to be on the safe side
+      xsw.flush();
+      xsw.close();
+    } catch(XMLStreamException e) {
+      throw (IOException)new IOException("Error writing FastInfoset XML")
+        .initCause(e);
+    } finally {
+      // closing the XSW doesn't close the stream (by design)
+      outputStream.close();
+    }
+  }
+}
\ No newline at end of file

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


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to