@Test public void test() { try { BBCMusicCorpus corpus = new BBCMusicCorpus( new File( "../corpora/bbc_music/bbc_music_labels.zip"), new TextCorpus( new File( "../corpora/bbc_music/bbc_music_text.zip"), MediaType.ZIP, MediaType.HTML, Language.EN)); @SuppressWarnings({ "unchecked" }) List<URI> list = (List<URI>) corpus .forEach(new DocumentProcedure<URI>() { @Override public URI process(Reader doc, URI uri) throws Exception { return uri; } }); for (URI e : list) { BufferedReader reader = new BufferedReader( corpus.getGroundTruth(e)); for (String line = reader.readLine(); line != null; line = reader .readLine()) { } reader.close(); } } catch (Exception e) { e.printStackTrace(); } }
public Reader getGroundTruth(final URI uri) throws Exception { if (labelFileMediaType == MediaType.DIRECTORY) { return new StringReader(FileUtils.readFileToString(new File(uri))); } else if (labelFileMediaType == MediaType.ZIP) { ZipFile zipFile = new ZipFile(labelFolder); String[] entryName = uri.toURL().getFile().split("/"); ZipEntry entry = zipFile.getEntry(URLDecoder.decode( entryName[entryName.length - 1], "utf-8").replace("txt", "dumps") + ".rdf"); if (entry != null) { log.info("found labels for: " + uri.toString()); } else { throw new Exception("did not found labels for: " + uri.toString()); } return new InputStreamReader(zipFile.getInputStream(entry)); } else { throw new Exception("Unsupported media format for labels: " + labelFileMediaType + ". " + "Please use zip or plain directories instead."); } }
BBCMusicCorpus extends LabeledTextCorpus { public Reader getGroundTruth(final URI uri) throws Exception { if (labelFileMediaType == MediaType.DIRECTORY) { return new StringReader(FileUtils.readFileToString(new File(uri))); } else if (labelFileMediaType == MediaType.ZIP) { ZipFile zipFile = new ZipFile(labelFolder); String[] entryName = uri.toURL().getFile().split("/"); ZipEntry entry = zipFile.getEntry(URLDecoder.decode( entryName[entryName.length - 1], "utf-8").replace("txt", "dumps") + ".rdf"); if (entry != null) { log.info("found labels for: " + uri.toString()); } else { throw new Exception("did not found labels for: " + uri.toString()); } return new InputStreamReader(zipFile.getInputStream(entry)); } else { throw new Exception("Unsupported media format for labels: " + labelFileMediaType + ". " + "Please use zip or plain directories instead."); } } }
BBCMusicCorpus extends LabeledTextCorpus { public Reader getGroundTruth(final URI uri) throws Exception { if (labelFileMediaType == MediaType.DIRECTORY) { return new StringReader(FileUtils.readFileToString(new File(uri))); } else if (labelFileMediaType == MediaType.ZIP) { ZipFile zipFile = new ZipFile(labelFolder); String[] entryName = uri.toURL().getFile().split("/"); ZipEntry entry = zipFile.getEntry(URLDecoder.decode( entryName[entryName.length - 1], "utf-8").replace("txt", "dumps") + ".rdf"); if (entry != null) { log.info("found labels for: " + uri.toString()); } else { throw new Exception("did not found labels for: " + uri.toString()); } return new InputStreamReader(zipFile.getInputStream(entry)); } else { throw new Exception("Unsupported media format for labels: " + labelFileMediaType + ". " + "Please use zip or plain directories instead."); } } BBCMusicCorpus(File labelFolder, TextCorpus corpus);  BBCMusicCorpus(); }
BBCMusicCorpus extends LabeledTextCorpus { public Reader getGroundTruth(final URI uri) throws Exception { if (labelFileMediaType == MediaType.DIRECTORY) { return new StringReader(FileUtils.readFileToString(new File(uri))); } else if (labelFileMediaType == MediaType.ZIP) { ZipFile zipFile = new ZipFile(labelFolder); String[] entryName = uri.toURL().getFile().split("/"); ZipEntry entry = zipFile.getEntry(URLDecoder.decode( entryName[entryName.length - 1], "utf-8").replace("txt", "dumps") + ".rdf"); if (entry != null) { log.info("found labels for: " + uri.toString()); } else { throw new Exception("did not found labels for: " + uri.toString()); } return new InputStreamReader(zipFile.getInputStream(entry)); } else { throw new Exception("Unsupported media format for labels: " + labelFileMediaType + ". " + "Please use zip or plain directories instead."); } } BBCMusicCorpus(File labelFolder, TextCorpus corpus);  BBCMusicCorpus(); Reader getGroundTruth(final URI uri); }
BBCMusicCorpus extends LabeledTextCorpus { public Reader getGroundTruth(final URI uri) throws Exception { if (labelFileMediaType == MediaType.DIRECTORY) { return new StringReader(FileUtils.readFileToString(new File(uri))); } else if (labelFileMediaType == MediaType.ZIP) { ZipFile zipFile = new ZipFile(labelFolder); String[] entryName = uri.toURL().getFile().split("/"); ZipEntry entry = zipFile.getEntry(URLDecoder.decode( entryName[entryName.length - 1], "utf-8").replace("txt", "dumps") + ".rdf"); if (entry != null) { log.info("found labels for: " + uri.toString()); } else { throw new Exception("did not found labels for: " + uri.toString()); } return new InputStreamReader(zipFile.getInputStream(entry)); } else { throw new Exception("Unsupported media format for labels: " + labelFileMediaType + ". " + "Please use zip or plain directories instead."); } } BBCMusicCorpus(File labelFolder, TextCorpus corpus);  BBCMusicCorpus(); Reader getGroundTruth(final URI uri);  }