application_vnd.jupyter.stderr_output_1.png
from vncorenlp import VnCoreNLP

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import re

import string

import string
class Config:
    max_sequence_length = -1
    word_vec = -1
    punctuations = f'[{string.punctuation}\\d\n]'
    seed = 44

data_path = '../input/vietnamese-text-classification-dataset/train.csv'
df = pd.read_csv(data_path, header=None, names=['label', 'text'])

from vncorenlp import VnCoreNLP
vncorenlp = VnCoreNLP('../input/vncorenlp/VnCoreNLP-1.1.1.jar', annotators='wseg,pos,ner,parse', max_heap_size='-Xmx2g')

vncorenlp_example = vncorenlp.tokenize('nắng chiếu lung linh trên hoa vàng')

import fasttext.util
cbow_pretrain = fasttext.load_model('../input/cbow-model/cc.vi.300.bin')

import re
def format_sentence(sentence):
    sentence = re.sub(f'[{string.punctuation}\\d\n]', '', sentence)
    tokens = vncorenlp.tokenize(sentence.lower())[0]
    sentence = ' '.join(tokens)
    embedding_sentence = cbow_pretrain.get_sentence_vector(sentence)
    return embedding_sentence

"""
lấy phần text trong dataframe:
df[tên cột]: pandas.core.series.Series
df[tên cột].values: numpy.ndarray
"""
corpus = df['text'].values.tolist()

corpus = list(map(format_sentence, corpus))

X = np.array(corpus)
Config.word_vec = X.shape[1]
print(Config.word_vec)