Example BoaC Programs

BoaC is a flexible language, capable of answering a wide variety of questions. Here we provide several example questions and BoaC programs to answer those questions.

  1. How many papers have empty vs. non-empty title?
  2. What 100 words appear in the most number of paper abstracts?
  3. What 100 words appear in the most number of paper bodies?
  4. What 500 words appear in the least number of paper bodies for papers with vaccine in the title?
  5. What are the most mentioned antivirals?
  6. What do we know about cornavirus risk factors?
  7. What has been published about medical care?

How many papers have empty vs. non-empty title?

p: Paper = input; empty: output sum of int; non_empty: output sum of int; # check if title is empty or not if (p.metadata.title == "") empty << 1; else non_empty << 1;

Run Example | Published Results

What 100 words appear in the most number of paper abstracts?

# What 100 words appear in the most number of paper abstracts? p: Paper = input; o: output top(100) of string weight int; stopwords: set of string = stop_words(); # store all words used in this paper's abstract abstractWords: set of string; foreach (i: int; def(p.abstract[i])) { paragraphWords: array of string = splitall(lowercase(p.abstract[i].text), " "); foreach (j: int; !contains(stopwords, paragraphWords[j])) add(abstractWords, paragraphWords[j]); } words := values(abstractWords); foreach (k: int; def(words[k])) o << words[k] weight 1;

Run Example | Published Results

What 100 words appear in the most number of paper bodies?

# What 100 words appear in the most number of paper bodies? p: Paper = input; o: output top(100) of string weight int; stopwords: set of string = stop_words(); # store all words used in this paper's body bodyWords: set of string; foreach (i: int; def(p.body_text[i])) { foreach (m: int; def(p.body_text[i].body[m])) { paragraphWords: array of string = splitall(lowercase(p.body_text[i].body[m].text), " "); foreach (j: int; !contains(stopwords, paragraphWords[j])) add(bodyWords, paragraphWords[j]); } } words := values(bodyWords); foreach (k: int; def(words[k])) o << words[k] weight 1;

Run Example | Published Results

What 500 words appear in the least number of paper bodies for papers with vaccine in the title?

# What 500 words appear in the least number of paper bodies for papers with vaccine in the title? p: Paper = input; o: output bottom(500) of string weight int; stopwords: set of string = stop_words(); # store all words used in this paper's body bodyWords: set of string; if (strfind("vaccine", lowercase(p.metadata.title)) >= 0) { foreach (i: int; def(p.body_text[i])) { foreach (m: int; def(p.body_text[i].body[m])) { paragraphWords: array of string = splitall(lowercase(p.body_text[i].body[m].text), " "); foreach (j: int; !contains(stopwords, paragraphWords[j])) # match only english words if (match("^[a-z]+$", paragraphWords[j])) add(bodyWords, paragraphWords[j]); } } words := values(bodyWords); foreach (k: int; def(words[k])) o << words[k] weight 1; }

Run Example | Published Results

What are the most mentioned antivirals?

# What are the most mentioned antivirals? p: Paper = input; o: output top(500) of string weight int; stopwords: set of string = stop_words(); # store all words used in this paper's body bodyWords: set of string; foreach (i: int; def(p.body_text[i])) { foreach (m: int; def(p.body_text[i].body[m])) { paragraphWords: array of string = splitall(lowercase(p.body_text[i].body[m].text), " "); foreach (j: int; !contains(stopwords, paragraphWords[j])) # match only english words if (match("^[a-z]*vir$", paragraphWords[j])) add(bodyWords, paragraphWords[j]); } } words := values(bodyWords); foreach (k: int; def(words[k])) o << words[k] weight 1;

Run Example | Published Results

What do we know about cornavirus risk factors?

## What do we know about cornavirus risk factors? p: Paper = input; smoke: output set of string; pregnant: output set of string; neonatal: output set of string; pulmonary: output set of string; foreach (i: int; def(p.abstract[i])) { absStore: string = lowercase(p.abstract[i].text); if ((strfind("smoke", absStore) >= 0 || strfind("smoking", absStore) >= 0) && strfind("risk", absStore) >= 0) { smoke << p.metadata.title; } if ((strfind("pregnant", absStore) >= 0 || strfind("pregnancy", absStore) >= 0) && strfind("risk", absStore) >= 0) { pregnant << p.metadata.title; } if ((strfind("neonatal", absStore) >= 0 || strfind("neo-natal", absStore) >= 0) && strfind("risk", absStore) >= 0) { neonatal << p.metadata.title; } if (strfind("pulmonary", absStore) >= 0 && strfind("risk", absStore) >= 0) { pulmonary << p.metadata.title; } }

Run Example | Published Results

What has been published about medical care?

## What has been published about medical care? p: Paper = input; nursing: output set of string; ards: output set of string; ecmo: output set of string; ventilation: output set of string; n95: output set of string; regulatory: output set of string; medication: output set of string; foreach (i: int; def(p.abstract[i])) { absStore: string = lowercase(p.abstract[i].text); if (strfind("nursing", absStore) >= 0 || strfind("long term care", absStore) >= 0) { nursing << p.metadata.title; } if (strfind("ards", absStore) >= 0 || strfind("acute respiratory distress syndrome", absStore) >= 0) { ards << p.metadata.title; } if (strfind("ecmo", absStore) >= 0 || strfind("extracorporeal membrane oxygenation", absStore) >= 0) { ecmo << p.metadata.title; } if (strfind("ventilation", absStore) >= 0) { ventilation << p.metadata.title; } if (strfind("n95", absStore) >= 0) { n95 << p.metadata.title; } if (strfind("eua", absStore) >= 0 || strfind("clia", absStore) >= 0) { regulatory << p.metadata.title; } if (strfind("medication", absStore) >= 0 && strfind("oral", absStore) >= 0) { medication << p.metadata.title; } }

Run Example | Published Results