Tabnine Logo
BaleenCollectionReader.close
Code IndexAdd Tabnine to your IDE (free)

How to use
close
method
in
uk.gov.dstl.baleen.uima.BaleenCollectionReader

Best Java code snippets using uk.gov.dstl.baleen.uima.BaleenCollectionReader.close (Showing top 20 results out of 315)

origin: uk.gov.dstl.baleen/baleen-uima

@Override
public void destroy() {
 super.destroy();
 try {
  close();
 } catch (IOException e) {
  getMonitor().warn("Close on destroy", e);
 }
}
origin: dstl/baleen

@Override
public void destroy() {
 super.destroy();
 try {
  close();
 } catch (IOException e) {
  getMonitor().warn("Close on destroy", e);
 }
}
origin: dstl/baleen

 public void close() throws IOException {
  sender.destroy();
  reader.close();
 }
}
origin: dstl/baleen

@Test
public void testSubDirectories() throws Exception {
 File subdir = new File(inputDir, "subdir");
 subdir.mkdir();
 File f1 = new File(subdir, TEXT1_FILE);
 f1.createNewFile();
 BaleenCollectionReader bcr =
   getCollectionReader(FolderReader.PARAM_FOLDERS, new String[] {inputDir.getPath()});
 assertNextSourceNotNull(bcr);
 File f2 = new File(subdir, TEST2_FILE);
 f2.createNewFile();
 Thread.sleep(TIMEOUT);
 assertNextSourceNotNull(bcr);
 bcr.close();
 f1.delete();
 f2.delete();
 subdir.delete();
}
origin: dstl/baleen

@Test
public void testExistingFiles() throws Exception {
 File f1 = new File(inputDir, TEXT1_FILE);
 f1.createNewFile();
 File f2 = new File(inputDir, TEST2_FILE);
 f2.createNewFile();
 BaleenCollectionReader bcr =
   getCollectionReader(FolderReader.PARAM_FOLDERS, new String[] {inputDir.getPath()});
 assertNextSourceNotNull(bcr);
 assertNextSourceNotNull(bcr);
 assertFalse(bcr.doHasNext());
 bcr.close();
}
origin: dstl/baleen

@Test
public void testDeleteFile() throws Exception {
 BaleenCollectionReader bcr =
   getCollectionReader(FolderReader.PARAM_FOLDERS, new String[] {inputDir.getPath()});
 assertFalse(bcr.doHasNext());
 File f = new File(inputDir, TEXT1_FILE);
 f.createNewFile();
 // Wait for file to be written and change detected
 Thread.sleep(TIMEOUT);
 f.delete();
 // Wait for file to be written and change detected
 Thread.sleep(TIMEOUT);
 assertFalse(bcr.doHasNext());
 bcr.close();
}
origin: dstl/baleen

@Test
public void testFilenameFilter2() throws Exception {
 File f1 = new File(inputDir, TEXT1_FILE);
 f1.createNewFile();
 File f2 = new File(inputDir, "test2.log");
 f2.createNewFile();
 File f3 = new File(inputDir, "test3.TXT");
 f3.createNewFile();
 BaleenCollectionReader bcr =
   getCollectionReader(
     FolderReader.PARAM_FOLDERS,
     new String[] {inputDir.getPath()},
     FolderReader.PARAM_ACCEPTED_PATTERNS,
     new String[] {".*[2-3].*"});
 assertNextSourceNotNull(bcr);
 assertNextSourceNotNull(bcr);
 assertFalse(bcr.doHasNext());
 bcr.close();
}
origin: dstl/baleen

@Test
public void testFilenameFilter1() throws Exception {
 File f1 = new File(inputDir, TEXT1_FILE);
 f1.createNewFile();
 File f2 = new File(inputDir, "test2.log");
 f2.createNewFile();
 File f3 = new File(inputDir, "test3.TXT");
 f3.createNewFile();
 BaleenCollectionReader bcr =
   getCollectionReader(
     FolderReader.PARAM_FOLDERS,
     new String[] {inputDir.getPath()},
     FolderReader.PARAM_ACCEPTED_PATTERNS,
     new String[] {".*\\.txt"});
 assertNextSourceNotNull(bcr);
 assertNextSourceNotNull(bcr);
 assertFalse(bcr.doHasNext());
 bcr.close();
}
origin: dstl/baleen

 @Test
 public void testDocumentText() throws Exception {
  BaleenCollectionReader bcr =
    getCollectionReader(MimeReader.PARAM_FOLDER, tmpDir.toAbsolutePath().toString());
  bcr.initialize();

  assertTrue(bcr.doHasNext());
  bcr.getNext(jCas.getCas());

  assertTrue(jCas.getDocumentText().startsWith("I'm going to eat you!"));

  bcr.close();
 }
}
origin: dstl/baleen

