CALBC Home
Status: Beta
Brought to you by:
loopasam
public class Example {
//This code instantiate the calbc corpus in Java object and retrieve information from it.
//Path to the CALBC file
private static String pathInput;
public static void main(String[] args) throws FileNotFoundException, XMLStreamException {
//Where the CALBC i slocated on the hard drive
pathInput = "path/to/calbc/file/175k-allcomer-xtype";
//Creation of a CALBC file
File calbcFile = new File(pathInput);
//Creation of a Corpus object. This object holds all the CALBC information
Corpus calbc = new Corpus(calbcFile);
//Once the Corpus object instantiated, it is possible to retrieve the elements:
//Loop over the articles contained inside the corpus and associated info
for (Article article : calbc.getArticles()) {
String articleID = article.getId();
String articleTitle = article.getTitle());
if(currentArticle.getDate() != null){
String articleDate = article.getDate();
}
String pmid = article.getPmid();
if(article.getAuthors() != null){
//List of the authors attached to the article
for (Author author : article.getAuthors()) {
if(author.getName() != null){
String authorName = author.getName();
}
}
}
//Loop over the sentences contained inside the current article
for (Sentence sentence : article.getSentences()) {
String sentenceId = sentence.getId();
if((sentence.getAnnotations() != null) && (sentence.getAnnotations().size() > 0)){
//Loop over the annotations contained inside the current sentence
for (Annotation annotation : sentence.getAnnotations()) {
String annotationId = annotation.getId();
String annotatedString = annotation.getAnnotatedString());
if(annotation.getConsensusTypes() != null){
for (String type : annotation.getConsensusTypes()) {
String semanticType = type;
}
}
}
}
}
}
}
}