私は NLTK を使用していくつかの古典的なテキストを分析していますが、テキストを文ごとにトークン化する際に問題が発生しています。たとえば、Moby Dickからのスニペットから取得したものは次のとおりです。
import nltk
sent_tokenize = nltk.data.load('tokenizers/punkt/english.pickle')
'''
(Chapter 16)
A clam for supper? a cold clam; is THAT what you mean, Mrs. Hussey?" says I, "but
that's a rather cold and clammy reception in the winter time, ain't it, Mrs. Hussey?"
'''
sample = 'A clam for supper? a cold clam; is THAT what you mean, Mrs. Hussey?" says I, "but that\'s a rather cold and clammy reception in the winter time, ain\'t it, Mrs. Hussey?"'
print "\n-----\n".join(sent_tokenize.tokenize(sample))
'''
OUTPUT
"A clam for supper?
-----
a cold clam; is THAT what you mean, Mrs.
-----
Hussey?
-----
" says I, "but that\'s a rather cold and clammy reception in the winter time, ain\'t it, Mrs.
-----
Hussey?
-----
"
'''
Melville の構文が少し古くなっていることを考えると、ここで完璧を期待することはできませんが、NLTK は終端の二重引用符と "Mrs." のようなタイトルを処理できるはずです。ただし、トークナイザーは教師なしトレーニング アルゴの結果であるため、それをいじる方法がわかりません。
より良い文のトークン化に関する推奨事項はありますか? 自分のパーサーをトレーニングするよりも、ハッキングできる単純なヒューリスティックの方が好きです。