/** * Annotates a file with whatizit * * @param outRDF File to be annotated * @param outputDir Output dor for the annotated RDF (output located at /AO_annotations subfolder) * @param pmc Article (file) id * @param pipeline Whatizit pipeline * @throws Exception */ public void annotateFileWithWhatizit(File outRDF, String outputDir, String pipeline) throws Exception { logger.info("===Whatizit " + outRDF.getName() + "==="); // 3. Annotate with whatizit String rdfFileName = outRDF.getAbsolutePath(); String pmc; if (outRDF.getName().startsWith(this.pmcPrefix)) { pmc = outRDF.getName().substring(this.pmcPrefix.length(), outRDF.getName().length() - 4); } else { pmc = outRDF.getName().substring(0, outRDF.getName().length() - 4); } if (pmc.endsWith(this.pmcSuffix)) { pmc = pmc.substring(0, pmc.length() - this.pmcSuffix.length()); } String outRDFFileName = outputDir + "/AO_annotations/PMC" + pmc + "_" + pipeline + ".rdf"; List<Annotation> lsAnnotations = new ArrayList<Annotation>(); this.handler.setPaperURLId(GlobalPmc.getPmcRdfUri(pmc)); this.handler.setDocumentPaperId(pmc); File outRDF_AO = new File(outRDFFileName); if (!outRDF_AO.exists()) { outRDF_AO = this.handler.annotateWithWhatizit( pipeline, rdfFileName, outRDFFileName, lsAnnotations, TEXT_PROPERTY, GlobalPmc.RDF4PMC_AGENT); } }
/** * RDFizes a file * * @param subdir File to rdfize * @param outputDir Output dir for generated RDF * @param sections Should sections be processed? * @throws JAXBException * @throws FileNotFoundException * @throws UnsupportedEncodingException * @throws ParserConfigurationException * @throws SAXException * @throws PMCIdException * @throws ArticleTypeException * @throws DTDException */ public File rdfizeFile(File subdir, String outputDir, boolean sections) throws JAXBException, FileNotFoundException, UnsupportedEncodingException, SAXException, ParserConfigurationException, DTDException, ArticleTypeException, PMCIdException { logger.info("===RDFize " + subdir.getName() + "==="); File outRDF = null; // 1. Create RDF used as a mechanism for improving information retrieval over tagged resources // as well as to facilitate the discovery of shared conceptualizations[2,3]. this.handler.setStrPmcId(new StringBuilder()); this.handler.setPaper2rdf(new PmcOpenAccess2RDF(subdir, this.handler.getStrPmcId())); String pmc = this.handler.getStrPmcId().toString(); this.handler.setPaperURLId(GlobalPmc.getPmcRdfUri(pmc)); this.handler.setDocumentPaperId(pmc); outRDF = new File(outputDir + "/PMC" + pmc + ".rdf"); if (!outRDF.exists()) { outRDF = this.handler.createRDFFromXML(subdir, outputDir, sections); } return outRDF; }