pubmed_parser/medline_parser.py
def parse_references(pubmed_article, reference_list):
    """Parse references from Pubmed Article

    if reference_list is True, return list, if False return string
    """
    references = []
    reference_list_data = pubmed_article.find('PubmedData/ReferenceList')
    if reference_list_data is not None:
        for ref in reference_list_data.findall('Reference'):
            citation = ref.find('Citation')
            citation = citation.text.strip() if citation is not None else ''
            article_ids = ref.find('ArticleIdList')
            pmid = article_ids.find('ArticleId[@IdType="pubmed"]') if article_ids is not None else None
            pmid = pmid.text.strip() if pmid is not None else ''
            references.append({
                'citation': citation,
                'pmid': pmid
            })

    if reference_list:
        return references
    else:
        references = ';'.join([ref['pmid'] for ref in references if ref['pmid'] is not ''])
        return references
Parse references from Pubmed Article

    if reference_list is True, return list, if False return string
    
Parse references from Pubmed Article
if reference_list is True, return list, if False return string
Parse references from Pubmed Article if reference_list is True return list if False return string
def parse_references(pubmed_article, reference_list):
    references = []
    reference_list_data = pubmed_article.find('PubmedData/ReferenceList')
    if reference_list_data is not None:
        for ref in reference_list_data.findall('Reference'):
            citation = ref.find('Citation')
            citation = citation.text.strip() if citation is not None else ''
            article_ids = ref.find('ArticleIdList')
            pmid = article_ids.find('ArticleId[@IdType="pubmed"]') if article_ids is not None else None
            pmid = pmid.text.strip() if pmid is not None else ''
            references.append({
                'citation': citation,
                'pmid': pmid
            })
    if reference_list:
        return references
    else:
        references = ';'.join([ref['pmid'] for ref in references if ref['pmid'] is not ''])
        return references
def parse_references ( pubmed_article , reference_list ) : references = [ ] reference_list_data = pubmed_article . find ( 'PubmedData/ReferenceList' ) if reference_list_data is not None : for ref in reference_list_data . findall ( 'Reference' ) : citation = ref . find ( 'Citation' ) citation = citation . text . strip ( ) if citation is not None else '' article_ids = ref . find ( 'ArticleIdList' ) pmid = article_ids . find ( 'ArticleId[@IdType="pubmed"]' ) if article_ids is not None else None pmid = pmid . text . strip ( ) if pmid is not None else '' references . append ( { 'citation' : citation , 'pmid' : pmid } ) if reference_list : return references else : references = ';' . join ( [ ref [ 'pmid' ] for ref in references if ref [ 'pmid' ] is not '' ] ) return references
Parse references from Pubmed Article
if reference_list is True, return list, if False return string
Parse references from Pubmed Article if reference_list is True return list if False return string
"""Parse references from Pubmed Article

    if reference_list is True, return list, if False return string
    """
pubmed_article
reference_list