์ด๋ฒ ํฌ์คํ ์์๋ ์ ๋ฒ ๊ธ์ ์ด์ด์ ํ ์คํธ ์ ์ฒ๋ฆฌ๋ฅผ ์ด์ด ์ ์ด๋ณด๋ ค๊ณ ํ๋ค!
[ํ ์คํธ ๋ถ์] 2-(1). ํ ์คํธ ์ ์ฒ๋ฆฌ - ํด๋ ์ง, ํ ํฐํ
2022.02.19 - [๋จธ์ ๋ฌ๋ | ๋ฅ๋ฌ๋/ํ ์คํธ ๋ถ์] - [ํ ์คํธ ๋ถ์] 1. ํ ์คํธ ๋ถ์์ ์ดํด [ํ ์คํธ ๋ถ์] 1. ํ ์คํธ ๋ถ์์ ์ดํด ํ๋ก์ ํธ๋ฅผ ํ๋ฉด์ ํ ์คํธ ๋ถ์์ ์ ํด๋ณผ ๊ธฐํ๊ฐ ์์๋๋ฐ ์์ ํ ์ดํด๋ฅผ
xod22.tistory.com
1. Cleansing(ํด๋ ์ง)
2. Tokenization(ํ ํฐํ)
3. ํํฐ๋ง / stopwords(๋ถ์ฉ์ด) ์ ๊ฑฐ / ์ฒ ์ ์์
4. Stemming & Lemmatization
3. StopWords (๋ถ์ฉ์ด) ์ ๊ฑฐ
: ์๋ฏธ์๋ ๋ถํ์ํ ๋จ์ด๋ฅผ ์ ๊ฑฐํ๋ ์์!
์คํฑ์๋(StopWord)๋ ๋ถ์์ ํฐ ์๋ฏธ๊ฐ ์๋ ๋จ์ด๋ฅผ ์ง์นญํ๋ค.
์๋ฅผ๋ค์ด is, the, a, will ๋ฑ์ ๋ฌธ๋ฒ์ ์ผ๋ก ํ์ํ ๋จ์ด๋ค์ด์ง๋ง ๋ฌธ๋งฅ์ ํฐ ์๋ฏธ๊ฐ ์๋ ๋จ์ด๋ค์ด๊ธฐ ๋๋ฌธ์ ์คํฑ ์๋์ ์ํ๋ค. ์ด๋ฌํ ๋จ์ด๋ค์ ๋ชจ๋ ํ ์คํธ์ ๋น๋ฒํ๊ฒ ๋ํ๋๋ฏ๋ก ๋ง์ผ ์ ๊ฑฐํ์ง ์๊ณ ๊ทธ๋๋ก ์ฌ์ฉํ๋ค๋ฉด, ๊ธฐ๊ณ๊ฐ ๋ค๋ฅธ ์ค์ํ ๋จ์ด๋ฅผ ์ ์ณ๋๊ณ ์ด ๋จ์ด๋ค์ ์ค์ํ ๋จ์ด๋ค๋ก ์๊ฐํ ์ ์์ ์ํ์ด ์๋ค. ๋ฐ๋ผ์ ์ด ์๋ฏธ์๋ ๋จ์ด๋ค์ ์ ์ฒ๋ฆฌ ํด์ค์ผ๋ง ํ๋ค!
ํ์ง๋ง ์ธ์ด๋ณ๋ก ์คํฑ ์๋์ ์ข ๋ฅ๊ฐ ๋ค ๋ค๋ฅธ๋ฐ...
๋คํํ๋ ์ธ์ด๋ณ๋ก ์คํฑ ์๋์ ๋ชฉ๋ก์ด ๋ชฉ๋กํ ๋์ด์๋ค..!
NLTK ๊ฐ์ ๊ฒฝ์ฐ ๊ฐ์ฅ ๋ค์ํ ์ธ์ด์ ์คํฑ ์๋๋ฅผ ์ ๊ณตํ๋ค.
import nltk
# 'english'์ธ์ด์ ๋ถ์ฉ์ด ๋ชฉ๋ก์ ๊ฐ์ ธ์ด
stopwords = nltk.corpus.stopwords.words('english')
all_tokens = []
for i in word_tokens:
filltered_words = []
for word in i:
#์๋ฌธ์๋ก ๋ณํ
word=word.lower()
#word๊ฐ ๋ถ์ฉ์ด์ ์๋ค๋ฉด filltered_words์ ์ถ๊ฐ
if word not in stopwords:
filltered_words.append(word)
all_tokens.append(filltered_words)
print(all_tokens)
1. ์์ ํฌ์คํ ์์ 3๊ฐ์ ๋ฌธ์ฅ ๋ณ๋ก ๋จ์ด ํ ํฐํ์์ผฐ๋ ๋ณ์ word_tokens๋ฅผ ์ด์ฉํด์ ๊ฐ๊ฐ์ ๋จ์ด์ ๋ํด stopwords์ธ์ง ํ๋ณํ์ฌ ๋ฐ๋ก all_tokens๋ฆฌ์คํธ์ ์ ์ฅํ๋ค.
2. ๊ฒฐ๊ณผ๋ฅผ ํ์ธํด๋ณด๋ฉด 'The', 'is', 'this'..๋ฑ๋ฑ ๊ฐ์ StopWords๊ฐ ํํฐ๋ง ๋์์์ ํ์ธํ ์ ์๋ค!
'๐ ๋จธ์ ๋ฌ๋ | ๋ฅ๋ฌ๋ > ํ ์คํธ ๋ถ์' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ ์คํธ ๋ถ์] 4-1. ์ง๋ํ์ต ๊ธฐ๋ฐ ๊ฐ์ฑ ๋ถ์ - IMDB์ํํ (0) | 2022.02.26 |
---|---|
[ํ ์คํธ ๋ถ์] 3. Bag of Words (BOW) (0) | 2022.02.24 |
[ํ ์คํธ ๋ถ์] 2-3. ํ ์คํธ ์ ์ฒ๋ฆฌ - Stemming๊ณผ Lemmatization (0) | 2022.02.23 |
[ํ ์คํธ ๋ถ์] 2-1. ํ ์คํธ ์ ์ฒ๋ฆฌ - ํด๋ ์ง, ํ ํฐํ (0) | 2022.02.20 |
[ํ ์คํธ ๋ถ์] 1. ํ ์คํธ ๋ถ์์ ์ดํด (0) | 2022.02.19 |