Getting started

Running Pikey from the command line

Download pikey-1.6-standalone.jar and start as follows from the command line:

wb@desktop:/home/wb$ java -jar pikey-1.6-standalone.jar -h
usage: pikey [OPTION...] FILE|DIR...
 -c,--config <arg>   Use the given pipeline configuration
    --gui            Launch the grafical user interface
 -h,--help           Print help and exit
 -l,--lib <arg>      Add the given URL to the classpath
    --print-xml      Print the document in Gate XML form

The output should look like above. In order to do something useful, you need a Gate application. Pikey is capable of loading GAPP files as well as "Pikey" files. Right now we're going to run ANNIE from a Pikey file. Download and extract the contents of pikey-annie.zip. You'll have a folder with a file named annie.kapp and a bunch of ANNIE resources. Start Pikey with the annie.kapp file:

wb@desktop:/home/wb$ java -jar pikey-1.6-standalone.jar -c annie/annie.kapp --gui

The --gui option makes it start the usual Gate user interface. It will also load the processing resources listed in annie.kap. You can now start adding and processing documents. Alternatively, load the documents right away from the command line:

wb@desktop:/home/wb$ java -jar pikey-1.6-standalone.jar -c annie/annie.kapp --gui /path/to/document.pdf

Embedding Pikey

public class Main {
  public static void main(String[] args) throws Exception {
    String gate_app = args[0];
    String document_filename = args[1];

    // initialize Gate
    GateUtils.setupGateSandbox();

    // load gate application configuration
    PipelineFactory pcfg = new PipelineParser().parse(new File(gate_app));

    // initialize gate application
    LanguageAnalyser pipe = pcfg.openPipeline();

    try {
      // open the document
      gate.Document doc = Factory.newDocument(new File(document_filename).toURI().toURL());

      try {
        // process the document, and write results as XML to System.out
        GateUtils.processDocument(pipe, doc);
        System.out.println(doc.toXml());
      } finally {
        // tell Gate that we are finished with the document
        Factory.deleteResource(doc);
      }
    } finally {
      // tell Gate that we are finished with the application
      Factory.deleteResource(pipe);
    }
  }
}

Maven

<project>

  ...

  <dependencies>

    ...

    <dependency>
      <groupId>net.sf.pikey</groupId>
      <artifactId>pikey-config</artifactId>
      <version>1.6</version>
    </dependency>

  </dependencies>

  <repositories>
    <repository>
      <id>pikey.sourceforge.net</id>
      <url>http://downloads.sourceforge.net/project/pikey/m2repo</url>
    </repository>
  </repositories>
</project>