我在我的程序Java中从GUI Developer Gate调用我的应用程序,然后我将我的文档注释为格式XML.But现在我无法在XML文件中提取我的数据。你能帮帮我吗?
Corpus corpus = Factory.newCorpus("Processing CV");
CorpusController application =
(CorpusController)PersistenceManager.loadObjectFromUrl(new URL("file:////home/NafisehApp.xgapp"));
application.setCorpus(corpus);
File[] files = getFilesFromDir("/home/GAte/TestCV.pdf");
for (int i = 0; i < files.length; i++) {
if (!files[i].getName().endsWith(".pdf"))
continue;
File docFile = files[i];
gate.Document doc =Factory.newDocument(docFile.toURI().toURL());
corpus.add(doc);
application.execute();
AnnotationSet defaultAnnotSet = doc.getAnnotations();
Set<String> annotTypesRequired = new HashSet<String>();
annotTypesRequired.add("Person");
annotTypesRequired.add("Address");
annotTypesRequired.add("Title");
File outputFile = new File("/home/GAte/file.xml");
DocumentStaxUtils.writeDocument(doc, outputFile);
FileUtils.write(outputFile,doc.toXml(doc.getAnnotations().get(annotTypesRequired), true));