2016-10-05 2 views
1

메신저 지금은 예를 들어, 처리 속도를 향상하기 위해 단어의 원형 화 작업을 수행 할 NLTK를 사용하고, 파이썬을 scikit을 배우기 :감정 분석 공동 목록과 감정 분석하고

를 내가받을 다음과 같은 배열 한 후 NLTK 처리 :

array([ ['Really', 'a', 'terrible', 'course', u'lecture', u'be', 'so', 'boring', 'i', u'contemplate', 'suicide', 'on', 'numerous', u'occasion', 'and', 'the', 'tutes', u'go', 'for', 'two', u'hour', 'and', u'be', 'completely'], ['Management', 'accounting', u'require', 'sufficient', 'practice', 'to', 'get', 'a', 'hang', 'of', 'Made', 'easier', 'with', 'a', 'great', 'lecturer']], dtype=object) 

하지만 scklearn 배열이 너무 적절한 형태로이 배열을 변환하는 가장 좋은 방법은 무엇

array([ 'Really a terrible course lectures were so boring i contemplated suicide on numerous occasions and the tutes went for two hours and were completely ', 'Management accounting requires sufficient practice to get a hang of Made easier with a great lecturer '],dtype=object) 

입니다 필요? 당신은 할 것 나는 joint list을 사용하려고하지만 결과는

답변

0

이상하다 :

second_array = [' '.join(each) for each in first_array] 

또는 당신은 당신의 토큰을 사용하는 sklearn.CountVectorizer을 알 수 있습니다 :

vect = CountVectorizer(preprocessor=lambda x: x, tokenizer=lambda x: x) 
X = vect.fit_transform(first_array) 
+0

멋진! 정말 고마워 –