@Test
public void testDocumentText() throws Exception {
 BaleenCollectionReader bcr =
   getCollectionReader(
     Re3dReader.PARAM_FOLDER,
     tmpDir.toAbsolutePath().toString(),
     Re3dReader.PARAM_ENTITIES,
     true,
     Re3dReader.PARAM_RANDOM_DATES,
     true);
 assertTrue(bcr.doHasNext());
 bcr.getNext(jCas.getCas());
 assertTrue(jCas.getDocumentText().contains("This is the text of the article."));
 bcr.close();
}
origin: dstl/baleen

@Test
public void testCreateFileDefaultDirectory() throws Exception {
 BaleenCollectionReader bcr = getCollectionReader();
 assertTrue(
   bcr.doHasNext()); // There will be files in the current directory, so we can just check
 // that it's picked them up.
 bcr.getNext(jCas.getCas());
 assertTrue(getSource(jCas).contains(System.getProperty("user.dir")));
 bcr.close();
}
origin: dstl/baleen

@Test
public void testCreateFile() throws Exception {
 BaleenCollectionReader bcr =
   getCollectionReader(FolderReader.PARAM_FOLDERS, new String[] {inputDir.getPath()});
 assertFalse(bcr.doHasNext());
 File f = new File(inputDir, TEXT1_FILE);
 f.createNewFile();
 // Wait for file to be written and change detected
 Thread.sleep(TIMEOUT);
 assertTrue(bcr.doHasNext());
 bcr.getNext(jCas.getCas());
 assertFilesEquals(f.getPath(), getSource(jCas));
 assertFalse(bcr.doHasNext());
 bcr.close();
}
origin: dstl/baleen

@Test
public void testDocumentMetadata() throws Exception {
 BaleenCollectionReader bcr =
   getCollectionReader(
     Re3dReader.PARAM_FOLDER,
     tmpDir.toAbsolutePath().toString(),
     Re3dReader.PARAM_ENTITIES,
     true,
     Re3dReader.PARAM_RANDOM_DATES,
     true);
 assertTrue(bcr.doHasNext());
 bcr.getNext(jCas.getCas());
 AnnotationIndex<DocumentAnnotation> annotationIndex =
   jCas.getAnnotationIndex(DocumentAnnotation.class);
 assertTrue(contains(annotationIndex, d -> d.getSourceUri().equals(SOURCE_URL)));
 bcr.close();
}
origin: dstl/baleen

 @Test
 public void test() throws Exception {

  BaleenCollectionReader bcr = getCollectionReader();

  assertTrue(bcr.doHasNext());
  bcr.getNext(jCas.getCas());
  assertFalse(jCas.getDocumentText().isEmpty());
  assertFalse(bcr.doHasNext());

  bcr.close();
 }
}
origin: dstl/baleen

@Test
public void testMetadata() throws Exception {
 BaleenCollectionReader bcr =
   getCollectionReader(MimeReader.PARAM_FOLDER, tmpDir.toAbsolutePath().toString());
 bcr.initialize();
 assertTrue(bcr.doHasNext());
 bcr.getNext(jCas.getCas());
 AnnotationIndex<Metadata> annotationIndex = jCas.getAnnotationIndex(Metadata.class);
 // returns the X-From and not the From, these can differ
 assertEquals(X_FROM, get(annotationIndex, "email.X-From"));
 assertEquals(TO, get(annotationIndex, "email.X-To"));
 assertEquals(MESSAGE_ID, get(annotationIndex, "email.Message-ID"));
 bcr.close();
}
origin: dstl/baleen

@Test
public void testEntities() throws Exception {
 BaleenCollectionReader bcr =
   getCollectionReader(
     Re3dReader.PARAM_FOLDER,
     tmpDir.toAbsolutePath().toString(),
     Re3dReader.PARAM_ENTITIES,
     true,
     Re3dReader.PARAM_RANDOM_DATES,
     true);
 assertTrue(bcr.doHasNext());
 bcr.getNext(jCas.getCas());
 AnnotationIndex<Entity> annotationIndex = jCas.getAnnotationIndex(Entity.class);
 contains(annotationIndex, e -> e.getValue().equals("Location"));
 contains(annotationIndex, e -> e.getBegin() == 100);
 contains(annotationIndex, e -> e.getEnd() == 118);
 contains(annotationIndex, e -> e.getValue().equals("Organisation Ltd"));
 contains(annotationIndex, e -> e.getBegin() == 12);
 contains(annotationIndex, e -> e.getEnd() == 18);
 bcr.close();
}
origin: dstl/baleen

