POS使用NLTK正则表达式拆分文本

时间:2016-10-07 19:06:14

标签: python nltk

我正在尝试使用NLTK来帮助我解析一些文本。到目前为止,只使用sent_tokenize函数对组织文本非常有帮助。作为一个例子,我有:

1 Robins Drive owned by Gregg S. Smith was sold to TeStER, LLC of 494 Bridge Avenue, Suite 101-308, Sheltville AZ 02997 for $27,000.00.

使用:

words =pos_tag(word_tokenize(sentence))

我明白了:

[('1', 'CD'), ('Robins', 'NNP'), ('Drive', 'NNP'), ('owned', 'VBN'), ('by', 'IN'), ('Gregg', 'NNP'), ('S.', 'NNP'), ('Smith', 'NNP'), ('was', 'VBD'), ('sold', 'VBN'), ('to', 'TO'), ('TeStER', 'NNP'), (',', ','), ('LLC', 'NNP'), ('of', 'IN'), ('494', 'CD'), ('Bridge', 'NNP'), ('Avenue', 'NNP'), (',', ','), ('Suite', 'NNP'), ('101-308', 'CD'), (',', ','), ('Sheltville', 'NNP'), ('AZ', 'NNP'), ('02997', 'CD'), ('for', 'IN'), ('$', '$'), ('27,000.00', 'CD'), ('.', '.')]

我一直在查看各种教程和书籍http://www.nltk.org/book/,以及http://www.nltk.org/_modules/nltk/tokenize/regexp.html上的文档。

我注意到POS' IN' (来自http://nishutayaltech.blogspot.in/2015/02/penn-treebank-pos-tags-in-natural.html的介词或从属连词)会产生一些好的信息。我怎么能这样做?

0 个答案:

没有答案