ํ์ค ๋ฌธ์ฅ ํ ํฌ๋์ด์ sent_tokenize
๋ฒ๊ทธ๊ฐ ์๋ค๊ณ ์๊ฐํฉ๋๋ค. ๋ฌธ์ ๋ ํน์ ๊ฒฝ์ฐ์ ํ
์คํธ๋ฅผ ๋ฌธ์ฅ์ผ๋ก ๋ถํ ํ์ง ์๋๋ค๋ ๊ฒ์
๋๋ค. ๋ค์์ ํ ํฌ๋์ด์ ๊ฐ ํ
์คํธ๋ฅผ ๋ ๋ฌธ์ฅ์ผ๋ก ๋ถํ ํ๋ ๋ฐ ์คํจํ ๊ฒฝ์ฐ์
๋๋ค.
[sent for sent in nltk.sent_tokenize('Model wears size S. Fits size.')]
์ด ๋ฐํ ['Model wears size S. Fits size.']
๋์ ์, ['Model wears size S.', 'Fits size.']
. .
์์ ๋ง์ง๋ง ๋ฌธ์์ด์ ํ๋์ ๋ฌธ์๋ง ํฌํจ๋ ๊ฒฝ์ฐ ๋ฌธ์ ๊ฐ ๋ํ๋๋ ๊ฒ ๊ฐ์ต๋๋ค. ๋ฌธ์ ์๊ฐ >= 2
์ด๋ฉด ํ
์คํธ๋ฅผ ์ฌ๋ฐ๋ฅด๊ฒ ๋ถํ ํฉ๋๋ค.
S. Fits๊ฐ ์ฌ๋์ ์ฑ๊ณผ ์ด๋ฆ์ผ ์ ์๋ค๋ ์ ์ ๊ณ ๋ คํ๋ฉด ๋ฌธ์ฅ ํ ํฌ๋์ด์ ์์ ์์ ํ๊ธฐ๊ฐ ๋งค์ฐ ์ด๋ ค์ ๋ณด์ ๋๋ค.
๊ฐ ๋ฐฉ๋ฒ์ ๊ธฐ๋ณธ NLTK ๋ฌธ์ฅ ํ ํฌ๋์ด์ ๋ฅผ ํ์ ํด๋์คํํ๊ฑฐ๋ ๋ณต์ฌํ์ฌ ๋ถ์ฌ๋ฃ๊ณ ์์ฉ ํ๋ก๊ทธ๋จ์ ๋ง๊ฒ ์์ ํ๋ ๊ฒ์
๋๋ค. ์๋ฅผ ๋ค์ด ํ
์คํธ์์ ์ด๋ฌํ ์ฌ๋ ์ด๋ฆ์ด ํ์ํ์ง ์์ ๊ฒฝ์ฐ ์ฌ๋ ์ด๋ฆ์ ์ฒ๋ฆฌํ๋ ๊ท์น์ ์ ๊ฑฐํ์ญ์์ค. ๋ ๋ค๋ฅธ ์ต์
์ ํ ํฐํ ์ ์ size <X>
๋ฅผ size_<X>
๋ฐ๊พธ๊ณ ํ
์คํธ๊ฐ ๋ฌธ์ฅ์ผ๋ก ๋ถํ ๋ ํ ๋ค์ ๋ฐ๊พธ๋ ๊ฒ๊ณผ ๊ฐ์ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๋ ๊ฒ์
๋๋ค.
ํ . ๋ฐฉ๊ธ ๋ค์ ์๋ํ์ต๋๋ค. ๊ทธ๋์ ์ ๊ฐ ์ ์ํ ์ฒซ ๋ฒ์งธ ์ฌ๋ก๋ ์ฌ๋ฐ๋ฅด๊ฒ ๋ถํ ๋์ง ์์ต๋๋ค. ๊ทธ๋ฌ๋ ๋ค๋ฅธ ๋ฌธ์๋ฅผ ์ฌ์ฉํ๋ฉด ๋๋๋ก ๋ถํ ๋ฉ๋๋ค! ์ด๊ฒ์ด ๋ด๊ฐ ์ด ๋น ๋ฅธ ํ ์คํธ๋ฅผ ์์ฑํ ์ด์ ์ ๋๋ค.
import nltk
import pprint
pp = pprint.PrettyPrinter(indent=4)
s = 'Test {}. Test {}.'
[nltk.sent_tokenize(s.format(char, char)) for char in 'abcdefghijklmnopqrstuvwxyz']
[pp.pprint(nltk.sent_tokenize(s.format(char, char))) for char in 'abcdefghijklmnopqrstuvwxyz']
์ฐ์ถ:
['Test a.', 'Test a.']
['Test b.', 'Test b.']
['Test c. Test c.']
['Test d. Test d.']
['Test e. Test e.']
['Test f. Test f.']
['Test g. Test g.']
['Test h. Test h.']
['Test i.', 'Test i.']
['Test j.', 'Test j.']
['Test k. Test k.']
['Test l. Test l.']
['Test m. Test m.']
['Test n. Test n.']
['Test o.', 'Test o.']
['Test p. Test p.']
['Test q.', 'Test q.']
['Test r. Test r.']
['Test s. Test s.']
['Test t. Test t.']
['Test u.', 'Test u.']
['Test v. Test v.']
['Test w. Test w.']
['Test x.', 'Test x.']
['Test y.', 'Test y.']
['Test z.', 'Test z.']
@kmike ,
@JernejJerin ๊ท์น ๊ธฐ๋ฐ ํ ํฌ๋์ด์ ๊ฐ ์๋๋ฏ๋ก ์ ๊ท์๊ณผ ๊ฐ์ ์ค๋ช ์ ์ฌ์ฉํ์ฌ ๋ถํ ์ "๊ท์น"์ ์ ์ด/์ค๋ช ํ ์ ์์ต๋๋ค.
sent_tokenizer
ํ๋ จ์ ์ฌ์ฉ๋ ์๊ณ ๋ฆฌ์ฆ์ Kiss and Strunk(2006) punkt ์๊ณ ๋ฆฌ์ฆ ์
๋๋ค. ๋ฌธ์ฅ ๊ฒฝ๊ณ๋ฅผ ํ์ตํ๋ ค๊ณ ์๋ํ๋ ํต๊ณ ์์คํ
์ด๋ฏ๋ก ์๋ฒฝํ์ง๋ ์์ง๋ง ๋ชจ๋ธ์์ ์์ฑ๋ ํ๋ฅ ๊ณผ ์ผ์นํฉ๋๋ค(๊ทธ๋ฌ๋ ์ธ๊ฐ๊ณผ ๊ฐ์ ๊ท์น์ ํ์ํ์ง ์์).
Smashwords์ Mike Suttons๊ฐ ๋ฐํํ "Three Plays"์์ ์ถ์ถํ BookCorpus ์ ์ค์ ์์ ๋ฅผ ์ถ๊ฐํ๊ณ ์ถ์ต๋๋ค.
sent_tokenize('The weather is terrible, and my day was ok. You are supposed to take your medicine.')
์ฐ์ถ
['The weather is terrible, and my day was ok. You are supposed to take your medicine.']
nltk๊ฐ k.
๋ฅผ ๋ฌธ์ฅ ๊ตฌ๋ถ์๋ก ์ธ์ํ์ง ๋ชปํ๋ ๊ฒ์ ํ์ธํ์ต๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
Smashwords์ Mike Suttons๊ฐ ๋ฐํํ "Three Plays"์์ ์ถ์ถํ BookCorpus ์ ์ค์ ์์ ๋ฅผ ์ถ๊ฐํ๊ณ ์ถ์ต๋๋ค.
sent_tokenize('The weather is terrible, and my day was ok. You are supposed to take your medicine.')
์ฐ์ถ
['The weather is terrible, and my day was ok. You are supposed to take your medicine.']
nltk๊ฐ
k.
๋ฅผ ๋ฌธ์ฅ ๊ตฌ๋ถ์๋ก ์ธ์ํ์ง ๋ชปํ๋ ๊ฒ์ ํ์ธํ์ต๋๋ค.