@Test
public void testPopNoMessages() throws Exception {
 BaleenCollectionReader bcr =
   getCollectionReader(
     EmailReader.PARAM_PROTOCOL,
     "pop3",
     EmailReader.PARAM_WAIT,
     5,
     EmailReader.PARAM_SERVER,
     greenMail.getPop3().getBindTo(),
     EmailReader.PARAM_PORT,
     greenMail.getPop3().getPort(),
     EmailReader.PARAM_USER,
     "to@localhost.com",
     EmailReader.PARAM_PASS,
     "password");
 bcr.initialize();
 assertFalse(bcr.doHasNext());
 bcr.close();
}
origin: dstl/baleen

@Test
public void testImapNoMessages() throws Exception {
 BaleenCollectionReader bcr =
   getCollectionReader(
     EmailReader.PARAM_PROTOCOL,
     "imap",
     EmailReader.PARAM_WAIT,
     5,
     EmailReader.PARAM_SERVER,
     greenMail.getImap().getBindTo(),
     EmailReader.PARAM_PORT,
     greenMail.getImap().getPort(),
     EmailReader.PARAM_USER,
     "to@localhost.com",
     EmailReader.PARAM_PASS,
     "password");
 bcr.initialize();
 assertFalse(bcr.doHasNext());
 bcr.close();
}
origin: dstl/baleen

 @Test
 public void test() throws IOException, UIMAException {
  BaleenCollectionReader bcr =
    getCollectionReader(ReutersReader.KEY_PATH, tmpDir.toAbsolutePath().toString());
  bcr.initialize();

  assertTrue(bcr.doHasNext());

  bcr.getNext(jCas.getCas());

  // assertEquals("DEV-MUC3-0001 (NOSC)", getSource(jCas));
  assertEquals("Some example\ntext.", jCas.getDocumentText());

  jCas.reset();

  assertTrue(bcr.doHasNext());
  bcr.getNext(jCas.getCas());

  // assertEquals("DEV-MUC3-0001 (NOSC)", getSource(jCas));
  assertEquals("Another example", jCas.getDocumentText());

  assertFalse(bcr.doHasNext());

  bcr.close();
 }
}
origin: dstl/baleen

@Test
public void testPopWait() throws Exception {
 BaleenCollectionReader bcr =
   getCollectionReader(
     EmailReader.PARAM_PROTOCOL, "pop3",
     EmailReader.PARAM_WAIT, 5,
     EmailReader.PARAM_SERVER, greenMail.getPop3().getBindTo(),
     EmailReader.PARAM_PORT, greenMail.getPop3().getPort(),
     EmailReader.PARAM_USER, "to@localhost.com",
     EmailReader.PARAM_PASS, "password",
     EmailReader.PARAM_PROCESS, "content");
 bcr.initialize();
 assertFalse(bcr.doHasNext());
 GreenMailUtil.sendTextEmailTest(
   "to@localhost.com", "from@localhost.com", GreenMailUtil.random(), GreenMailUtil.random());
 assertFalse(bcr.doHasNext()); // Should be a 5 second delay before it returns true
 Thread.sleep(5000);
 assertTrue(bcr.doHasNext());
 bcr.close();
}
uk.gov.dstl.baleen.uimaBaleenCollectionReaderclose

Popular methods of BaleenCollectionReader

  • doHasNext
    Called when UIMA is asking whether there is another document to process. Implementations should retu
  • getNext
  • doClose
    Called when the collection reader has finished and is closing down. Any open resources, for example,
  • doGetNext
    Called when UIMA wants the next document. The passed CAS object should be populated with the documen
  • doGetProgress
    Called when UIMA wants to know how far we've got with processing the current collection of documents
  • doInitialize
    Called when the collection reader is being initialized. Any required resources, for example, should
  • getMonitor
  • getUimaContext
  • hasNext
    Override of the UIMA hasNext() method with logic to continuously check for new documents until one i
  • initialize

Popular in Java

  • Finding current android device location
  • findViewById (Activity)
  • setScale (BigDecimal)
  • startActivity (Activity)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now