(where_str_tokens, NLq)
return ret.strip()
Almost copied of SQLNet.
    The main purpose is pad blank line while combining tokens.
Almost copied of SQLNet.
    The main purpose is pad blank line while combining tokens.
Almost copied of SQLNet . The main purpose is pad blank line while combining tokens .
def merge_wv_t1_eng(where_str_tokens, NLq):
    """
    Almost copied of SQLNet.
    The main purpose is pad blank line while combining tokens.
    """
    nlq = NLq.lower()
    where_str_tokens = [tok.lower() for tok in where_str_tokens]
    alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789$'
    special = {'-LRB-': '(',
               '-RRB-': ')',
               '-LSB-': '[',
               '-RSB-': ']',
               '``': '"',
               '\'\'': '"',
               }
               # '--': '\u2013'} # this generate error for test 5661 case.
    ret = ''
    double_quote_appear = 0
    for raw_w_token in where_str_tokens:
        # if '' (empty string) of None, continue
        if not raw_w_token:
            continue

        # Change the special characters
        w_token = special.get(raw_w_token, raw_w_token)  # maybe necessary for some case?

        # check the double quote
        if w_token == '"':
            double_quote_appear = 1 - double_quote_appear

        # Check whether ret is empty. ret is selected where condition.
        if len(ret) == 0:
            pass
        # Check blank character.
        elif len(ret) > 0 and ret + ' ' + w_token in nlq:
            # Pad ' ' if ret + ' ' is part of nlq.
            ret = ret + ' '

        elif len(ret) > 0 and ret + w_token in nlq:
            pass  # already in good form. Later, ret + w_token will performed.

        # Below for unnatural question I guess. Is it likely to appear?
        elif w_token == '"':
            if double_quote_appear:
                ret = ret + ' '  # pad blank line between next token when " because in this case, it is of closing apperas
                # for the case of opening, no blank line.

        elif w_token[0] not in alphabet:
            pass  # non alphabet one does not pad blank line.

        # when previous character is the special case.
        elif (ret[-1] not in ['(', '/', '\u2013', '#', '$', '&']) and (ret[-1] != '"' or not double_quote_appear):
            ret = ret + ' '
        ret = ret + w_token

    return ret.strip()
def merge_wv_t1_eng ( where_str_tokens , NLq ) : nlq = NLq . lower ( ) where_str_tokens = [ tok . lower ( ) for tok in where_str_tokens ] alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789$' special = { '-LRB-' : '(' , '-RRB-' : ')' , '-LSB-' : '[' , '-RSB-' : ']' , '``' : '"' , '\'\'' : '"' , } # '--': '\u2013'} # this generate error for test 5661 case. ret = '' double_quote_appear = 0 for raw_w_token in where_str_tokens : # if '' (empty string) of None, continue if not raw_w_token : continue # Change the special characters w_token = special . get ( raw_w_token , raw_w_token ) # maybe necessary for some case? # check the double quote if w_token == '"' : double_quote_appear = 1 - double_quote_appear # Check whether ret is empty. ret is selected where condition. if len ( ret ) == 0 : pass # Check blank character. elif len ( ret ) > 0 and ret + ' ' + w_token in nlq : # Pad ' ' if ret + ' ' is part of nlq. ret = ret + ' ' elif len ( ret ) > 0 and ret + w_token in nlq : pass # already in good form. Later, ret + w_token will performed. # Below for unnatural question I guess. Is it likely to appear? elif w_token == '"' : if double_quote_appear : ret = ret + ' ' # pad blank line between next token when " because in this case, it is of closing apperas # for the case of opening, no blank line. elif w_token [ 0 ] not in alphabet : pass # non alphabet one does not pad blank line. # when previous character is the special case. elif ( ret [ - 1 ] not in [ '(' , '/' , '\u2013' , '#' , '$' , '&' ] ) and ( ret [ - 1 ] != '"' or not double_quote_appear ) : ret = ret + ' ' ret = ret + w_token return ret . strip ( )