(data_dir, word_to_id, cat_to_id, seq_length=256)
return np.array(data_id), np.array(label_id)
:param data_dir:
    :param word_to_id:
    :param cat_to_id:
    :param seq_length:
    :return:
def process_file(data_dir, word_to_id, cat_to_id, seq_length=256):
    """

    :param data_dir:
    :param word_to_id:
    :param cat_to_id:
    :param seq_length:
    :return:
    """
    data_label = read_data(data_dir)
    random.shuffle(data_label)

    data_id, label_id = [], []
    for line in data_label:
        labels = line[0].split(",")
        tmp = [cat_to_id[i] for i in labels]
        y_pad = [0] * len(cat_to_id)
        for i in tmp:
            y_pad[i] = 1
        label_id.append(y_pad)
        sent = sub_patt.sub("圞", line[1])
        tmp = []
        for word in sent:
            if word in word_to_id:
                tmp.append(word_to_id[word])
            elif word == "圞":
                tmp.append(word_to_id["<NUM>"])
            else:
                tmp.append(word_to_id["<UNK>"])
        # pad to the required length
        if len(tmp) > seq_length:
            tmp = tmp[:seq_length]
        else:
            padding = [0] * (seq_length - len(tmp))
            tmp += padding
        data_id.append(tmp)

    return np.array(data_id), np.array(label_id)
def process_file ( data_dir , word_to_id , cat_to_id , seq_length = 256 ) : data_label = read_data ( data_dir ) random . shuffle ( data_label ) data_id , label_id = [ ] , [ ] for line in data_label : labels = line [ 0 ] . split ( "," ) tmp = [ cat_to_id [ i ] for i in labels ] y_pad = [ 0 ] * len ( cat_to_id ) for i in tmp : y_pad [ i ] = 1 label_id . append ( y_pad ) sent = sub_patt . sub ( "圞",  l ne[1 ] ) tmp = [ ] for word in sent : if word in word_to_id : tmp . append ( word_to_id [ word ] ) elif word == "圞": tmp . append ( word_to_id [ "<NUM>" ] ) else : tmp . append ( word_to_id [ "<UNK>" ] ) # pad to the required length if len ( tmp ) > seq_length : tmp = tmp [ : seq_length ] else : padding = [ 0 ] * ( seq_length - len ( tmp ) ) tmp += padding data_id . append ( tmp ) return np . array ( data_id ) , np . array ( label_id )