create_database/database_insertion.py
def offsets_to_token(left, right, offset_array, lemmas, punc=set(punctuation)):
    """Calculate the offset from tag to token
    Ripped off from the snorkel custom tagger.
    Designed to get the offset where a given token is found so it can receive a custom entity tag.
    (i.e. Gene or Chemical)
    Keyword arguments
    left - the start of the tag
    right - the end of the tag
    offset_array - array of offsets given by stanford corenlp
    lemmas - array of lemmas given by stanford corenlp
    punc - a list of punctuation characters
    """
    token_start, token_end = None, None
    for i, c in enumerate(offset_array):
        if left >= c:
            token_start = i
        if c > right and token_end is None:
            token_end = i
            break
    token_end = len(offset_array) - 1 if token_end is None else token_end
    token_end = token_end - 1 if lemmas[token_end - 1] in punc else token_end
    return range(token_start, token_end)
Calculate the offset from tag to token
    Ripped off from the snorkel custom tagger.
    Designed to get the offset where a given token is found so it can receive a custom entity tag.
    (i.e. Gene or Chemical)
    Keyword arguments
    left - the start of the tag
    right - the end of the tag
    offset_array - array of offsets given by stanford corenlp
    lemmas - array of lemmas given by stanford corenlp
    punc - a list of punctuation characters
    
Calculate the offset from tag to token
Ripped off from the snorkel custom tagger.
Designed to get the offset where a given token is found so it can receive a custom entity tag.
Calculate the offset from tag to token Ripped off from the snorkel custom tagger . Designed to get the offset where a given token is found so it can receive a custom entity tag .
def offsets_to_token(left, right, offset_array, lemmas, punc=set(punctuation)):
    token_start, token_end = None, None
    for i, c in enumerate(offset_array):
        if left >= c:
            token_start = i
        if c > right and token_end is None:
            token_end = i
            break
    token_end = len(offset_array) - 1 if token_end is None else token_end
    token_end = token_end - 1 if lemmas[token_end - 1] in punc else token_end
    return range(token_start, token_end)
def offsets_to_token ( left , right , offset_array , lemmas , punc = set ( punctuation ) ) : token_start , token_end = None , None for i , c in enumerate ( offset_array ) : if left >= c : token_start = i if c > right and token_end is None : token_end = i break token_end = len ( offset_array ) - 1 if token_end is None else token_end token_end = token_end - 1 if lemmas [ token_end - 1 ] in punc else token_end return range ( token_start , token_end )
Calculate the offset from tag to token
Ripped off from the snorkel custom tagger.
Calculate the offset from tag to token Ripped off from the snorkel custom tagger .
"""Calculate the offset from tag to token
    Ripped off from the snorkel custom tagger.
    Designed to get the offset where a given token is found so it can receive a custom entity tag.
    (i.e. Gene or Chemical)
    Keyword arguments
    left - the start of the tag
    right - the end of the tag
    offset_array - array of offsets given by stanford corenlp
    lemmas - array of lemmas given by stanford corenlp
    punc - a list of punctuation characters
    """
left
right
offset_array
lemmas
punc