/** * Loads the specified JAPE grammar into GATE and then serializes it * into the specified file. This file can then be used to create * a new transducer instance via the <code>binaryGrammarURL</code> * init time parameter. */ public static void compile(URL jape, File ser) throws Exception { Transducer transducer = new Transducer(); transducer.setGrammarURL(new ResourceReference(jape)); transducer.setEncoding(defaultEncoding); transducer.init(); FileOutputStream out = new FileOutputStream(ser); ObjectOutputStream s = new ObjectOutputStream(out); transducer.serialize(s); s.flush(); s.close(); out.close(); }