์ด ์ถ๋ ฅ์ ์๊ธฐ์น ์์ ๊ฒ์
๋๋ค. In
๋ PorterStemmer์ ์ถ๋ ฅ์์ โโ๋๋ฌธ์ In
๋ฅผ ๋ฐํํฉ๋๋ค.
>>> from nltk.stem import PorterStemmer
>>> porter = PorterStemmer()
>>> porter.stem('In')
'In'
https://stackoverflow.com/q/60387288/610569 ์ ๋ํ ์์ธํ ๋ด์ฉ
ํํ์ ๋ถ์์ ๊ฒฝ์ฐ ๋จผ์ ์ ๊ทํ์ ์ผ๋ถ๋ก ์๋ฌธ์๋ก ๋ณํํด์ผ ํ์ง ์์ต๋๊น?
Oh
์ฌ์ฉํ ๋๋ฌธ์ ์ถ๋ ฅ์ ๋ ๋ค๋ฅธ ์
>>> from nltk.stem import PorterStemmer
>>> porter = PorterStemmer()
>>> porter.stem('Oh')
'Oh'
state์ ๋ํ ์ฝ์ด์ฒ๋ผ ๋จ์ด ๊ธธ์ด๊ฐ 2๋ณด๋ค ์์ ๋ ์๋์ ์ฝ์ด ํํ๋ฅผ ์ ์งํ๊ณ ์ ํ๊ธฐ ๋๋ฌธ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค.
def stem(self, word):
stem = word.lower()
if self.mode == self.NLTK_EXTENSIONS and word in self.pool:
return self.pool[word]
if self.mode != self.ORIGINAL_ALGORITHM and len(word) <= 2:
# With this line, strings of length 1 or 2 don't go through
# the stemming process, although no mention is made of this
# in the published algorithm.
return word
stem = self._step1a(stem)
stem = self._step1b(stem)
stem = self._step1c(stem)
stem = self._step2(stem)
stem = self._step3(stem)
stem = self._step4(stem)
stem = self._step5a(stem)
stem = self._step5b(stem)
return stem
'In'๊ณผ 'Oh'๋ผ๋ ๋จ์ด๋ ๋ชจ๋ self.pool
๋ฐ len(word)<=2
์ ์์ง ์์ต๋๋ค. ์ฆ, ์ฌ๊ธฐ์์ ์ค๊ธฐ ์กฐ๊ฑด์ ์ถฉ์กฑํ์ง ์์ผ๋ฏ๋ก ๋์ผํ๊ฒ ์ ์ง๋ฉ๋๋ค.
ํ ๋น๋์ง ์์ ๊ฒฝ์ฐ ์ด ์์ ์ ์ํํด๋ ๋ฉ๋๊น? ํ๋ก์ ํธ์ ๊ธฐ์ฌํ ๊ฒ์ ์ฒ์์ ๋๋ค.
@PhanatosZou ์์ ๋กญ๊ฒ ๋ณ๊ฒฝํ๊ณ ํ ๋ฆฌํ์คํธ๋ฅผ ์์ฑํ์ธ์. ๋ณ๊ฒฝํด์ผ ํ๋ ์ฃผ์ ์ฝ๋๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
if self.mode != self.ORIGINAL_ALGORITHM and len(word) <= 2:
# With this line, strings of length 1 or 2 don't go through
# the stemming process, although no mention is made of this
# in the published algorithm.
return stem
๊ทธ๋ฌ๋ self.pool
๋ชจ๋ ํค๋ฅผ ํ์ธํ๊ณ ๋๋ฌธ์๊ฐ ์๋ ๊ฒฝ์ฐ ์ด๊ฒ๋ ๋ณ๊ฒฝํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
if self.mode == self.NLTK_EXTENSIONS and word in self.pool:
return self.pool[stem]
์ข์ ์๋ฆฌ! ์์ ํ๊ฒ ์ต๋๋ค.