javanetbeanscygwingate

NetBeans does not find build.properties on GATE


I am using GATE for extracting text from French documents. I already had a problem with TreeTagger and Cygwin on Windows in GATE GUI, which I solved by putting the line shown below in system environment instead of C:\Cygwin\bin\sh.exe;C:\cygwin\bin C:/cygwin2/bin/sh.exe;C:/cygwin2/bin and created build.properties file in root of GATE and put below line on it

run.shell.path: C\:\\cygwin2\\bin\\sh.exe

Right now, I have my favorite pipeline and it works properly on French text through GATE GUI. I saved my pipeline by "Save Application state" and right know I want to load it through NetBeans and execute it.

But when Netbeans initialized GATE and load my saved pipeline and add my corpus and document, it can not find the cygwin path for POS. I got error=193, and as I guess it means it can not find build.properties file path for addressing sh.exe file for tagging by TreeTagger.

this is my code:

public static void main(String[] args) throws Exception {

   CorpusController FrenchController;

   Gate.init();
   MainFrame.getInstance().setVisible(true);

   File GateHome = Gate.getGateHome();
   File FrenchGapp = new File(GateHome,"appTest.xgapp");
   FrenchController =   (CorpusController)PersistenceManager.loadObjectFromFile(FrenchGapp);

   Corpus corpus = Factory.newCorpus("TestCorpus");
   FrenchController.setCorpus(corpus);

   File docFile = new File("D:\\Amin\\Project\\DropBox\\Donnees\\7_doc.xml"); 
   Document doc = Factory.newDocument(docFile.toURL(), "utf-8");   //encoding

   corpus.add(doc);

   FrenchController.execute();

   corpus.clear();
} 

------------------------ Error on GATE after execution------------------------

C:\GATE\plugins\Tagger_Framework\resources\TreeTagger\tree-tagger-french-gate-utf8 C:\Users\Amin\AppData\Local\Temp\tagger6897917088215914126.txt
Exception in thread "main" gate.creole.ExecutionException: java.io.IOException: Cannot run program "C:\GATE\plugins\Tagger_Framework\resources\TreeTagger\tree-tagger-french-gate-utf8": CreateProcess **error=193**, %1 is not a valid Win32 application
    at gate.taggerframework.GenericTagger.runTagger(GenericTagger.java:489)
    at gate.taggerframework.GenericTagger.execute(GenericTagger.java:245)
    at gate.util.Benchmark.executeWithBenchmarking(Benchmark.java:291)
    at gate.creole.SerialController.runComponent(SerialController.java:221)
    at gate.creole.SerialController.executeImpl(SerialController.java:153)
    at gate.creole.SerialAnalyserController.executeImpl(SerialAnalyserController.java:125)
    at gate.creole.AbstractController.execute(AbstractController.java:75)
    at secondshot.SecondShot.main(SecondShot.java:84)
Caused by: java.io.IOException: Cannot run program "C:\GATE\plugins\Tagger_Framework\resources\TreeTagger\tree-tagger-french-gate-utf8": CreateProcess error=193, %1 is not a valid Win32 application
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1041)
    at java.lang.Runtime.exec(Runtime.java:617)
    at gate.util.ProcessManager.runProcess(ProcessManager.java:84)
    at gate.util.ProcessManager.runProcess(ProcessManager.java:66)
    at gate.taggerframework.GenericTagger.runTagger(GenericTagger.java:478)
    ... 7 more
Caused by: java.io.IOException: CreateProcess error=193, %1 is not a valid Win32 application
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:385)
    at java.lang.ProcessImpl.start(ProcessImpl.java:136)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1022)
    ... 11 more

Thanks for your time


Solution

  • I think, that the build.properties file is read only when running GATE Developer. See the documentation http://gate.ac.uk/userguide/sec:gettingstarted:sysprop

    ... When using GATE Embedded, you can set the values for these properties before you call Gate.init() ...

    In your application, you can check if the property shell.path is set correctly before invoking FrenchController.execute(). Just call System.getProperty("shell.path") and see...

    If it is not, you can set the property using

    System.setProperty("shell.path", "C:\\cygwin2\\bin\\sh.exe")
    

    somewhere in your code, before invoking FrenchController.execute().

    Or in NetBeans, you can set it as described in this answer: https://stackoverflow.com/a/7839141/1857897