[1bd6b5]: / helpers / awesome.py

Download this file

26 lines (15 with data), 570 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from re import findall
def get_between_headers(md_list, start, end):
return md_list[md_list.index(start):md_list.index(end)]
def match_dois(lines):
return findall(r'doi.org/(.*?)\)\W', '\n'.join(lines))
def match_pubmed(lines):
return findall(r'pubmed/(\d+)', '\n'.join(lines))
def match_pubmed_central(lines):
return findall(r'pmc/articles/(PMC\d+)/', '\n'.join(lines))
def extract_references(text):
return {
'doi': match_dois(text),
'pubmed': match_pubmed(text),
'pubmed_central': match_pubmed_central(text)
}