create_database/database_insertion.py
def tag(self, parts):
        """Tag each Sentence
        Keyword arguments:
        self -- the class object
        parts -- standford's corenlp object which consists of nlp properties
        Returns:
        An updated parts object containing specified custom tags.
        """

        pubmed_id, _, _, sent_start, sent_end = parts['stable_id'].split(':')
        sent_start, sent_end = int(sent_start), int(sent_end)

        # For each tag in the given document
        # assign it to the correct word and move on
        # if int(pubmed_id) not in self.annt_df['pubmed_id']:
        #    return parts
        try:
            for index, tag in self.annt_df.get_group(int(pubmed_id)).iterrows():
                if not (sent_start <= int(tag['offset']) <= sent_end):
                    continue

                offsets = [offset + sent_start for offset in parts['char_offsets']]
                toks = offsets_to_token(int(tag['offset']), int(tag['end']), offsets, parts['lemmas'])
                for tok in toks:
                    parts['entity_types'][tok] = tag['type']
                    parts['entity_cids'][tok] = tag['identifier']

            return parts

        except KeyError as e:
            return parts
Tag each Sentence
        Keyword arguments:
        self -- the class object
        parts -- standford's corenlp object which consists of nlp properties
        Returns:
        An updated parts object containing specified custom tags.
        
Tag each Sentence
Keyword arguments:
self -- the class object
parts -- standford's corenlp object which consists of nlp properties
Tag each Sentence Keyword arguments : self -- the class object parts -- standford ' s corenlp object which consists of nlp properties
def tag(self, parts):
        pubmed_id, _, _, sent_start, sent_end = parts['stable_id'].split(':')
        sent_start, sent_end = int(sent_start), int(sent_end)
        try:
            for index, tag in self.annt_df.get_group(int(pubmed_id)).iterrows():
                if not (sent_start <= int(tag['offset']) <= sent_end):
                    continue
                offsets = [offset + sent_start for offset in parts['char_offsets']]
                toks = offsets_to_token(int(tag['offset']), int(tag['end']), offsets, parts['lemmas'])
                for tok in toks:
                    parts['entity_types'][tok] = tag['type']
                    parts['entity_cids'][tok] = tag['identifier']
            return parts
        except KeyError as e:
            return parts
def tag ( self , parts ) : pubmed_id , _ , _ , sent_start , sent_end = parts [ 'stable_id' ] . split ( ':' ) sent_start , sent_end = int ( sent_start ) , int ( sent_end ) try : for index , tag in self . annt_df . get_group ( int ( pubmed_id ) ) . iterrows ( ) : if not ( sent_start <= int ( tag [ 'offset' ] ) <= sent_end ) : continue offsets = [ offset + sent_start for offset in parts [ 'char_offsets' ] ] toks = offsets_to_token ( int ( tag [ 'offset' ] ) , int ( tag [ 'end' ] ) , offsets , parts [ 'lemmas' ] ) for tok in toks : parts [ 'entity_types' ] [ tok ] = tag [ 'type' ] parts [ 'entity_cids' ] [ tok ] = tag [ 'identifier' ] return parts except KeyError as e : return parts
Tag each Sentence
Keyword arguments:
self -- the class object
parts -- standford's corenlp object which consists of nlp properties
Tag each Sentence Keyword arguments : self -- the class object parts -- standford ' s corenlp object which consists of nlp properties
"""Tag each Sentence
        Keyword arguments:
        self -- the class object
        parts -- standford's corenlp object which consists of nlp properties
        Returns:
        An updated parts object containing specified custom tags.
        """ # For each tag in the given document # assign it to the correct word and move on # if int(pubmed_id) not in self.annt_df['pubmed_id']: #    return parts
None
self
parts