我正在使用 Python 的 nltk,我想标记一个包含引号的句子,但它将 " 变成了 `` 和 '' .
例如:
>>> from nltk import word_tokenize
>>> sentence = 'He said "hey Bill!"'
>>> word_tokenize(sentence)
['He', 'said', '``', 'hey', 'Bill', '!', "''"]
为什么不保留原句中的引号,如何解决?
谢谢
请您参考如下方法:
它实际上是为了这样做,而不是偶然的。来自 Penn Treebank Tokenization
double quotes (") are changed to doubled single forward- and backward- quotes (`` and '')
在以前的版本中没有这样做,但是去年更新了。换句话说,如果你想改变你需要编辑 treebank.py
