Webで「GATE」を使いたい。次に、GATE Embedded を使用して Java で SOAP Web サービスを作成することにしました。
しかし、同じドキュメントと保存されたパイプラインに対して、GATE Embedded が Java Web サービスとして実行される場合、実行時間は異なります。同じコードを Java アプリケーション プロジェクトとして実行すると、実行時間が一定になります。
Web サービスでは、タイムアウト エラーが発生するまで、実行ごとにランタイムが増加します。
誰もがこの種の経験を持っていますか?
これは私のコードです:
@WebService(serviceName = "GateWS")
public class GateWS {
@WebMethod(operationName = "gateengineapi")
public String gateengineapi(@WebParam(name = "PipelineNumber") String PipelineNumber, @WebParam(name = "Documents") String Docs) throws Exception {
try {
System.setProperty("gate.home", "C:\\GATE\\");
System.setProperty("shell.path", "C:\\cygwin2\\bin\\sh.exe");
Gate.init();
File GateHome = Gate.getGateHome();
File FrenchGapp = new File(GateHome, PipelineNumber);
CorpusController FrenchController;
FrenchController = (CorpusController) PersistenceManager.loadObjectFromFile(FrenchGapp);
Corpus corpus = Factory.newCorpus("BatchProcessApp Corpus");
FrenchController.setCorpus(corpus);
File docFile = new File(GateHome, Docs);
Document doc = Factory.newDocument(docFile.toURL(), "utf-8");
corpus.add(doc);
FrenchController.execute();
String docXMLString = null;
docXMLString = doc.toXml();
String outputFileName = doc.getName() + ".out.xml";
File outputFile = new File(docFile.getParentFile(), outputFileName);
FileOutputStream fos = new FileOutputStream(outputFile);
BufferedOutputStream bos = new BufferedOutputStream(fos);
OutputStreamWriter out;
out = new OutputStreamWriter(bos, "utf-8");
out.write(docXMLString);
out.close();
gate.Factory.deleteResource(doc);
return outputFileName;
} catch (Exception ex) {
return "ERROR: -> " + ex.getMessage();
}
}
}
あなたが提供できる助けに本当に感謝します。