modules/utils/notebook_utils/dataframe_helper.py
def make_sentence_df(candidates):
    """ 
    This function creats a dataframe for all candidates (sentences that contain at least two mentions)
    located in our database.
    
    candidates - a list of candidate objects passed in from sqlalchemy

    return a Dataframe that contains each candidate sentence  and the corresponding candidate entities
    """
    rows = list()
    for c in tqdm_notebook(candidates):
        args = [
                (c[0].get_word_start(), c[0].get_word_end(), 1),
                (c[1].get_word_start(), c[1].get_word_end(), 2)
            ]
        sen = " ".join(mark_sentence(candidate_to_tokens(c), args))
        if hasattr(c, 'Disease_cid') and hasattr(c, 'Gene_cid'):
            row = OrderedDict()
            row['candidate_id'] = c.id
            row['disease'] = c[0].get_span()
            row['gene'] = c[1].get_span()
            row['doid_id'] = c.Disease_cid
            row['entrez_gene_id'] = c.Gene_cid
            row['sentence'] = sen
        elif hasattr(c, 'Gene1_cid') and hasattr(c, 'Gene2_cid'):
            row = OrderedDict()
            row['candidate_id'] = c.id
            row['gene1'] = c[0].get_span()
            row['gene2'] = c[1].get_span()
            row['gene1_id'] = c.Gene1_cid
            row['gene2_id'] = c.Gene2_cid
            row['sentence'] = sen
        elif hasattr(c, 'Compound_cid') and hasattr(c, 'Gene_cid'):
            row = OrderedDict()
            row['candidate_id'] = c.id
            row['compound'] = c[0].get_span()
            row['gene'] = c[1].get_span()
            row['drugbank_id'] = c.Compound_cid
            row['entrez_gene_id'] = c.Gene_cid
            row['sentence'] = sen
        elif hasattr(c, 'Compound_cid') and hasattr(c, 'Disease_cid'):
            row = OrderedDict()
            row['candidate_id'] = c.id
            row['compound'] = c[0].get_span()
            row['disease'] = c[1].get_span()
            row['drugbank_id'] = c.Compound_cid
            row['doid_id'] = c.Disease_cid
            row['sentence'] = sen
        rows.append(row)
    return pd.DataFrame(rows)
 
    This function creats a dataframe for all candidates (sentences that contain at least two mentions)
    located in our database.
    
    candidates - a list of candidate objects passed in from sqlalchemy

    return a Dataframe that contains each candidate sentence  and the corresponding candidate entities
    
This function creats a dataframe for all candidates (sentences that contain at least two mentions)
located in our database.

a list of candidate objects passed in from sqlalchemy

return a Dataframe that contains each candidate sentence  and the corresponding candidate entities
This function creats a dataframe for all candidates ( sentences that contain at least two mentions ) located in our database . a list of candidate objects passed in from sqlalchemy return a Dataframe that contains each candidate sentence and the corresponding candidate entities
def make_sentence_df(candidates):
    rows = list()
    for c in tqdm_notebook(candidates):
        args = [
                (c[0].get_word_start(), c[0].get_word_end(), 1),
                (c[1].get_word_start(), c[1].get_word_end(), 2)
            ]
        sen = " ".join(mark_sentence(candidate_to_tokens(c), args))
        if hasattr(c, 'Disease_cid') and hasattr(c, 'Gene_cid'):
            row = OrderedDict()
            row['candidate_id'] = c.id
            row['disease'] = c[0].get_span()
            row['gene'] = c[1].get_span()
            row['doid_id'] = c.Disease_cid
            row['entrez_gene_id'] = c.Gene_cid
            row['sentence'] = sen
        elif hasattr(c, 'Gene1_cid') and hasattr(c, 'Gene2_cid'):
            row = OrderedDict()
            row['candidate_id'] = c.id
            row['gene1'] = c[0].get_span()
            row['gene2'] = c[1].get_span()
            row['gene1_id'] = c.Gene1_cid
            row['gene2_id'] = c.Gene2_cid
            row['sentence'] = sen
        elif hasattr(c, 'Compound_cid') and hasattr(c, 'Gene_cid'):
            row = OrderedDict()
            row['candidate_id'] = c.id
            row['compound'] = c[0].get_span()
            row['gene'] = c[1].get_span()
            row['drugbank_id'] = c.Compound_cid
            row['entrez_gene_id'] = c.Gene_cid
            row['sentence'] = sen
        elif hasattr(c, 'Compound_cid') and hasattr(c, 'Disease_cid'):
            row = OrderedDict()
            row['candidate_id'] = c.id
            row['compound'] = c[0].get_span()
            row['disease'] = c[1].get_span()
            row['drugbank_id'] = c.Compound_cid
            row['doid_id'] = c.Disease_cid
            row['sentence'] = sen
        rows.append(row)
    return pd.DataFrame(rows)
def make_sentence_df ( candidates ) : rows = list ( ) for c in tqdm_notebook ( candidates ) : args = [ ( c [ 0 ] . get_word_start ( ) , c [ 0 ] . get_word_end ( ) , 1 ) , ( c [ 1 ] . get_word_start ( ) , c [ 1 ] . get_word_end ( ) , 2 ) ] sen = " " . join ( mark_sentence ( candidate_to_tokens ( c ) , args ) ) if hasattr ( c , 'Disease_cid' ) and hasattr ( c , 'Gene_cid' ) : row = OrderedDict ( ) row [ 'candidate_id' ] = c . id row [ 'disease' ] = c [ 0 ] . get_span ( ) row [ 'gene' ] = c [ 1 ] . get_span ( ) row [ 'doid_id' ] = c . Disease_cid row [ 'entrez_gene_id' ] = c . Gene_cid row [ 'sentence' ] = sen elif hasattr ( c , 'Gene1_cid' ) and hasattr ( c , 'Gene2_cid' ) : row = OrderedDict ( ) row [ 'candidate_id' ] = c . id row [ 'gene1' ] = c [ 0 ] . get_span ( ) row [ 'gene2' ] = c [ 1 ] . get_span ( ) row [ 'gene1_id' ] = c . Gene1_cid row [ 'gene2_id' ] = c . Gene2_cid row [ 'sentence' ] = sen elif hasattr ( c , 'Compound_cid' ) and hasattr ( c , 'Gene_cid' ) : row = OrderedDict ( ) row [ 'candidate_id' ] = c . id row [ 'compound' ] = c [ 0 ] . get_span ( ) row [ 'gene' ] = c [ 1 ] . get_span ( ) row [ 'drugbank_id' ] = c . Compound_cid row [ 'entrez_gene_id' ] = c . Gene_cid row [ 'sentence' ] = sen elif hasattr ( c , 'Compound_cid' ) and hasattr ( c , 'Disease_cid' ) : row = OrderedDict ( ) row [ 'candidate_id' ] = c . id row [ 'compound' ] = c [ 0 ] . get_span ( ) row [ 'disease' ] = c [ 1 ] . get_span ( ) row [ 'drugbank_id' ] = c . Compound_cid row [ 'doid_id' ] = c . Disease_cid row [ 'sentence' ] = sen rows . append ( row ) return pd . DataFrame ( rows )
This function creats a dataframe for all candidates (sentences that contain at least two mentions)
located in our database.
This function creats a dataframe for all candidates ( sentences that contain at least two mentions ) located in our database .
""" 
    This function creats a dataframe for all candidates (sentences that contain at least two mentions)
    located in our database.
    
    candidates - a list of candidate objects passed in from sqlalchemy

    return a Dataframe that contains each candidate sentence  and the corresponding candidate entities
    """
candidates