tenho 3 arquivos o que execução, o de leitura e o de escrita. Meu problema é no de leitura, que primeiro tive que fazer ler 3 texto que é a parte que está como comentário, mas agora tenho que adaptar ele para pegar o arquivo “news.txt” e separar por linhas para o arquivo de escrita, possa dividir em tokens.
Muito obrigado pela ajuda!
public class DummyReader extends JCasCollectionReader_ImplBase {
List<String> texts;
int idx = 0;
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
super.initialize(context);
ClassLoader classLoader= getClass().getClassLoader();
File file = new File(classLoader.getResource("news.txt").getFile());
// texts = new ArrayList<>();
// texts.add("Ubi est Cornelia?");
// texts.add("Subito Marcus vocat:");
// texts.add("Ibi Cornelia est, ibi stat!");
}
@Override
public void getNext(JCas jcas) throws IOException, CollectionException {
// add the text to the JCAS. All annotation (AEs) will be based on this text
jcas.setDocumentText(texts.get(idx));
idx++;
}
@Override
public Progress[] getProgress() {
return new Progress[] { new ProgressImpl(idx + 1, texts.size(), Progress.ENTITIES) };
}
@Override
public boolean hasNext() throws IOException, CollectionException {
return idx < texts.size();
}
}