from collections import Counter #라이브러리 호출
df['noun'] = df['content'].apply(lambda x : mecab.nouns(x)) #데이터프레임 본문에서 명사만 추출
#전처리(불용어 제거 및 텍스트 정제)
noun = df['noun'].apply(lambda x : [item for item in x if item not in stop_words])
noun = noun.apply(lambda x : [word for word in x if len(word) > 1])
#counter 함수를 사용하기위해 list화
noun_list = []
for tokens in noun:
for token in tokens:
noun_list.append(token)
#키워드 빈도수 확인
noun_count = Counter(noun_list)
#상위 50개 추출
noun_50 = noun_count.most_common(50)
from nltk import bigrams #nltk에 bigrams 패키지 사용
#전처리
noun = df['content'].apply(lambda x : [item for item in x if item not in stop_words]) #불용어 제거
noun = df['content'].apply(lambda x : [word for word in if len(word) > 1]) #글자 수가 1개보다 적은 단어는 제거
bgrams = [bigrams(word) for word in noun] #bgrams라는 변수에 전처리된 단어들을 적용
token = []
for i in bgrams:
token += ([x for x in i])